create_matrixT_create_matrixCreateMatrixCreateMatrixcreate_matrix (Operator)


create_matrixT_create_matrixCreateMatrixCreateMatrixcreate_matrix — Create a matrix.


create_matrix( : : Rows, Columns, Value : MatrixID)

Herror T_create_matrix(const Htuple Rows, const Htuple Columns, const Htuple Value, Htuple* MatrixID)

void CreateMatrix(const HTuple& Rows, const HTuple& Columns, const HTuple& Value, HTuple* MatrixID)

void HMatrix::HMatrix(Hlong Rows, Hlong Columns, const HTuple& Value)

void HMatrix::HMatrix(Hlong Rows, Hlong Columns, double Value)

void HMatrix::CreateMatrix(Hlong Rows, Hlong Columns, const HTuple& Value)

void HMatrix::CreateMatrix(Hlong Rows, Hlong Columns, double Value)

static void HOperatorSet.CreateMatrix(HTuple rows, HTuple columns, HTuple value, out HTuple matrixID)

public HMatrix(int rows, int columns, HTuple value)

public HMatrix(int rows, int columns, double value)

void HMatrix.CreateMatrix(int rows, int columns, HTuple value)

void HMatrix.CreateMatrix(int rows, int columns, double value)

def create_matrix(rows: int, columns: int, value: MaybeSequence[Union[int, float, str]]) -> HHandle


The operator create_matrixcreate_matrixCreateMatrixCreateMatrixCreateMatrixcreate_matrix creates a new Matrix with RowsRowsRowsRowsrowsrows rows and ColumnsColumnsColumnsColumnscolumnscolumns columns and returns the matrix handle MatrixIDMatrixIDMatrixIDMatrixIDmatrixIDmatrix_id. Access to the elements of the matrix is possible e.g., with the operator get_full_matrixget_full_matrixGetFullMatrixGetFullMatrixGetFullMatrixget_full_matrix. The parameter ValueValueValueValuevaluevalue is a string or a tuple of floating point or integer numbers. Integer numbers are converted to floating point numbers automatically.

If ValueValueValueValuevaluevalue = 'identity'"identity""identity""identity""identity""identity", RowsRowsRowsRowsrowsrows and ColumnsColumnsColumnsColumnscolumnscolumns must have the identical values and an identity matrix is created.

Example: Rows = 3 Columns = 3 Value = 'identity'

If the parameter ValueValueValueValuevaluevalue contains a single value, all elements of the matrix are filled with this value.

Example: Rows = 3 Columns = 3 Value = 7

If ValueValueValueValuevaluevalue contains as many values as the main diagonal, all elements of the main diagonal are set to the values of the parameter ValueValueValueValuevaluevalue (i.e., the number of elements in ValueValueValueValuevaluevalue is identical).

Example: Rows = 3 Columns = 4 Value = [3, 7, 1]

It is also possible to set all elements of the matrix with different values. In this case the parameter ValueValueValueValuevaluevalue must contain all values in a row-major order, i.e., stored line by line. In addition, the number of elements of ValueValueValueValuevaluevalue must be identical to the number of all elements of the matrix, i.e., RowsRowsRowsRowsrowsrows * ColumnsColumnsColumnsColumnscolumnscolumns.

Example: Rows = 3 Columns = 3 Value = [3,1,-2,-5,7,2,-9,-4,1]

It should be noted that in the examples there are differences in the meaning of the values of the output matrices: If a value is shown as an integer number, e.g., 0 or 1, the value of this element is per definition this certain value. If the number is shown as a floating point number, e.g., 0.0 or 1.0, the value is computed by the operator.

Execution Information

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.


RowsRowsRowsRowsrowsrows (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of rows of the matrix.

Default value: 3

Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 50, 100

Restriction: Rows >= 1

ColumnsColumnsColumnsColumnscolumnscolumns (input_control)  integer HTupleintHTupleHtuple (integer) (int / long) (Hlong) (Hlong)

Number of columns of the matrix.

Default value: 3

Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 50, 100

Restriction: Columns >= 1

ValueValueValueValuevaluevalue (input_control)  number(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (real / integer / string) (double / int / long / string) (double / Hlong / HString) (double / Hlong / char*)

Values for initializing the elements of the matrix.

Default value: 0

Suggested values: 0, 1, 'identity'"identity""identity""identity""identity""identity"

MatrixIDMatrixIDMatrixIDMatrixIDmatrixIDmatrix_id (output_control)  matrix HMatrix, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Matrix handle.


If the parameters are valid, the operator create_matrixcreate_matrixCreateMatrixCreateMatrixCreateMatrixcreate_matrix returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Possible Successors

set_full_matrixset_full_matrixSetFullMatrixSetFullMatrixSetFullMatrixset_full_matrix, clear_matrixclear_matrixClearMatrixClearMatrixClearMatrixclear_matrix