Skip to content

create_matrixCreateMatrixCreateMatrixcreate_matrixT_create_matrix🔗

Short description🔗

create_matrixCreateMatrixCreateMatrixcreate_matrixT_create_matrix — Create a matrix.

Signature🔗

create_matrix( integer Rows, integer Columns, number Value, out matrix MatrixID )void CreateMatrix( const HTuple& Rows, const HTuple& Columns, const HTuple& Value, HTuple* MatrixID )static void HOperatorSet.CreateMatrix( HTuple rows, HTuple columns, HTuple value, out HTuple matrixID )def create_matrix( rows: int, columns: int, value: MaybeSequence[Union[int, float, str]] ) -> HHandle

Herror T_create_matrix( 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 )

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

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

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

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

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

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

Description🔗

The operator create_matrixCreateMatrix creates a new Matrix with Rowsrowsrows rows and Columnscolumnscolumns columns and returns the matrix handle MatrixIDmatrixIDmatrix_id. Access to the elements of the matrix is possible e.g., with the operator get_full_matrixGetFullMatrix. The parameter Valuevaluevalue is a string or a tuple of floating point or integer numbers. Integer numbers are converted to floating point numbers automatically.

If Valuevaluevalue = 'identity'"identity", Rowsrowsrows and Columnscolumnscolumns must have the identical values and an identity matrix is created.

Example:

Rowsrowsrows = 33, Columnscolumnscolumns = 33, Valuevaluevalue = 'identity'"identity"

\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \mvMatrix{ 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 } \end{eqnarray*}\]

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

Example:

Rowsrowsrows = 33, Columnscolumnscolumns = 33, Valuevaluevalue = 77

\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \mvMatrix{ 7.0 & 7.0 & 7.0 \\ 7.0 & 7.0 & 7.0 \\ 7.0 & 7.0 & 7.0 } \end{eqnarray*}\]

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

Example:

Rowsrowsrows = 33, Columnscolumnscolumns = 44, Valuevaluevalue = [3, 7, 1][3, 7, 1]

\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \mvMatrix{ 3.0 & 0 & 0 & 0 \\ 0 & 7.0 & 0 & 0 \\ 0 & 0 & 1.0 & 0 } \end{eqnarray*}\]

It is also possible to set all elements of the matrix with different values. In this case the parameter Valuevaluevalue must contain all values in a row-major order, i.e., stored line by line. In addition, the number of elements of Valuevaluevalue must be identical to the number of all elements of the matrix, i.e., Rowsrowsrows \(\times\) Columnscolumnscolumns.

Example:

Rowsrowsrows = 33, Columnscolumnscolumns = 33, Valuevaluevalue = [3, 1, -2, -5, 7, 2, -9, -4, 1][3, 1, -2, -5, 7, 2, -9, -4, 1]

\[\begin{eqnarray*} \to \qquad \texttt{Matrix} = \left[ \begin{array}{rrr} 3.0 & 1.0 & -2.0 \\ -5.0 & 7.0 & 2.0 \\ -9.0 & -4.0 & 1.0 \end{array} \right] \end{eqnarray*}\]

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🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

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.

Parameters🔗

Rowsrowsrows (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of rows of the matrix.

Default: 33
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 50, 1001, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 50, 100
Restriction: Rows >= 1

Columnscolumnscolumns (input_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Number of columns of the matrix.

Default: 33
Suggested values: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 50, 1001, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 30, 50, 100
Restriction: Columns >= 1

Valuevaluevalue (input_control) number(-array) → (real / integer / string)HTuple (double / Hlong / HString)HTuple (double / int / long / string)MaybeSequence[Union[int, float, str]]Htuple (double / Hlong / char*)

Values for initializing the elements of the matrix.

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

MatrixIDmatrixIDmatrix_id (output_control) matrix → (handle)HTuple (HHandle)HMatrix, HTuple (IntPtr)HHandleHtuple (handle)

Matrix handle.

Result🔗

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

Combinations with other operators🔗

Combinations

Possible successors

set_full_matrixSetFullMatrix, clear_matrixClearMatrix

Module🔗

Foundation