Skip to content

Commit 4762f4c

Browse files
authored
Merge pull request #16 from DurieuxPol/fix/qr
Fix PMQRTest>>testDecompositionOfMatrixCausingErraticFailure
2 parents 01ac13f + 7009ff2 commit 4762f4c

2 files changed

Lines changed: 21 additions & 3 deletions

File tree

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [
3131
{ #category : 'tests' }
3232
PMQRTest >> testDecompositionOfMatrixCausingErraticFailure [
3333

34-
<expectedFailure>
3534
| a qrDecomposition matricesAndPivot q r expectedMatrix pivot |
3635
a := PMSymmetricMatrix rows:
3736
#( #( 0.41929313699681925 0.05975350554089691

src/Math-Matrix/PMQRDecomposition.class.st

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Class {
88
'matrixToDecompose',
99
'colSize',
1010
'r',
11-
'q'
11+
'q',
12+
'comparisonPrecision'
1213
],
1314
#category : 'Math-Matrix',
1415
#package : 'Math-Matrix'
@@ -21,6 +22,18 @@ PMQRDecomposition class >> of: matrix [
2122
^ self new of: matrix
2223
]
2324

25+
{ #category : 'constants' }
26+
PMQRDecomposition >> comparisonPrecision [
27+
28+
^ comparisonPrecision ifNil: [ self defaultComparisonPrecision ]
29+
]
30+
31+
{ #category : 'accessing' }
32+
PMQRDecomposition >> comparisonPrecision: anObject [
33+
34+
comparisonPrecision := anObject
35+
]
36+
2437
{ #category : 'arithmetic' }
2538
PMQRDecomposition >> decompose [
2639
"
@@ -108,7 +121,7 @@ PMQRDecomposition >> decomposeWithPivot [
108121
positionOfMaximum := (vectorOfNormSquareds
109122
copyFrom: rank + 1
110123
to: vectorOfNormSquareds size) max.
111-
(positionOfMaximum closeTo: 0) ifTrue: [ positionOfMaximum := 0 ].
124+
(positionOfMaximum closeTo: 0 precision: self comparisonPrecision) ifTrue: [ positionOfMaximum := 0 ].
112125
positionOfMaximum := positionOfMaximum > 0
113126
ifTrue: [
114127
vectorOfNormSquareds indexOf: positionOfMaximum startingAt: rank + 1 ]
@@ -128,6 +141,12 @@ PMQRDecomposition >> decomposeWithPivot [
128141
^ Array with: q with: r with: pivot
129142
]
130143

144+
{ #category : 'constants' }
145+
PMQRDecomposition >> defaultComparisonPrecision [
146+
147+
^ 0.0001
148+
]
149+
131150
{ #category : 'private' }
132151
PMQRDecomposition >> householderReflectionOf: columnVector atColumnNumber: columnNumber [
133152

0 commit comments

Comments
 (0)