Skip to content

Commit c3a6eee

Browse files
committed
Added class comment
1 parent 40811e8 commit c3a6eee

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

src/Math-Numerical/PMLeastSquares.class.st

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
1+
"
2+
SVD-based implementation of a minimum-norm solution to the overdetermined least squares problem.
3+
"
14
Class {
25
#name : #PMLeastSquares,
36
#superclass : #Object,
47
#category : #'Math-Numerical'
58
}
69

7-
{ #category : #'as yet unclassified' }
10+
{ #category : #accessing }
811
PMLeastSquares >> pseudoinverseOfDiagonal: aMatrix [
9-
"To get pseudoinverse of a diagonal rectangular matrix, we take reciprocal of any no-zero element of the main diagonal, leaving all zeros in place. Then we transpose the matrix."
10-
12+
13+
"To get pseudoinverse of a diagonal rectangular matrix, we take reciprocal of any no-zero
14+
element of the main diagonal, leaving all zeros in place. Then we transpose the matrix."
15+
1116
| pseudoinverse diagonalSize |
12-
1317
"Rows become columns and columns become rows because we transpose"
14-
pseudoinverse := PMMatrix
15-
zerosRows: aMatrix numberOfColumns
16-
cols: aMatrix numberOfRows.
17-
18+
pseudoinverse := PMMatrix zerosRows: aMatrix numberOfColumns cols: aMatrix numberOfRows.
19+
1820
"The size of the main diagonal of a rectangular matrix is its smallest dimension"
1921
diagonalSize := aMatrix numberOfRows min: aMatrix numberOfColumns.
20-
22+
2123
"Inverting the elements on the main diaginal"
22-
1 to: diagonalSize do: [ :i |
23-
pseudoinverse at: i at: i put: ((aMatrix at: i at: i) = 0
24-
ifTrue: [ 0 ] ifFalse: [ 1 / (aMatrix at: i at: i) ]) ].
25-
24+
1 to: diagonalSize do: [ :i |
25+
pseudoinverse at: i at: i put: ((aMatrix at: i at: i) = 0 ifTrue: [ 0 ]
26+
ifFalse: [ 1 / (aMatrix at: i at: i) ]) ].
27+
2628
^ pseudoinverse
2729
]
2830

29-
{ #category : #'as yet unclassified' }
31+
{ #category : #api }
3032
PMLeastSquares >> solveMatrixA: aMatrix matrixB: aMatrixOrVector [
3133

32-
"SVD-based implementation of a minimum-norm solution to the overdetermined least squares problem.
33-
34-
If b is a vector:
34+
"If b is a vector:
3535
x' = minimize || b - Ax ||
3636
3737
If B is a matrix:

0 commit comments

Comments
 (0)