Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Math-Matrix-Tests/PMQRTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ PMQRTest >> assert: inverse isMoorePenroseInverseOf: aMatrix [
{ #category : 'tests' }
PMQRTest >> testDecompositionOfMatrixCausingErraticFailure [

<expectedFailure>
| a qrDecomposition matricesAndPivot q r expectedMatrix pivot |
a := PMSymmetricMatrix rows:
#( #( 0.41929313699681925 0.05975350554089691
Expand Down
23 changes: 21 additions & 2 deletions src/Math-Matrix/PMQRDecomposition.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ Class {
'matrixToDecompose',
'colSize',
'r',
'q'
'q',
'comparisonPrecision'
],
#category : 'Math-Matrix',
#package : 'Math-Matrix'
Expand All @@ -21,6 +22,18 @@ PMQRDecomposition class >> of: matrix [
^ self new of: matrix
]

{ #category : 'constants' }
PMQRDecomposition >> comparisonPrecision [

^ comparisonPrecision ifNil: [ self defaultComparisonPrecision ]
]

{ #category : 'accessing' }
PMQRDecomposition >> comparisonPrecision: anObject [

comparisonPrecision := anObject
]

{ #category : 'arithmetic' }
PMQRDecomposition >> decompose [
"
Expand Down Expand Up @@ -108,7 +121,7 @@ PMQRDecomposition >> decomposeWithPivot [
positionOfMaximum := (vectorOfNormSquareds
copyFrom: rank + 1
to: vectorOfNormSquareds size) max.
(positionOfMaximum closeTo: 0) ifTrue: [ positionOfMaximum := 0 ].
(positionOfMaximum closeTo: 0 precision: self comparisonPrecision) ifTrue: [ positionOfMaximum := 0 ].
positionOfMaximum := positionOfMaximum > 0
ifTrue: [
vectorOfNormSquareds indexOf: positionOfMaximum startingAt: rank + 1 ]
Expand All @@ -128,6 +141,12 @@ PMQRDecomposition >> decomposeWithPivot [
^ Array with: q with: r with: pivot
]

{ #category : 'constants' }
PMQRDecomposition >> defaultComparisonPrecision [

^ 0.0001
]

{ #category : 'private' }
PMQRDecomposition >> householderReflectionOf: columnVector atColumnNumber: columnNumber [

Expand Down
Loading