aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/matcat.spad.pamphlet
diff options
context:
space:
mode:
Diffstat (limited to 'src/algebra/matcat.spad.pamphlet')
-rw-r--r--src/algebra/matcat.spad.pamphlet12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/algebra/matcat.spad.pamphlet b/src/algebra/matcat.spad.pamphlet
index d84feb2b..d0bcd007 100644
--- a/src/algebra/matcat.spad.pamphlet
+++ b/src/algebra/matcat.spad.pamphlet
@@ -37,6 +37,8 @@ MatrixCategory(R,Row,Col): Category == Definition where
R : Ring
Row : FiniteLinearAggregate R
Col : FiniteLinearAggregate R
+ macro NNI == NonNegativeInteger
+ macro I == Integer
Definition ==> TwoDimensionalArrayCategory(R,Row,Col) with
shallowlyMutable
@@ -70,6 +72,9 @@ MatrixCategory(R,Row,Col): Category == Definition where
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.
+ matrix: (NNI, NNI, (I,I) -> R) -> %
+ ++ \spad{matrix(n,m,f)} construcys and \spad{n * m} matrix with
+ ++ the \spad{(i,j)} entry equal to \spad{f(i,j)}.
scalarMatrix: (NonNegativeInteger,R) -> %
++ \spad{scalarMatrix(n,r)} returns an n-by-n matrix with r's on the
++ diagonal and zeroes elsewhere.
@@ -264,6 +269,13 @@ MatrixCategory(R,Row,Col): Category == Definition where
qsetelt!(ans,i,j,r)
ans
+ matrix(n,m,f) ==
+ mat := new(n,m,0)
+ for i in minr mat..maxr mat repeat
+ for j in minc mat..maxc mat repeat
+ qsetelt!(mat,i,j,f(i,j))
+ mat
+
scalarMatrix(n,r) ==
ans := zero(n,n)
for i in minr(ans)..maxr(ans) for j in minc(ans)..maxc(ans) repeat