aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/SQMATRIX.ht
blob: b5db8bcf40c8e96d451f2ef8fb6eecd8e0e90bb1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
\newcommand{\SquareMatrixXmpTitle}{SquareMatrix}
\newcommand{\SquareMatrixXmpNumber}{9.74}
%
% =====================================================================
\begin{page}{SquareMatrixXmpPage}{9.74 SquareMatrix}
% =====================================================================
\beginscroll
 
The top level matrix type in \Language{} is \spadtype{Matrix}
(see \downlink{`Matrix'}{MatrixXmpPage}\ignore{Matrix}), which
provides basic arithmetic and linear algebra functions.
However, since the matrices can be of any size it is not true that any pair
can be added or multiplied.
Thus \spadtype{Matrix} has little algebraic structure.
 
Sometimes you want to use matrices as coefficients for polynomials
or in other algebraic contexts.  In this case, \spadtype{SquareMatrix}
%-% \HDindex{matrix!square}{SquareMatrixXmpPage}{9.74}{SquareMatrix}
should be used.  The domain \spadtype{SquareMatrix(n,R)} gives the ring of
\spad{n} by \spad{n} square matrices over \spad{R}.
 
\xtc{
Since \spadtype{SquareMatrix} is not normally exposed at the top level,
you must expose it before it can be used.
}{
\spadpaste{)set expose add constructor SquareMatrix \bound{SQ}}
}
\xtc{
Once \spad{SQMATRIX} has been exposed,
values can be created using the \spadfunFrom{squareMatrix}{SquareMatrix}
function.
}{
\spadpaste{m := squareMatrix [[1,-\%i],[\%i,4]] \bound{m}\free{SQ}}
}
\xtc{
The usual arithmetic operations are available.
}{
\spadpaste{m*m - m \free{m}}
}
\xtc{
Square matrices can be used where ring elements are required.
For example, here is a matrix with matrix entries.
}{
\spadpaste{mm := squareMatrix [[m, 1], [1-m, m**2]] \free{m}\bound{mm}}
}
\xtc{
Or you can construct a polynomial with  square matrix coefficients.
}{
\spadpaste{p := (x + m)**2 \free{m}\bound{p}}
}
\xtc{
This value can be converted to a square matrix with polynomial coefficients.
}{
\spadpaste{p::SquareMatrix(2, ?) \free{p}}
}
 
For more information on related topics, see
\downlink{``\ugTypesWritingModesTitle''}{ugTypesWritingModesPage} in Section \ugTypesWritingModesNumber\ignore{ugTypesWritingModes},
\downlink{``\ugTypesExposeTitle''}{ugTypesExposePage} in Section \ugTypesExposeNumber\ignore{ugTypesExpose}, and
\downlink{`Matrix'}{MatrixXmpPage}\ignore{Matrix}.
\showBlurb{SquareMatrix}
\endscroll
\autobuttons
\end{page}
%