Skip to content

Commit fc02c3f

Browse files
committed
Split a large test case with many assertions and moved part of it to Math-Numerical
1 parent b88eee1 commit fc02c3f

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed

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

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,30 @@ PMMatrixTest >> testIdentityMatrix [
215215
self assert: identityMatrix equals: expectedIdentityMatrix.
216216
]
217217

218+
{ #category : #'linear algebra' }
219+
PMMatrixTest >> testInversePureCRLSingularMatrixError [
220+
221+
self
222+
should: [ (PMSymmetricMatrix rows: #((1 2 3)(2 2 2)(3 2 1))) inversePureCRL ]
223+
raise: PMSingularMatrixError.
224+
]
225+
226+
{ #category : #'linear algebra' }
227+
PMMatrixTest >> testInversePureLUPSingularMatrixError [
228+
229+
self
230+
should: [ (PMSymmetricMatrix rows: #((1 2 3)(2 2 2)(3 2 1))) inversePureLUP ]
231+
raise: PMSingularMatrixError.
232+
]
233+
234+
{ #category : #'linear algebra' }
235+
PMMatrixTest >> testInverseSingularMatrixError [
236+
237+
self
238+
should: [ (PMMatrix rows: #((1 2 3)(3 4 6))) inverse ]
239+
raise: PMSingularMatrixError.
240+
]
241+
218242
{ #category : #tests }
219243
PMMatrixTest >> testIsRealOnComplexMatrix [
220244
| matrix |
@@ -757,22 +781,6 @@ PMMatrixTest >> testSimpleMatrixOperations [
757781
self assert: m transpose * m equals: m squared
758782
]
759783

760-
{ #category : #'linear algebra' }
761-
PMMatrixTest >> testSingularMatrixError [
762-
|h f|
763-
h:=PMHistogram new.
764-
h freeExtent: true.
765-
1 to: 3 do: [:i| h accumulate: i ].
766-
f:=PMLeastSquareFit histogram: h distributionClass: PMTriangularDistribution.
767-
self should: [ f evaluate ] raise: PMSingularMatrixError .
768-
"and not something completely incomprehensible"
769-
"also here:"
770-
self should: [ f errorMatrix ] raise: PMSingularMatrixError .
771-
self should: [(PMMatrix rows: #((1 2 3)(3 4 6)))inverse] raise: PMSingularMatrixError .
772-
self should: [(PMSymmetricMatrix rows: #((1 2 3)(2 2 2)(3 2 1)))inversePureLUP] raise: PMSingularMatrixError.
773-
self should: [(PMSymmetricMatrix rows: #((1 2 3)(2 2 2)(3 2 1)))inversePureCRL] raise: PMSingularMatrixError.
774-
]
775-
776784
{ #category : #tests }
777785
PMMatrixTest >> testSkalarMultiplication [
778786
| a r |

src/Math-Tests-Numerical/PMNumericalMethodsTestCase.class.st

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,24 @@ PMNumericalMethodsTestCase >> testLeastSquarePolynomial [
391391
< (estimation error: 7.15)
392392
]
393393

394+
{ #category : #'iterative algorithms' }
395+
PMNumericalMethodsTestCase >> testLeastSquaresSingularMatrixError [
396+
| histogram leastSquares |
397+
398+
histogram := PMHistogram new
399+
freeExtent: true;
400+
yourself.
401+
402+
1 to: 3 do: [:i| histogram accumulate: i ].
403+
404+
leastSquares := PMLeastSquareFit
405+
histogram: histogram
406+
distributionClass: PMTriangularDistribution.
407+
408+
self should: [ leastSquares evaluate ] raise: PMSingularMatrixError.
409+
self should: [ leastSquares errorMatrix ] raise: PMSingularMatrixError .
410+
]
411+
394412
{ #category : #'iterative algorithms' }
395413
PMNumericalMethodsTestCase >> testLineSearch1 [
396414
"Test line searh for an initial step of Newton solver for equation
@@ -852,22 +870,6 @@ PMNumericalMethodsTestCase >> testOptimizeSimplex [
852870
self assert: (result at: 3) abs < 1.0e-6
853871
]
854872

855-
{ #category : #'linear algebra' }
856-
PMNumericalMethodsTestCase >> testSingularMatrixError [
857-
|h f|
858-
h:=PMHistogram new.
859-
h freeExtent: true.
860-
1 to: 3 do: [:i| h accumulate: i ].
861-
f:=PMLeastSquareFit histogram: h distributionClass: PMTriangularDistribution.
862-
self should: [ f evaluate ] raise: PMSingularMatrixError .
863-
"and not something completely incomprehensible"
864-
"also here:"
865-
self should: [ f errorMatrix ] raise: PMSingularMatrixError .
866-
self should: [(PMMatrix rows: #((1 2 3)(3 4 6)))inverse] raise: PMSingularMatrixError .
867-
self should: [(PMSymmetricMatrix rows: #((1 2 3)(2 2 2)(3 2 1)))inversePureLUP] raise: PMSingularMatrixError.
868-
self should: [(PMSymmetricMatrix rows: #((1 2 3)(2 2 2)(3 2 1)))inversePureCRL] raise: PMSingularMatrixError.
869-
]
870-
871873
{ #category : #statistics }
872874
PMNumericalMethodsTestCase >> testStatisticalMoments [
873875
"comment"

0 commit comments

Comments
 (0)