diff options
author | dos-reis <gdr@axiomatics.org> | 2010-06-27 20:40:42 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2010-06-27 20:40:42 +0000 |
commit | c18c464e8da9c36f71e468d52f3090a13acb4fa9 (patch) | |
tree | 6d2ad504471ca0e911acc1e6ba3b41ee71755ee9 /src/algebra/matcat.spad.pamphlet | |
parent | 29325dbb1fed9b472690b8541ef038f138070aea (diff) | |
download | open-axiom-c18c464e8da9c36f71e468d52f3090a13acb4fa9.tar.gz |
* algebra/matcat.spad.pamphlet (MatrixCategory) [matrix]:
Add overload that takes sizes and function to compute entries.
Diffstat (limited to 'src/algebra/matcat.spad.pamphlet')
-rw-r--r-- | src/algebra/matcat.spad.pamphlet | 12 |
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 |