Function: math[dim/identity] - creates an identity matrix
Calling Sequence:
dim(n, 'identity');
dim(m, n, 'identity');
dim(n1, n2, ..., nz, 'identity');
Parameters:
m, n, n1, n2, nz - positive integers
Description:
In the first form, dim/identity creates a (n, n)-matrix A with elements
= 0 for i <> j and
= 1.
In the second form, dim/identity creates a (m, n)-matrix A with elements
= 0 for i <> j and
= 1.
In the third form, dim/identity creates an array A with dimensions 1 .. n1, 1 .. n2, ..., 1 .. nz. If all coordinates (x1, x2, ..., xz) of an index are equal, i.e. x1 = x2 = ... = xz then A[x1, x2, ..., xz] is assigned the value 1, and 0 otherwise.
The return of dim/identity is an array. It does not feature the `identity` property so that you can assign elements that are off-diagonal.
A shortcut for the option 'identity' is 'id'.
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, dim):
> A := array(identity, 1 .. 3, 1 .. 3): eval(A);
> B := dim(3, id);
> op(eval(B));
> B[1, 2] := 1;
See Also:
math/dim , math/dim/diagonal , math/isIdentity , array , linalg/matrix , linalg/vector , linalg .
Version History:
Version 1.0 - March 16, 1998