Function: math[dim/diagonal] - create a diagonal matrix

Calling Sequence:

dim(L, 'diagonal');

Parameters:

L - a list

'diagonal' - the name

Description:

dim with the option 'diagonal' (or 'diag' for short) creates a square matrix (A) and puts the elements in L on the main diagonal. The first element in L is assigned index A[1, 1], the second element is assigned index A[2, 2], etc. Thus dim/diagonal creates a (nops(L), nops(L))-matrix/array.

The return of dim/diagonal is an array with dimensions 1 .. nops(L), 1 .. nops(L). It does not feature the `diagonal` property so that you can assign elements that are off-diagonal.

This function is part of the math package, and so can be used only after performing the command with(math) or with(math, dim).

Examples:

> with(math):

> A := array(diagonal, 1 .. 3, 1 .. 3, [(1, 1)=1, (2, 2)=2, (3, 3)=3]);

[Maple Math]

> B := dim([1, 2, 3], diag);

[Maple Math]

> B[2, 1] := 1;

[Maple Math]

> eval(B);

[Maple Math]

> op(eval(B));

[Maple Math]
[Maple Math]

See Also:

math/dim , math/dim/identity , math/isDiagonal , array , linalg/matrix , linalg/vector , linalg .

Version History:

Version 1.0 - March 16, 1998