ClassesClasses | | Operators

set_diagonal_matrixset_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrix (Operator)

Name

set_diagonal_matrixset_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrix — Set the diagonal elements of a matrix.

Signature

set_diagonal_matrix( : : MatrixID, VectorID, Diagonal : )

Herror set_diagonal_matrix(const Hlong MatrixID, const Hlong VectorID, const Hlong 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)

Description

The operator set_diagonal_matrixset_diagonal_matrixSetDiagonalMatrixSetDiagonalMatrixSetDiagonalMatrix overwrites the diagonal elements of the MatrixMatrixMatrixMatrixmatrix with the elements of the matrix VectorVectorVectorVectorvector. The matrices are defined by their matrix handles MatrixIDMatrixIDMatrixIDMatrixIDmatrixID and VectorIDVectorIDVectorIDVectorIDvectorID. The matrix VectorVectorVectorVectorvector 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 MatrixMatrixMatrixMatrixmatrix (see below). If the matrix VectorVectorVectorVectorvector has one column and one row, i.e., the matrix has one value, each element of the diagonal of the MatrixMatrixMatrixMatrixmatrix is overwritten by this value. Otherwise, the diagonal is overwritten by the elements of the matrix VectorVectorVectorVectorvector.

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

Example 1:

Example 2:

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

Example 1:

Example 2:

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

Example 1:

Example 2:

Execution Information

This operator modifies the state of the following input parameter:

The value of this parameter may not be shared across multiple threads without external synchronization.

Parameters

MatrixIDMatrixIDMatrixIDMatrixIDmatrixID (input_control, state is modified)  matrix HMatrix, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Matrix handle of the input matrix.

VectorIDVectorIDVectorIDVectorIDvectorID (input_control)  matrix HMatrix, HTupleHTupleHtuple (integer) (IntPtr) (Hlong) (Hlong)

Matrix handle containing the diagonal elements to be set.

DiagonalDiagonalDiagonalDiagonaldiagonal (input_control)  integer HTupleHTupleHtuple (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_matrixSetDiagonalMatrixSetDiagonalMatrixSetDiagonalMatrix returns the value 2 (H_MSG_TRUE). If necessary, an exception is raised.

Possible Predecessors

create_matrixcreate_matrixCreateMatrixCreateMatrixCreateMatrix

Possible Successors

get_full_matrixget_full_matrixGetFullMatrixGetFullMatrixGetFullMatrix, get_value_matrixget_value_matrixGetValueMatrixGetValueMatrixGetValueMatrix

See also

get_diagonal_matrixget_diagonal_matrixGetDiagonalMatrixGetDiagonalMatrixGetDiagonalMatrix

Module

Foundation


ClassesClasses | | Operators