matrix stuff
authorClaus Gittinger <cg@exept.de>
Tue, 20 Aug 2019 15:16:10 +0200
changeset 5088 72f0347803b6
parent 5087 2d85f44acc3e
child 5089 f3fc05f21250
matrix stuff
extensions.st
--- a/extensions.st	Tue Aug 20 15:10:57 2019 +0200
+++ b/extensions.st	Tue Aug 20 15:16:10 2019 +0200
@@ -897,6 +897,84 @@
     "Modified (comment): / 12-06-2017 / 20:55:24 / cg"
 ! !
 
+!Object methodsFor:'accessing'!
+
+_at:index
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] is parsed.
+     I.e. 
+        foo[n]
+     generates
+        foo _at: n
+    "
+    ^ self at:index
+! !
+
+!Object methodsFor:'accessing'!
+
+_at:index1 at:index2
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] is parsed.
+     I.e. 
+        foo[n,m]
+     generates
+        foo _at:n at:m
+    "
+    ^ (self at:index1) at:index2
+! !
+
+!Object methodsFor:'accessing'!
+
+_at:index1 at:index2 at:index3
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] is parsed.
+     I.e. 
+        foo[n,m,o]
+     generates
+        foo _at:n at:m at:o
+    "
+    ^ ((self at:index1) at:index2) at:index3
+! !
+
+!Object methodsFor:'accessing'!
+
+_at:index1 at:index2 at:index3 put:val
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] := val is parsed.
+     I.e. 
+        foo[n,m,o] := val
+     generates
+        foo _at:n at:m at:o put:val
+    "
+    ^ ((self at:index1) at:index2) at:index3 put:val
+! !
+
+!Object methodsFor:'accessing'!
+
+_at:index1 at:index2 put:val
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] := val is parsed.
+     I.e. 
+        foo[n,m] := val
+     generates
+        foo _at:n at:m put:val
+    "
+    ^ (self at:index1) at:index2 put:val                   
+! !
+
+!Object methodsFor:'accessing'!
+
+_at:index put:val
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] := val is parsed.
+     I.e. 
+        foo[n] := val
+     generates
+        foo _at:n put:val
+    "
+    ^ self at:index put:val
+! !
+
 !Object methodsFor:'dependents-interests'!
 
 addInterest:anInterest
@@ -1437,6 +1515,58 @@
     self expressInterestIn:anAspect for:anObject sendBack:anAspect
 ! !
 
+!SequenceableCollection class methodsFor:'instance creation - multiDimensional'!
+
+_at:nIndices
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] is parsed.
+     I.e. 
+        Array[n]
+     generates
+        Array _at: n
+    "
+
+    ^ self new:nIndices
+! !
+
+!SequenceableCollection class methodsFor:'instance creation - multiDimensional'!
+
+_at:dim1 at:dim2
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] is parsed.
+     I.e. 
+        Array[n,m]
+     generates
+        Array _at:n at:m
+    "
+
+    |data|
+
+    data := self withSize:(dim1 * dim2).
+    ^ MultiDimensionalArrayAccessor
+        collection:data
+        dimensions:(Array with:dim1 with:dim2)
+! !
+
+!SequenceableCollection class methodsFor:'instance creation - multiDimensional'!
+
+_at:dim1 at:dim2 at:dim3
+    "this is a synthetic selector, generated by the compiler,
+     if a construct of the form expr[idx...] is parsed.
+     I.e. 
+        Array[n,m,o]
+     generates
+        Array _at:n at:m at:o
+    "
+
+    |data|
+
+    data := self withSize:(dim1 * dim2 * dim3).
+    ^ MultiDimensionalArrayAccessor 
+        collection:data
+        dimensions:(Array with:dim1 with:dim2 with:dim3)
+! !
+
 !Stream methodsFor:'stacked computing streams'!
 
 collecting:aBlock