Skip to content

Commit a6d0892

Browse files
Merge f862644
2 parents 9615029 + f862644 commit a6d0892

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

src/Math-Matrix/PMMatrix.class.st

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ a tr.
6767
"15"
6868
]
6969

70+
{ #category : #'instance creation' }
71+
PMMatrix class >> identity: dimension [
72+
^ PMSymmetricMatrix identity: dimension
73+
]
74+
7075
{ #category : #'instance creation' }
7176
PMMatrix class >> join: anArrayOfMatrices [
7277
"Inverse of the split operation."

src/Math-Tests-Matrix/PMMatrixTest.class.st

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,20 @@ PMMatrixTest >> testFlattenRows [
197197
self assert: m flattenRows equals: #(1 2 3 4 5 6 7 8 9) asPMVector
198198
]
199199

200+
{ #category : #tests }
201+
PMMatrixTest >> testIdentityMatrix [
202+
|expectedIdentityMatrix identityMatrix|
203+
204+
expectedIdentityMatrix := PMMatrix zerosRows: 3 cols: 3.
205+
206+
expectedIdentityMatrix at: 1 at: 1 put: 1.
207+
expectedIdentityMatrix at: 2 at: 2 put: 1.
208+
expectedIdentityMatrix at: 3 at: 3 put: 1.
209+
210+
identityMatrix := PMMatrix identity: 3.
211+
self assert: identityMatrix equals: expectedIdentityMatrix.
212+
]
213+
200214
{ #category : #tests }
201215
PMMatrixTest >> testIsRealOnComplexMatrix [
202216
| matrix |

src/Math-Tests-Matrix/PMSymmetricMatrixTest.class.st

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Class {
22
#name : #PMSymmetricMatrixTest,
33
#superclass : #TestCase,
4-
#category : 'Math-Tests-Matrix'
4+
#category : #'Math-Tests-Matrix'
55
}
66

77
{ #category : #tests }
@@ -38,6 +38,16 @@ PMSymmetricMatrixTest >> testEqual [
3838
self assert: b ~= a
3939
]
4040

41+
{ #category : #tests }
42+
PMSymmetricMatrixTest >> testIdentityMatrix [
43+
|expectedIdentityMatrix identityMatrix|
44+
45+
identityMatrix := PMSymmetricMatrix identity: 3.
46+
expectedIdentityMatrix := PMSymmetricMatrix rows: #(#(1 0 0) #(0 1 0) #(0 0 1)).
47+
48+
self assert: identityMatrix equals: expectedIdentityMatrix.
49+
]
50+
4151
{ #category : #tests }
4252
PMSymmetricMatrixTest >> testInversePureLUP [
4353
| m i |

0 commit comments

Comments
 (0)