set_diagonal_matrixT_set_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrixset_diagonal_matrix (Operator)

Name

set_diagonal_matrixT_set_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrixset_diagonal_matrix — Set the diagonal elements of a matrix.

Signature

set_diagonal_matrix( : : MatrixID, VectorID, Diagonal : )

Herror T_set_diagonal_matrix(const Htuple MatrixID, const Htuple VectorID, const Htuple Diagonal)

void SetDiagonalMatrix(const HTuple& MatrixID, const HTuple& VectorID, const HTuple& Diagonal)

void HMatrix::SetDiagonalMatrix(const HMatrix& VectorID, Hlong Diagonal) const

static void HOperatorSet.SetDiagonalMatrix(HTuple matrixID, HTuple vectorID, HTuple diagonal)

void HMatrix.SetDiagonalMatrix(HMatrix vectorID, int diagonal)

def set_diagonal_matrix(matrix_id: HHandle, vector_id: HHandle, diagonal: int) -> None

Description

The operator set_diagonal_matrixset_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrixSetDiagonalMatrixset_diagonal_matrix overwrites the diagonal elements of the MatrixMatrixMatrixMatrixmatrixmatrix with the elements of the matrix VectorVectorVectorVectorvectorvector. The matrices are defined by their matrix handles MatrixIDMatrixIDMatrixIDMatrixIDmatrixIDmatrix_id and VectorIDVectorIDVectorIDVectorIDvectorIDvector_id. The matrix VectorVectorVectorVectorvectorvector must have one column and one row, n columns and one row or one column and n rows. n is the number of elements to be set in the MatrixMatrixMatrixMatrixmatrixmatrix (see below). If the matrix VectorVectorVectorVectorvectorvector has one column and one row, i.e., the matrix has one value, each element of the diagonal of the MatrixMatrixMatrixMatrixmatrixmatrix is overwritten by this value. Otherwise, the diagonal is overwritten by the elements of the matrix VectorVectorVectorVectorvectorvector.

If DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal = 0, the main diagonal of the MatrixMatrixMatrixMatrixmatrixmatrix is overwritten. The number n = min(number of rows of MatrixMatrixMatrixMatrixmatrixmatrix, number of columns of MatrixMatrixMatrixMatrixmatrixmatrix).

Example 1:

Example 2:

If DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal is positive, the DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal-th super-diagonal of MatrixMatrixMatrixMatrixmatrixmatrix is overwritten. For the example 1 the number n = min(number of rows of MatrixMatrixMatrixMatrixmatrixmatrix, parameter DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal). For the example 2 the number n = min(number of rows of MatrixMatrixMatrixMatrixmatrixmatrix, number of columns of MatrixMatrixMatrixMatrixmatrixmatrix).

Example 1:

Example 2:

If DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal is negative, the DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal-th sub-diagonal of MatrixMatrixMatrixMatrixmatrixmatrix is overwritten. For the example 1 the number n = min(number of columns of MatrixMatrixMatrixMatrixmatrixmatrix, parameter DiagonalDiagonalDiagonalDiagonaldiagonaldiagonal). For the example 2 the number n = min(number of rows of MatrixMatrixMatrixMatrixmatrixmatrix, number of columns of MatrixMatrixMatrixMatrixmatrixmatrix).

Example 1:

Example 2:

Execution Information

This operator modifies the state of the following input parameter:

During execution of this operator, access to the value of this parameter must be synchronized if it is used across multiple threads.

Parameters

MatrixIDMatrixIDMatrixIDMatrixIDmatrixIDmatrix_id (input_control, state is modified)  matrix HMatrix, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Matrix handle of the input matrix.

VectorIDVectorIDVectorIDVectorIDvectorIDvector_id (input_control)  matrix HMatrix, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Matrix handle containing the diagonal elements to be set.

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

Position of the diagonal.

Default value: 0

Suggested values: -20, -10, -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 10, 20

Result

If the parameters are valid, the operator set_diagonal_matrixset_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrixSetDiagonalMatrixset_diagonal_matrix returns the value TRUE. If necessary, an exception is raised.

Possible Predecessors

create_matrixcreate_matrixCreateMatrixCreateMatrixCreateMatrixcreate_matrix

Possible Successors

get_full_matrixget_full_matrixGetFullMatrixGetFullMatrixGetFullMatrixget_full_matrix, get_value_matrixget_value_matrixGetValueMatrixGetValueMatrixGetValueMatrixget_value_matrix

See also

get_diagonal_matrixget_diagonal_matrixGetDiagonalMatrixGetDiagonalMatrixGetDiagonalMatrixget_diagonal_matrix

Module

Foundation