The diagonal Indexing Function - Maple Programming Help

Home : Support : Online Help : Programming : Data Types : Tables, lists, and sets : indexing functions : indexfcn/diagonal

The diagonal Indexing Function

Description

 • The diagonal indexing function can be used to construct tables and rtable objects of type Array or Matrix.
 • The diagonal indexing function returns 0 as the value for all components whose indices are not identical.
 • In the construction of an m x n diagonal Matrix (rtable-based), if the initializer parameter is a Vector, then the entries of this Vector are placed along the main diagonal of the constructed Matrix, starting at position (1, 1).
 • Under normal circumstances, Maple only stores the diagonal elements.
 • If an object is defined by using the diagonal indexing function,  the elements located off the diagonal cannot be reassigned.
 In the case of a table, if you know that the elements may be reassigned, use the sparse indexing function instead.

Examples

 > $V≔\mathrm{Vector}\left(\left[1,2,3\right]\right)$
 ${V}{≔}\left[\begin{array}{c}{1}\\ {2}\\ {3}\end{array}\right]$ (1)
 > $M≔\mathrm{Matrix}\left(1..4,1..4,V,\mathrm{shape}=\mathrm{diagonal}\right)$
 ${M}{≔}\left[\begin{array}{cccc}{1}& {0}& {0}& {0}\\ {0}& {2}& {0}& {0}\\ {0}& {0}& {3}& {0}\\ {0}& {0}& {0}& {0}\end{array}\right]$ (2)