diff options
author | dos-reis <gdr@axiomatics.org> | 2013-05-14 06:33:45 +0000 |
---|---|---|
committer | dos-reis <gdr@axiomatics.org> | 2013-05-14 06:33:45 +0000 |
commit | 8464a292621a8ebec25e9906415cf324e3f0b419 (patch) | |
tree | 59454f6043dc6e8a71f83a4018bfade6fcb1ebd9 /src/algebra/array2.spad.pamphlet | |
parent | 00573c0a522d42bc609c32afc473cfb2d219c4b7 (diff) | |
download | open-axiom-8464a292621a8ebec25e9906415cf324e3f0b419.tar.gz |
* algebra/array2.spad.pamphlet (TwoDimensionalArrayCategory): Move
defaults to InnerTwoDimensionalArray.
Diffstat (limited to 'src/algebra/array2.spad.pamphlet')
-rw-r--r-- | src/algebra/array2.spad.pamphlet | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/src/algebra/array2.spad.pamphlet b/src/algebra/array2.spad.pamphlet index f7597b79..1f23e4fb 100644 --- a/src/algebra/array2.spad.pamphlet +++ b/src/algebra/array2.spad.pamphlet @@ -149,41 +149,6 @@ TwoDimensionalArrayCategory(R,Row,Col): Category == Definition where R has sample: () -> R => sample()$R NIL$Lisp -- better obfuscation welcome. - copy m == - ans := new(nrows m,ncols m,sampleElement()) - for i in minRowIndex(m)..maxRowIndex(m) repeat - for j in minColIndex(m)..maxColIndex(m) repeat - qsetelt!(ans,i,j,qelt(m,i,j)) - ans - - fill!(m,r) == - for i in minRowIndex(m)..maxRowIndex(m) repeat - for j in minColIndex(m)..maxColIndex(m) repeat - qsetelt!(m,i,j,r) - m - - map(f,m) == - ans := new(nrows m,ncols m,sampleElement()) - for i in minRowIndex(m)..maxRowIndex(m) repeat - for j in minColIndex(m)..maxColIndex(m) repeat - qsetelt!(ans,i,j,f(qelt(m,i,j))) - ans - - map!(f,m) == - for i in minRowIndex(m)..maxRowIndex(m) repeat - for j in minColIndex(m)..maxColIndex(m) repeat - qsetelt!(m,i,j,f(qelt(m,i,j))) - m - - map(f,m,n) == - (nrows(m) ~= nrows(n)) or (ncols(m) ~= ncols(n)) => - error "map: arguments must have same dimensions" - ans := new(nrows m,ncols m,sampleElement()) - for i in minRowIndex(m)..maxRowIndex(m) repeat - for j in minColIndex(m)..maxColIndex(m) repeat - qsetelt!(ans,i,j,f(qelt(m,i,j),qelt(n,i,j))) - ans - map(f,m,n,r) == maxRow := max(maxRowIndex m,maxRowIndex n) maxCol := max(maxColIndex m,maxColIndex n) @@ -314,8 +279,36 @@ InnerTwoDimensionalArray(R,Row,Col):_ j < 1 or j > ncols m => error "column: index out of range" j := dec j [[rep(m).i.j for i in 0..nrows m - 1]]$Col - - + + copy m == + t: Rep := new(nrows m,sample$PrimitiveArray(R)) + for i in 0..maxIndex rep m repeat + t.i := copy rep(m).i + per t + + fill!(m,r) == + for i in 0..maxIndex rep m repeat + fill!(rep(m).i,r) + m + + map(f,m) == + t: Rep := new(nrows m,sample$PrimitiveArray(R)) + for i in 0..maxIndex rep m repeat + t.i := map(f,rep(m).i) + per t + + map!(f,m) == + for i in 0..maxIndex rep m repeat + map!(f,rep(m).i) + m + + map(f,m,n) == + nrows(m) ~= nrows(n) or ncols(m) ~= ncols(n) => + error "map: arguments must have same dimensions" + t: Rep := new(nrows m,sample$PrimitiveArray(R)) + for i in 0..maxIndex rep m repeat + t.i := map(f,rep(m).i,rep(n).i) + per t @ |