Skip to content

Commit b1b923d

Browse files
committed
Class methods for the tensor of rank greater than 2
1 parent 3df00c5 commit b1b923d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/Math-Matrix/PMTensor.class.st

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,28 @@ Class {
1010
#category : #'Math-Matrix'
1111
}
1212

13+
{ #category : #'instance creation' }
14+
PMTensor class >> newWith: anInteger [
15+
16+
^ self new array: {anInteger} withShape: #( )
17+
]
18+
19+
{ #category : #'instance creation' }
20+
PMTensor class >> rows: anArray [
21+
22+
^ self new array: anArray flattened withShape: (self shape:anArray)
23+
]
24+
25+
{ #category : #accessing }
26+
PMTensor class >> shape: anArray [
27+
28+
anArray isArray ifFalse:[^#()]
29+
ifTrue:[
30+
^ {anArray size}, (self shape: anArray first)
31+
]
32+
33+
]
34+
1335
{ #category : #comparing }
1436
PMTensor >> = aTensor [
1537

0 commit comments

Comments
 (0)