Matrix.CopyFromDiagonal Method

Definition

Namespace: Numerics.NET
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.5.0

Overload List

CopyFromDiagonal<T>(Vector<T>) Creates a new DiagonalMatrix<T> with specified diagonal values.
CopyFromDiagonal<T>(Matrix<T>, ArrayMutability) Returns a copy of the diagonal part of a matrix.
CopyFromDiagonal<T>(Matrix<T>, Int32, Int32, ArrayMutability) Returns a copy of the diagonal part of a matrix with explicit dimensions.

CopyFromDiagonal<T>(Vector<T>)

Creates a new DiagonalMatrix<T> with specified diagonal values.
C#
public static DiagonalMatrix<T> CopyFromDiagonal<T>(
	Vector<T> diagonal
)

Parameters

diagonal  Vector<T>
A vector containing the diagonal values.

Type Parameters

T
The element type of the matrix.

Return Value

DiagonalMatrix<T>
A new DiagonalMatrix<T>.

Exceptions

ArgumentNullExceptiondiagonal is null.

CopyFromDiagonal<T>(Matrix<T>, ArrayMutability)

Returns a copy of the diagonal part of a matrix.
C#
public static Matrix<T> CopyFromDiagonal<T>(
	Matrix<T> source,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

source  Matrix<T>
The source matrix.
mutability  ArrayMutability  (Optional)
The desired mutability of the copy. The default is MutableValues.

Type Parameters

T
The element type of the matrix.

Return Value

Matrix<T>
A new matrix containing the diagonal elements of source; all off-diagonal elements are zero. In Professional edition this may be a DiagonalMatrix<T>.

Exceptions

ArgumentNullException

source is null.

CopyFromDiagonal<T>(Matrix<T>, Int32, Int32, ArrayMutability)

Returns a copy of the diagonal part of a matrix with explicit dimensions.
C#
public static Matrix<T> CopyFromDiagonal<T>(
	Matrix<T> source,
	int rowCount,
	int columnCount,
	ArrayMutability mutability = ArrayMutability.MutableValues
)

Parameters

source  Matrix<T>
The source matrix.
rowCount  Int32
The number of rows of the copy. Must be between 0 and the row count of source (inclusive).
columnCount  Int32
The number of columns of the copy. Must be between 0 and the column count of source (inclusive).
mutability  ArrayMutability  (Optional)
The desired mutability of the copy. The default is MutableValues.

Type Parameters

T
The element type of the matrix.

Return Value

Matrix<T>
A new rowCount×columnCount matrix containing the diagonal elements of the leading submatrix of source; all off-diagonal elements are zero.

Exceptions

ArgumentNullException

source is null.

ArgumentOutOfRangeException

rowCount is less than 0 or greater than the row count of source.

-or-

columnCount is less than 0 or greater than the column count of source.

See Also