Skip to content

Commit 9baa7ba

Browse files
We now use the new method and have reduced the scope of a temporary variable.
1 parent 5fb1e1b commit 9baa7ba

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/Math-Matrix/PMQRDecomposition.class.st

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,25 @@ https://en.wikipedia.org/wiki/QR_decomposition#Using_Householder_reflections
7171
{ #category : #arithmetic }
7272
PMQRDecomposition >> decomposeWithPivot [
7373

74-
| householderVector i v vectorOfNormSquareds rank mx pivot matrixOfMinor |
74+
| i v vectorOfNormSquareds rank mx pivot matrixOfMinor |
7575
vectorOfNormSquareds := matrixToDecompose columnsCollect: [
7676
:columnVector | columnVector * columnVector ].
7777
mx := vectorOfNormSquareds indexOf: vectorOfNormSquareds max.
7878
pivot := Array new: vectorOfNormSquareds size.
7979
rank := 0.
8080
[
81-
| householderMatrix columnVectorFromRMatrix identityMatrix |
81+
| householderReflection householderMatrix householderVector columnVectorFromRMatrix |
8282
rank := rank + 1.
8383
pivot at: rank put: mx.
8484
r swapColumn: rank withColumn: mx.
8585
vectorOfNormSquareds swap: rank with: mx.
8686
columnVectorFromRMatrix := r columnVectorAt: rank size: colSize.
87-
householderVector := columnVectorFromRMatrix householder.
88-
v := (PMVector zeros: rank - 1) , (householderVector at: 2).
89-
identityMatrix := PMSymmetricMatrix identity: colSize.
90-
householderMatrix := identityMatrix
91-
-
92-
((householderVector at: 1) * v tensorProduct: v).
87+
householderReflection := self
88+
householderReflectionOf:
89+
columnVectorFromRMatrix
90+
atColumnNumber: rank.
91+
householderVector := householderReflection at: 1.
92+
householderMatrix := householderReflection at: 2.
9393
q := q * householderMatrix.
9494
matrixOfMinor := r minor: rank - 1 and: rank - 1.
9595
matrixOfMinor := matrixOfMinor

0 commit comments

Comments
 (0)