extract the diagonals from a matrix or create a diagonal matrix - Maple Help

Online Help

All Products    Maple    MapleSim


Home : Support : Online Help : Connectivity : MTM Package : MTM/diag

MTM[diag] - extract the diagonals from a matrix or create a diagonal matrix

Calling Sequence

diag(A)

diag(A, k)

Parameters

A

-

matrix, vector, array, or scalar

k

-

(optional) integer

Description

• 

For a matrix A, the diag(A) command returns the main diagonal of A as a (column) vector.

• 

For a matrix A, the diag(A, k) command returns the (column) vector corresponding to the diagonal of A, specified by the selection parameter k.

• 

For a vector A, the diag(A) command returns a matrix with the entries of A along the main diagonal, and 0 everywhere else.

• 

For a vector A, the diag(A, k) command returns a matrix with the entries of A along the diagonal specified by the selection parameter k.

• 

The diagonals of a matrix are indexed using signed integers, where the main diagonal has index 0. Superdiagonals are indexed with positive integers and subdiagonals are indexed with negative integers.

Examples

withMTM:

A:=Matrix1,2,1,4,5,6,2,8,1

A:=121456281

(1)

diagA

151

(2)

diagA,1

26

(3)

diagA,1

48

(4)

B:=Vector4,5,6

B:=456

(5)

diagB

400050006

(6)

diagB,1

0400005000060000

(7)

diagB,1

0000400005000060

(8)

See Also

ArrayTools[Diagonal], LinearAlgebra[Diagonal], LinearAlgebra[DiagonalMatrix], MTM[tril], MTM[triu]


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam