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 | |
parent | 00573c0a522d42bc609c32afc473cfb2d219c4b7 (diff) | |
download | open-axiom-8464a292621a8ebec25e9906415cf324e3f0b419.tar.gz |
* algebra/array2.spad.pamphlet (TwoDimensionalArrayCategory): Move
defaults to InnerTwoDimensionalArray.
Diffstat (limited to 'src')
-rw-r--r-- | src/ChangeLog | 5 | ||||
-rw-r--r-- | src/algebra/array2.spad.pamphlet | 67 |
2 files changed, 35 insertions, 37 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 35a9db68..1e25e2e0 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-05-14 Gabriel Dos Reis <gdr@integrable-solutions.net> + + * algebra/array2.spad.pamphlet (TwoDimensionalArrayCategory): Move + defaults to InnerTwoDimensionalArray. + 2013-05-14 Edi Meier <liste_franken@gmx.de> * graph/include/G.h (GCstruct::GCchar): Increase length to 12. 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 @ |