@@ -42,6 +42,18 @@ PMTensorTest >> testFirst [
4242 self assert: b first equals: #( 1 1 )
4343]
4444
45+ { #category : #tests }
46+ PMTensorTest >> testFlattenedIndexOf [
47+
48+ | t1 t2 |
49+ t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
50+ self assert: (t1 flattenedIndexOf: #( 1 2 ) ) equals: 2 .
51+
52+ t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
53+ #( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
54+ self assert: (t2 flattenedIndexOf: #( 1 2 2 ) ) equals: 4
55+ ]
56+
4557{ #category : #tests }
4658PMTensorTest >> testFromNestedArray [
4759
@@ -72,18 +84,6 @@ PMTensorTest >> testGet [
7284 self should: [t1 get: #( 4 4 ) ] raise: Error
7385]
7486
75- { #category : #tests }
76- PMTensorTest >> testGetPosition [
77-
78- | t1 t2 |
79- t1 := PMTensor fromNestedArray: #( #( 1 2 3 4 ) #( 5 6 7 8 ) ).
80- self assert: (t1 getPosition: #( 1 2 ) ) equals: 2 .
81-
82- t2 := PMTensor fromNestedArray: #( #( #( 1 2 ) #( 3 4 ) ) #( #( 5 6 ) #( 7 8 ) )
83- #( #( 9 10 ) #( 11 12 ) ) #( #( 13 14 ) #( 15 16 ) ) ).
84- self assert: (t2 getPosition: #( 1 2 2 ) ) equals: 4
85- ]
86-
8787{ #category : #tests }
8888PMTensorTest >> testRank [
8989
@@ -162,13 +162,13 @@ PMTensorTest >> testStrides [
162162 self assert: b strides equals: #( 6 1 ) .
163163 b := a reshape: #( 6 4 ) .
164164 self assert: b strides equals: #( 4 1 ) .
165- self assert: (b getPosition : #( 4 2 ) ) equals: 14 .
165+ self assert: (b flattenedIndexOf : #( 4 2 ) ) equals: 14 .
166166 b := a reshape: #( 3 4 2 ) .
167167 self assert: b strides equals: #( 8 2 1 ) .
168- self assert: (b getPosition : #( 3 2 1) ) equals: 19 .
168+ self assert: (b flattenedIndexOf : #( 3 2 1) ) equals: 19 .
169169 b := a reshape: #( 2 3 4 ) .
170170 self assert: b strides equals: #( 12 4 1 ) .
171- self assert: (b getPosition : #( 2 2 3 ) ) equals: 19
171+ self assert: (b flattenedIndexOf : #( 2 2 3 ) ) equals: 19
172172]
173173
174174{ #category : #tests }
0 commit comments