/usr/share/axiom-20170501/src/algebra/RMATCAT.spad is in axiom-source 20170501-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | )abbrev category RMATCAT RectangularMatrixCategory
++ Authors: Grabmeier, Gschnitzer, Williamson
++ Date Created: 1987
++ Date Last Updated: July 1990
++ Description:
++ \spadtype{RectangularMatrixCategory} is a category of matrices of fixed
++ dimensions. The dimensions of the matrix will be parameters of the
++ domain. Domains in this category will be R-modules and will be non-mutable.
RectangularMatrixCategory(m,n,R,Row,Col) : Category == SIG where
m : NonNegativeInteger
n : NonNegativeInteger
R : Ring
Row : DirectProductCategory(n,R)
Col : DirectProductCategory(m,R)
SIG ==> Join(BiModule(R,R),HomogeneousAggregate(R)) with
finiteAggregate
++ matrices are finite
if R has CommutativeRing then Module(R)
--% Matrix creation
matrix : List List R -> %
++ \spad{matrix(l)} converts the list of lists l to a matrix, where the
++ list of lists is viewed as a list of the rows of the matrix.
--% Predicates
square? : % -> Boolean
++ \spad{square?(m)} returns true if m is a square matrix (that is, if m
++ has the same number of rows as columns) and false otherwise.
diagonal? : % -> Boolean
++ \spad{diagonal?(m)} returns true if the matrix m is square and
++ diagonal (that is, all entries of m not on the diagonal are zero) and
++ false otherwise.
symmetric? : % -> Boolean
++ \spad{symmetric?(m)} returns true if the matrix m is square and
++ symmetric (that is, \spad{m[i,j] = m[j,i]} for all \spad{i} and j) and
++ false otherwise.
antisymmetric? : % -> Boolean
++ \spad{antisymmetric?(m)} returns true if the matrix m is square and
++ antisymmetric. That is,
++ \spad{m[i,j] = -m[j,i]} for all \spad{i} and j
++ and false otherwise.
--% Size inquiries
minRowIndex : % -> Integer
++ \spad{minRowIndex(m)} returns the index of the 'first' row of the
++ matrix m.
maxRowIndex : % -> Integer
++ \spad{maxRowIndex(m)} returns the index of the 'last' row of the
++ matrix m.
minColIndex : % -> Integer
++ \spad{minColIndex(m)} returns the index of the 'first' column of the
++ matrix m.
maxColIndex : % -> Integer
++ \spad{maxColIndex(m)} returns the index of the 'last' column of the
++ matrix m.
nrows : % -> NonNegativeInteger
++ \spad{nrows(m)} returns the number of rows in the matrix m.
ncols : % -> NonNegativeInteger
++ \spad{ncols(m)} returns the number of columns in the matrix m.
--% Part extractions
listOfLists : % -> List List R
++ \spad{listOfLists(m)} returns the rows of the matrix m as a list
++ of lists.
elt : (%,Integer,Integer) -> R
++ \spad{elt(m,i,j)} returns the element in the \spad{i}th row and
++ \spad{j}th column of the matrix m.
++ Error: if indices are outside the proper
++ ranges.
qelt : (%,Integer,Integer) -> R
++ \spad{qelt(m,i,j)} returns the element in the \spad{i}th row and
++ \spad{j}th column of
++ the matrix m. Note that there is NO error check to determine
++ if indices are in the proper ranges.
elt : (%,Integer,Integer,R) -> R
++ \spad{elt(m,i,j,r)} returns the element in the \spad{i}th row and
++ \spad{j}th column of the matrix m, if m has an \spad{i}th row and a
++ \spad{j}th column, and returns r otherwise.
row : (%,Integer) -> Row
++ \spad{row(m,i)} returns the \spad{i}th row of the matrix m.
++ Error: if the index is outside the proper range.
column : (%,Integer) -> Col
++ \spad{column(m,j)} returns the \spad{j}th column of the matrix m.
++ Error: if the index outside the proper range.
--% Map and Zip
map : (R -> R,%) -> %
++ \spad{map(f,a)} returns b, where \spad{b(i,j) = a(i,j)} for all i, j.
map : ((R,R) -> R,%,%) -> %
++ \spad{map(f,a,b)} returns c, where c is such that
++ \spad{c(i,j) = f(a(i,j),b(i,j))} for all \spad{i}, j.
--% Arithmetic
if R has IntegralDomain then
"exquo" : (%,R) -> Union(%,"failed")
++ \spad{exquo(m,r)} computes the exact quotient of the elements
++ of m by r, returning \axiom{"failed"} if this is not possible.
if R has Field then
"/" : (%,R) -> %
++ \spad{m/r} divides the elements of m by r. Error: if \spad{r = 0}.
--% Linear algebra
if R has EuclideanDomain then
rowEchelon : % -> %
++ \spad{rowEchelon(m)} returns the row echelon form of the matrix m.
if R has IntegralDomain then
rank : % -> NonNegativeInteger
++ \spad{rank(m)} returns the rank of the matrix m.
nullity : % -> NonNegativeInteger
++ \spad{nullity(m)} returns the nullity of the matrix m. This is
++ the dimension of the null space of the matrix m.
nullSpace : % -> List Col
++ \spad{nullSpace(m)}+ returns a basis for the null space of
++ the matrix m.
add
nrows x == m
ncols x == n
square? x == m = n
diagonal? x ==
not square? x => false
for i in minRowIndex x .. maxRowIndex x repeat
for j in minColIndex x .. maxColIndex x
| (j - minColIndex x) ^= (i - minRowIndex x) repeat
not zero? qelt(x, i, j) => return false
true
symmetric? x ==
m ^= n => false
mr := minRowIndex x; mc := minColIndex x
for i in 0..(n - 1) repeat
for j in (i + 1)..(n - 1) repeat
qelt(x,mr + i,mc + j) ^= qelt(x,mr + j,mc + i) => return false
true
antisymmetric? x ==
m ^= n => false
mr := minRowIndex x; mc := minColIndex x
for i in 0..(n - 1) repeat
for j in i..(n - 1) repeat
qelt(x,mr + i,mc + j) ^= -qelt(x,mr + j,mc + i) =>
return false
true
|