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

Reshape() public static method

Reshapes the supplied Vector into a Matrix form.
public static Reshape ( Vector v, int dimension, VectorType dimensionType = VectorType.Col, VectorType byVector = VectorType.Row ) : Matrix
v Vector Source vector to act on.
dimension int Length of the specified dimension.
dimensionType VectorType Dimension type to use for creating a by n matrix.
byVector VectorType Direction to process, i.e. Row = Fill Down then Right, or Col = Fill Right then Down
return Matrix
        public static Matrix Reshape(Vector v, int dimension, VectorType dimensionType = VectorType.Col, VectorType byVector = VectorType.Row)
        {
            int x = (dimensionType == VectorType.Row ? dimension : v.Length / dimension);
            int y = (dimensionType == VectorType.Col ? dimension : v.Length / dimension);
            return Reshape(v, x, y, byVector);
        }

Same methods

Matrix::Reshape ( Matrix m, int rows, int cols ) : Matrix
Matrix::Reshape ( Vector v, int rows, int columns, VectorType byVector = VectorType.Row ) : Matrix

Usage Example

Exemplo n.º 1
0
 /// <summary>
 /// Reshapes the given Vector into a Matrix form given the specified dimension.
 /// <para>Reads from the source vector and repopulates from left to right when <paramref name="vectorType"/> equals 'Col' otherwise uses top down approach.</para>
 /// </summary>
 /// <param name="source"></param>
 /// <param name="dimension">If the <paramref name="vectorType"/> equals 'Col' the <paramref name="dimension"/> becomes the column width otherwise it is row height.</param>
 /// <param name="vectorType">Unit type of the dimension to use when rebuilding the Matrix.</param>
 /// <param name="fillType">Direction to process, i.e. Row = Fill Down then Right, or Col = Fill Right then Down</param>
 /// <returns>Matrix.</returns>
 public static Matrix Reshape(this Vector source, int dimension, VectorType vectorType = VectorType.Col, VectorType fillType = VectorType.Row)
 {
     return(Matrix.Reshape(source, dimension, vectorType, fillType));
 }