Function: math[mainDiagonal] - extracts the main diagonal from a square matrix
Calling Sequence:
mainDiagonal(A);
Parameters:
A - an array
Description:
mainDiagonal returns the main diagonal in the square matrix A.
The return is a list of all the elements on the main diagonal. If A is not a square matrix then mainDiagonal returns the empty list ([ ] or [ NULL ]).
This function is part of the math package, and so can be used only after performing the command with(math) or with(math, mainDiagonal).
Examples:
> with(math):
> A := matrix([[1, 2, 3], [4, 5, 6], [7, 8, 9]]);
> mainDiagonal(A);
> B := array(diagonal, 1 .. 2, 1 .. 2, [(1, 1)=a, (2, 2)=b]);
> mainDiagonal(B);
See Also:
Version History:
Version 1.0 - March 20, 1998