From ceab081a37fac0b76eaa9aa0f4ae51f96a275545 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 19 Jun 2022 23:06:37 +0100 Subject: [PATCH 01/17] Clarified the concept being tested. --- src/Math-Tests-Matrix/PMQRTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 38822df5..0a2a618d 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -18,7 +18,7 @@ PMQRTest >> mpTestFunction: aMatrix [ ] { #category : #tests } -PMQRTest >> testMPInverse [ +PMQRTest >> testMoorePenroseInverse [ | a | a := PMMatrix new initializeRows: From df133b766649ca9f0faa022da025de8b5b71ce82 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 26 Jun 2022 21:52:14 +0100 Subject: [PATCH 02/17] Clarified the names of some local variables. --- src/Math-Tests-Matrix/PMQRTest.class.st | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 0a2a618d..28b9a3c9 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -7,13 +7,13 @@ Class { { #category : #running } PMQRTest >> mpTestFunction: aMatrix [ - | inv mult | - inv := aMatrix mpInverse. - mult := inv * aMatrix. - self assert: (aMatrix * mult closeTo: aMatrix). - self assert: mult * inv closeTo: inv. - self assert: mult transpose closeTo: mult. - mult := aMatrix * inv. + | inverse mult identityMatrix | + inverse := aMatrix mpInverse. + identityMatrix := inverse * aMatrix. + self assert: (aMatrix * identityMatrix closeTo: aMatrix). + self assert: identityMatrix * inverse closeTo: inverse. + self assert: identityMatrix transpose closeTo: identityMatrix. + mult := aMatrix * inverse. self assert: mult transpose closeTo: mult ] From c2cefc1ae4aee9e80c15c7a0e66e3eb9075a61c5 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 26 Jun 2022 21:54:10 +0100 Subject: [PATCH 03/17] Clarified the name of a local variable. --- src/Math-Tests-Matrix/PMQRTest.class.st | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 28b9a3c9..3eafa490 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -7,14 +7,14 @@ Class { { #category : #running } PMQRTest >> mpTestFunction: aMatrix [ - | inverse mult identityMatrix | + | inverse identityMatrix | inverse := aMatrix mpInverse. identityMatrix := inverse * aMatrix. self assert: (aMatrix * identityMatrix closeTo: aMatrix). self assert: identityMatrix * inverse closeTo: inverse. self assert: identityMatrix transpose closeTo: identityMatrix. - mult := aMatrix * inverse. - self assert: mult transpose closeTo: mult + identityMatrix := aMatrix * inverse. + self assert: identityMatrix transpose closeTo: identityMatrix ] { #category : #tests } From 205918f6341b675a609fbcaaffc09f5e969a8133 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 26 Jun 2022 21:58:26 +0100 Subject: [PATCH 04/17] Copied another assertion to the custom assertion method. --- src/Math-Tests-Matrix/PMQRTest.class.st | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 3eafa490..f40396e1 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -5,10 +5,9 @@ Class { } { #category : #running } -PMQRTest >> mpTestFunction: aMatrix [ +PMQRTest >> assert: inverse isInverseOf: aMatrix [ - | inverse identityMatrix | - inverse := aMatrix mpInverse. + | identityMatrix | identityMatrix := inverse * aMatrix. self assert: (aMatrix * identityMatrix closeTo: aMatrix). self assert: identityMatrix * inverse closeTo: inverse. @@ -17,6 +16,15 @@ PMQRTest >> mpTestFunction: aMatrix [ self assert: identityMatrix transpose closeTo: identityMatrix ] +{ #category : #running } +PMQRTest >> mpTestFunction: aMatrix [ + + | inverse | + inverse := aMatrix mpInverse. + self assert: inverse isInverseOf: aMatrix. + +] + { #category : #tests } PMQRTest >> testMoorePenroseInverse [ From b67cdf9dc0b99b589a2af0ee3a1f221347edc1ea Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 26 Jun 2022 22:04:10 +0100 Subject: [PATCH 05/17] Added an additional assertion --- src/Math-Tests-Matrix/PMQRTest.class.st | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index f40396e1..d31d8bed 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -6,6 +6,7 @@ Class { { #category : #running } PMQRTest >> assert: inverse isInverseOf: aMatrix [ + "A~ * A = A * A~ = I" | identityMatrix | identityMatrix := inverse * aMatrix. @@ -13,7 +14,8 @@ PMQRTest >> assert: inverse isInverseOf: aMatrix [ self assert: identityMatrix * inverse closeTo: inverse. self assert: identityMatrix transpose closeTo: identityMatrix. identityMatrix := aMatrix * inverse. - self assert: identityMatrix transpose closeTo: identityMatrix + self assert: identityMatrix transpose closeTo: identityMatrix. + self assert: (identityMatrix * aMatrix) closeTo: aMatrix. ] { #category : #running } From d5d36d0c140a0a23ad2d30778871cbafd764919b Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 26 Jun 2022 22:21:33 +0100 Subject: [PATCH 06/17] Clarified the assertion a little more by making the code follow the definition in the wiki more closely. --- src/Math-Tests-Matrix/PMQRTest.class.st | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index d31d8bed..84f46cad 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -5,14 +5,20 @@ Class { } { #category : #running } -PMQRTest >> assert: inverse isInverseOf: aMatrix [ - "A~ * A = A * A~ = I" +PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ + "https://en.wikipedia.org/wiki/Moore–Penrose_inverse#Definition" | identityMatrix | - identityMatrix := inverse * aMatrix. - self assert: (aMatrix * identityMatrix closeTo: aMatrix). - self assert: identityMatrix * inverse closeTo: inverse. - self assert: identityMatrix transpose closeTo: identityMatrix. + "These two assertions are what define a pseudoinverse. They are known as + the Moore–Penrose conditions of which there are four, but here we have two. The other two + are that (A * A+) and A+ * A are Hermitian. + " + self assert: (aMatrix * inverse * aMatrix closeTo: aMatrix). + self assert: inverse * aMatrix * inverse closeTo: inverse. + + "Pseudoinversion commutes with transposition, complex conjugation, and taking the conjugate transpose" + self assert: aMatrix transpose mpInverse closeTo: aMatrix mpInverse transpose. + identityMatrix := aMatrix * inverse. self assert: identityMatrix transpose closeTo: identityMatrix. self assert: (identityMatrix * aMatrix) closeTo: aMatrix. @@ -23,7 +29,7 @@ PMQRTest >> mpTestFunction: aMatrix [ | inverse | inverse := aMatrix mpInverse. - self assert: inverse isInverseOf: aMatrix. + self assert: inverse isMoorePenroseInverseOf: aMatrix. ] From 69f477789dcb25b3660c8f32022e169c47f59ceb Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Sun, 26 Jun 2022 22:32:07 +0100 Subject: [PATCH 07/17] Inlined the method as it was not very useful. --- src/Math-Tests-Matrix/PMQRTest.class.st | 27 ++++++++++++------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 84f46cad..cca0848a 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -24,29 +24,28 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ self assert: (identityMatrix * aMatrix) closeTo: aMatrix. ] -{ #category : #running } -PMQRTest >> mpTestFunction: aMatrix [ - - | inverse | - inverse := aMatrix mpInverse. - self assert: inverse isMoorePenroseInverseOf: aMatrix. - -] - { #category : #tests } PMQRTest >> testMoorePenroseInverse [ - | a | + | a inverse | a := PMMatrix new initializeRows: #( #( 5 40 1 ) #( 0 0 1 ) #( 0 0 1 ) ). - self mpTestFunction: a. + inverse := a mpInverse . + self assert: inverse isMoorePenroseInverseOf: a. + a := a * (PMMatrix rows: 3 columns: 3 random: 5.0). - self mpTestFunction: a. + inverse := a mpInverse . + self assert: inverse isMoorePenroseInverseOf: a. + a := PMMatrix new initializeRows: #( #( 5 40 1 2.5 ) #( 0 0 1 2.5 ) #( 0 0 1 2.5 ) ). - self mpTestFunction: a. + inverse := a mpInverse . + self assert: inverse isMoorePenroseInverseOf: a. + a := a transpose. - self mpTestFunction: a. + inverse := a mpInverse . + self assert: inverse isMoorePenroseInverseOf: a. + 3 timesRepeat: [ a := PMMatrix rows: 3 columns: 3 random: 1.0. self assert: (a mpInverse closeTo: a inverse). From 2cc404e2f240b9ef860cc7f77d76817d655e37c8 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 09:38:12 +0100 Subject: [PATCH 08/17] Perhaps we can split the test up and we can discover where the erratic failure happens more precisely. --- src/Math-Tests-Matrix/PMQRTest.class.st | 28 ++++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index cca0848a..878afc76 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -28,14 +28,6 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ PMQRTest >> testMoorePenroseInverse [ | a inverse | - a := PMMatrix new initializeRows: - #( #( 5 40 1 ) #( 0 0 1 ) #( 0 0 1 ) ). - inverse := a mpInverse . - self assert: inverse isMoorePenroseInverseOf: a. - - a := a * (PMMatrix rows: 3 columns: 3 random: 5.0). - inverse := a mpInverse . - self assert: inverse isMoorePenroseInverseOf: a. a := PMMatrix new initializeRows: #( #( 5 40 1 2.5 ) #( 0 0 1 2.5 ) #( 0 0 1 2.5 ) ). @@ -53,6 +45,26 @@ PMQRTest >> testMoorePenroseInverse [ self assert: (a mpInverse closeTo: a inverse) ] ] +{ #category : #tests } +PMQRTest >> testMoorePenroseInverseOfNonRandomMatrix [ + | a inverse | + a := PMMatrix new initializeRows: + #( #( 5 40 1 ) #( 0 0 1 ) #( 0 0 1 ) ). + inverse := a mpInverse . + self assert: inverse isMoorePenroseInverseOf: a. +] + +{ #category : #tests } +PMQRTest >> testMoorePenroseInverseOfProductOfMatrices [ + | a inverse | + a := PMMatrix new initializeRows: + #( #( 5 40 1 ) #( 0 0 1 ) #( 0 0 1 ) ). + + a := a * (PMMatrix rows: 3 columns: 3 random: 5.0). + inverse := a mpInverse . + self assert: inverse isMoorePenroseInverseOf: a. +] + { #category : #tests } PMQRTest >> testOrthogonalize [ From e825deb400268baf049fabdde1c63598165f589f Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 09:45:54 +0100 Subject: [PATCH 09/17] Continued the break up of a large test into smaller and clearly named ones to aid debugging of the errratic test. --- src/Math-Tests-Matrix/PMQRTest.class.st | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 878afc76..7e8afccc 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -25,10 +25,8 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ ] { #category : #tests } -PMQRTest >> testMoorePenroseInverse [ - +PMQRTest >> testMoorePenroseInverseOfLargeNonRandomMatrix [ | a inverse | - a := PMMatrix new initializeRows: #( #( 5 40 1 2.5 ) #( 0 0 1 2.5 ) #( 0 0 1 2.5 ) ). inverse := a mpInverse . @@ -37,12 +35,6 @@ PMQRTest >> testMoorePenroseInverse [ a := a transpose. inverse := a mpInverse . self assert: inverse isMoorePenroseInverseOf: a. - - 3 timesRepeat: [ - a := PMMatrix rows: 3 columns: 3 random: 1.0. - self assert: (a mpInverse closeTo: a inverse). - a := PMSymmetricMatrix new: 4 random: 1.0. - self assert: (a mpInverse closeTo: a inverse) ] ] { #category : #tests } @@ -65,6 +57,17 @@ PMQRTest >> testMoorePenroseInverseOfProductOfMatrices [ self assert: inverse isMoorePenroseInverseOf: a. ] +{ #category : #tests } +PMQRTest >> testMoorePenroseInverseRepeatedly [ + + | a | + 3 timesRepeat: [ + a := PMMatrix rows: 3 columns: 3 random: 1.0. + self assert: (a mpInverse closeTo: a inverse). + a := PMSymmetricMatrix new: 4 random: 1.0. + self assert: (a mpInverse closeTo: a inverse) ] +] + { #category : #tests } PMQRTest >> testOrthogonalize [ From c287f903620a702c6952b217ad31ff417caaf05f Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 09:56:21 +0100 Subject: [PATCH 10/17] Improved the name of the test and of a local variable. --- src/Math-Tests-Matrix/PMQRTest.class.st | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 7e8afccc..b8d1c0a0 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -25,16 +25,16 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ ] { #category : #tests } -PMQRTest >> testMoorePenroseInverseOfLargeNonRandomMatrix [ - | a inverse | +PMQRTest >> testMoorePenroseInverseOfLargeNonRandomMatrixAndItsTranspose [ + | a inverse transposeOfA | a := PMMatrix new initializeRows: #( #( 5 40 1 2.5 ) #( 0 0 1 2.5 ) #( 0 0 1 2.5 ) ). inverse := a mpInverse . self assert: inverse isMoorePenroseInverseOf: a. - a := a transpose. - inverse := a mpInverse . - self assert: inverse isMoorePenroseInverseOf: a. + transposeOfA := a transpose. + inverse := transposeOfA mpInverse . + self assert: inverse isMoorePenroseInverseOf: transposeOfA. ] { #category : #tests } From 4fd471a37f4cc84367d3eee7f578d90482672036 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 17:55:31 +0100 Subject: [PATCH 11/17] Simplifed what appears to be a data-driven test. --- src/Math-Tests-Matrix/PMQRTest.class.st | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index b8d1c0a0..e15240f6 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -58,14 +58,11 @@ PMQRTest >> testMoorePenroseInverseOfProductOfMatrices [ ] { #category : #tests } -PMQRTest >> testMoorePenroseInverseRepeatedly [ +PMQRTest >> testMoorePenroseInverseOfRandomMatrix [ | a | - 3 timesRepeat: [ - a := PMMatrix rows: 3 columns: 3 random: 1.0. - self assert: (a mpInverse closeTo: a inverse). - a := PMSymmetricMatrix new: 4 random: 1.0. - self assert: (a mpInverse closeTo: a inverse) ] + a := PMSymmetricMatrix new: 4 random: 1.0. + self assert: (a mpInverse closeTo: a inverse) ] { #category : #tests } From 3b949d309d37915f273162931521ca08425ab41b Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 18:04:28 +0100 Subject: [PATCH 12/17] Improved code formatting. --- src/Math-Tests-Matrix/PMQRTest.class.st | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index e15240f6..c41a81a3 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -6,6 +6,7 @@ Class { { #category : #running } PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ + "https://en.wikipedia.org/wiki/Moore–Penrose_inverse#Definition" | identityMatrix | @@ -15,13 +16,15 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ " self assert: (aMatrix * inverse * aMatrix closeTo: aMatrix). self assert: inverse * aMatrix * inverse closeTo: inverse. - + "Pseudoinversion commutes with transposition, complex conjugation, and taking the conjugate transpose" - self assert: aMatrix transpose mpInverse closeTo: aMatrix mpInverse transpose. - + self + assert: aMatrix transpose mpInverse + closeTo: aMatrix mpInverse transpose. + identityMatrix := aMatrix * inverse. self assert: identityMatrix transpose closeTo: identityMatrix. - self assert: (identityMatrix * aMatrix) closeTo: aMatrix. + self assert: identityMatrix * aMatrix closeTo: aMatrix ] { #category : #tests } From 9d77e63de364c2934e2c95b187c9bd454ad028c2 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 18:15:41 +0100 Subject: [PATCH 13/17] Clarified the name of a test. --- src/Math-Tests-Matrix/PMQRTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index c41a81a3..139a5917 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -61,7 +61,7 @@ PMQRTest >> testMoorePenroseInverseOfProductOfMatrices [ ] { #category : #tests } -PMQRTest >> testMoorePenroseInverseOfRandomMatrix [ +PMQRTest >> testMoorePenroseInverseOfRandomMatrixIsAPseudoInverse [ | a | a := PMSymmetricMatrix new: 4 random: 1.0. From 15fdee1da3e597ba438e766ec52fee2754f719e4 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 18:27:41 +0100 Subject: [PATCH 14/17] Added a comment that explains what the test may be demonstrating. --- src/Math-Tests-Matrix/PMQRTest.class.st | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 139a5917..a6a62c30 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -61,7 +61,12 @@ PMQRTest >> testMoorePenroseInverseOfProductOfMatrices [ ] { #category : #tests } -PMQRTest >> testMoorePenroseInverseOfRandomMatrixIsAPseudoInverse [ +PMQRTest >> testMoorePenroseInverseOfRandomMatrixIsAnInverse [ +" +Proofs for the properties below can be found in literature: +If A has real entries, then so does A+ +If A is invertible, its pseudoinverse is its inverse. That is, A+=A**−1 +" | a | a := PMSymmetricMatrix new: 4 random: 1.0. From 007b67e0811109ba7a96f87cfc0a89415db3f4a1 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 18:28:16 +0100 Subject: [PATCH 15/17] Improved relation formatting. --- src/Math-Tests-Matrix/PMQRTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index a6a62c30..1a762431 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -65,7 +65,7 @@ PMQRTest >> testMoorePenroseInverseOfRandomMatrixIsAnInverse [ " Proofs for the properties below can be found in literature: If A has real entries, then so does A+ -If A is invertible, its pseudoinverse is its inverse. That is, A+=A**−1 +If A is invertible, its pseudoinverse is its inverse. That is, A+ = A**−1 " | a | From 00708b1fe055885058c38e4a1a099156886cfdf9 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 21:30:16 +0100 Subject: [PATCH 16/17] Made the assertion consistent with the one below it. --- src/Math-Tests-Matrix/PMQRTest.class.st | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index 1a762431..a3578640 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -14,7 +14,7 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ the Moore–Penrose conditions of which there are four, but here we have two. The other two are that (A * A+) and A+ * A are Hermitian. " - self assert: (aMatrix * inverse * aMatrix closeTo: aMatrix). + self assert: aMatrix * inverse * aMatrix closeTo: aMatrix. self assert: inverse * aMatrix * inverse closeTo: inverse. "Pseudoinversion commutes with transposition, complex conjugation, and taking the conjugate transpose" From 8cdda2d607dc5f8a8661ec72fec1e4d7ca7636c7 Mon Sep 17 00:00:00 2001 From: hemalvarambhia Date: Wed, 29 Jun 2022 21:32:16 +0100 Subject: [PATCH 17/17] Brought related assertions closer together. --- src/Math-Tests-Matrix/PMQRTest.class.st | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Math-Tests-Matrix/PMQRTest.class.st b/src/Math-Tests-Matrix/PMQRTest.class.st index a3578640..1b328b9b 100644 --- a/src/Math-Tests-Matrix/PMQRTest.class.st +++ b/src/Math-Tests-Matrix/PMQRTest.class.st @@ -16,15 +16,15 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [ " self assert: aMatrix * inverse * aMatrix closeTo: aMatrix. self assert: inverse * aMatrix * inverse closeTo: inverse. + + identityMatrix := aMatrix * inverse. + self assert: identityMatrix transpose closeTo: identityMatrix. + self assert: identityMatrix * aMatrix closeTo: aMatrix. "Pseudoinversion commutes with transposition, complex conjugation, and taking the conjugate transpose" self assert: aMatrix transpose mpInverse closeTo: aMatrix mpInverse transpose. - - identityMatrix := aMatrix * inverse. - self assert: identityMatrix transpose closeTo: identityMatrix. - self assert: identityMatrix * aMatrix closeTo: aMatrix ] { #category : #tests }