aboutsummaryrefslogtreecommitdiff
path: root/src/algebra/array2.spad.pamphlet
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2013-05-14 07:38:41 +0000
committerdos-reis <gdr@axiomatics.org>2013-05-14 07:38:41 +0000
commitc582247ba667504452862dc5f8a007999ea367ca (patch)
tree6a2a6d1582d077d5ee30ccb46d5905d58376fdfe /src/algebra/array2.spad.pamphlet
parent8464a292621a8ebec25e9906415cf324e3f0b419 (diff)
downloadopen-axiom-c582247ba667504452862dc5f8a007999ea367ca.tar.gz
* algebra/array2.spad.pamphlet (InnerTwoDimensionalArray) [map]:
Move implementation from TwoDimensionalArrayCategory.
Diffstat (limited to 'src/algebra/array2.spad.pamphlet')
-rw-r--r--src/algebra/array2.spad.pamphlet25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/algebra/array2.spad.pamphlet b/src/algebra/array2.spad.pamphlet
index 1f23e4fb..9be6ee45 100644
--- a/src/algebra/array2.spad.pamphlet
+++ b/src/algebra/array2.spad.pamphlet
@@ -142,21 +142,6 @@ TwoDimensionalArrayCategory(R,Row,Col): Category == Definition where
entryList
--% Creation
- -- array creation requires an initial element used to
- -- populate the array. This is a best effort attempt
- -- to supply such element, when semantics permits.
- sampleElement(): R ==
- R has sample: () -> R => sample()$R
- NIL$Lisp -- better obfuscation welcome.
-
- map(f,m,n,r) ==
- maxRow := max(maxRowIndex m,maxRowIndex n)
- maxCol := max(maxColIndex m,maxColIndex n)
- ans := new(max(nrows m,nrows n),max(ncols m,ncols n),sampleElement())
- for i in minRowIndex(m)..maxRow repeat
- for j in minColIndex(m)..maxCol repeat
- qsetelt!(ans,i,j,f(elt(m,i,j,r),elt(n,i,j,r)))
- ans
setRow!(m,i,v) ==
i < minRowIndex(m) or i > maxRowIndex(m) =>
@@ -310,6 +295,16 @@ InnerTwoDimensionalArray(R,Row,Col):_
t.i := map(f,rep(m).i,rep(n).i)
per t
+ map(f,m,n,r) ==
+ nrows m = nrows n and ncols m = ncols n => map(f,m,n)
+ nr := max(nrows m,nrows n)
+ nc := max(ncols m,ncols n)
+ t: Rep := new(nr,sample$PrimitiveArray(R))
+ for i in 1..nr repeat
+ t.i := [[f(elt(m,i,j,r),elt(n,i,j,r))
+ for j in 1..nc]]$PrimitiveArray(R)
+ per t
+
@
\section{domain ARRAY2 TwoDimensionalArray}