numl.Math.LinearAlgebra.Matrix.VStack C# (CSharp) Method

VStack() public static method

Stacks.
Thrown when the requested operation is invalid.
public static VStack ( Matrix m, Matrix t ) : Matrix
m Matrix Input Matrix.
t Matrix Row or Column sum.
return Matrix
        public static Matrix VStack(Matrix m, Matrix t)
        {
            if (m.Rows != t.Rows)
                throw new InvalidOperationException("Invalid dimension for stack operation!");

            Matrix p = new Matrix(m.Rows, m.Cols + t.Cols);
            for (int i = 0; i < p.Rows; i++)
            {
                for (int j = 0; j < p.Cols; j++)
                {
                    if (j < m.Cols)
                        p[i, j] = m[i, j];
                    else
                        p[i, j] = t[i, j - m.Cols];
                }
            }

            return p;
        }

Same methods

Matrix::VStack ( ) : Matrix

Usage Example

Exemplo n.º 1
0
 /// <summary>A Matrix extension method that stacks.</summary>
 /// <param name="m">Matrix.</param>
 /// <param name="t">Row or Column sum.</param>
 /// <returns>A Matrix.</returns>
 public static Matrix VStack(this Matrix m, Matrix t)
 {
     return(Matrix.VStack(m, t));
 }