PseudoInverse Class Reference
handles (weighted) pseudo-inverses and related operations.
More...
#include <pinv.hpp>
List of all members.
Public Member Functions |
double | derivsv (const double *Adot, int strideAdot, int svnr) |
void | inverse (const double *y, double *x, double eps) |
void | inverseWithNullSpace (const double *y, double *x, const double *xd, double eps) |
int | prepare (const double *_A, int _strideA, int _m, int _n, const double *_Ly, const double *_Lx, int nrOfIts) |
| prepares for solving Ax=y by calculating the singular value decomposition.
|
| PseudoInverse (int _maxsize) |
int | smallestSV (double eps) |
| Smallest eigenvalue larger then eps.
|
| ~PseudoInverse () |
Public Attributes |
const double * | A |
const double * | Lx |
const double * | Ly |
int | m |
int | n |
int * | ndx |
bool | prepared |
| the prepare method() has been called
|
double * | S |
int | strideA |
int | strideU |
| the stride for U.
|
int | strideV |
| the stride for V
|
double * | U |
| left orthonormal matrix when prepare() is called, U contains the left orthonormal matrix of the singular value decomposition.
|
double * | V |
| right orthonormal matrix when prepare is called, V contains the right orthonormal matrix of the singular value decomposition.
|
Private Attributes |
int | maxsize |
double * | tmp |
double * | y2 |
Detailed Description
handles (weighted) pseudo-inverses and related operations.
Definition at line 49 of file pinv.hpp.
Constructor & Destructor Documentation
PseudoInverse::PseudoInverse |
( |
int |
_maxsize |
) |
|
Allocate temporary space for calculating the pseudo-inverse of a matrix with maxrows rows or less , and maxcols collumns or less. maxrows > maxcols, because if nrofrows < nrofcols, extra rows have to be added to the matrix.
Definition at line 304 of file pinv.cpp.
PseudoInverse::~PseudoInverse |
( |
|
) |
|
Member Function Documentation
double PseudoInverse::derivsv |
( |
const double * |
Adot, |
|
|
int |
strideAdot, |
|
|
int |
svnr | |
|
) |
| | |
function to calculate :
- Parameters:
-
[in] | Adot | the derivative (towards some variable) of the A matrix |
[in] | strideAdot | |
[in] | svnr | indicates for which singular value the derivative is taken. |
- Warning:
- prepare() should have been called
Definition at line 460 of file pinv.cpp.
void PseudoInverse::inverse |
( |
const double * |
y, |
|
|
double * |
x, |
|
|
double |
eps | |
|
) |
| | |
- solves an equation with the weighted pseudo-inverse
- given : A.x = y
- Calculates x = A# y for the prepared matrix and weights.
- Warning:
- first call prepare()
- Parameters:
-
[in] | y | right hand side of the equations |
[out] | x | |
[in] | eps | tollerance for determining the nullspace. This is lowest value a singular value may have without entering the nullspace. |
- Warning:
- uses the U, V, S members
-
changes the tmp member
Definition at line 327 of file pinv.cpp.
void PseudoInverse::inverseWithNullSpace |
( |
const double * |
y, |
|
|
double * |
x, |
|
|
const double * |
xd, |
|
|
double |
eps | |
|
) |
| | |
- given : y = A.x
- Calculates x = A# y + (I-A# A) xd with A the weighted inverse
- A is specified with the prepare() method.
- Method : uses x = A# ( y -A.xd) + xd and calculates this via S.V.D.
- Parameters:
-
[in] | y | |
[out] | x | |
[in] | xd | |
[in] | eps | tollerance for determining the nullspace. This is lowest value a singular value may have without entering the nullspace. |
- Warning:
- prepare() has to be called first.
-
uses inverse method;
-
changes y2 members;
Definition at line 356 of file pinv.cpp.
int PseudoInverse::prepare |
( |
const double * |
_A, |
|
|
int |
_strideA, |
|
|
int |
_m, |
|
|
int |
_n, |
|
|
const double * |
_Ly, |
|
|
const double * |
_Lx, |
|
|
int |
nrOfIts | |
|
) |
| | |
prepares for solving Ax=y by calculating the singular value decomposition.
- prepare calculations for solving equations A.x = y.
- Parameters:
-
[in] | A | |
[in] | strideA | : stride of A, i.e. the amount of elements in the array between each row of A |
[in] | m | number of rows of A. |
[in] | n | number of columns of A. |
[in] | Ly | vector describing the square root of the diagonal weight matrix in y-space, has m elements. |
[in] | Lx | vector describing the square root of the diagonal weight matrix in x-space, has n elements. |
[in] | nrOfIts | maximal number of iterations while calculating the singular value decomposition of A. |
- Returns:
- 0 if successfull.
- Warning:
- a REFERENCE to _A,_Lx,_Ly is kept. So do not change these variables as long as you want to perform additional operations.
- prepare calculations for solving equations A.x = y.
- Parameters:
-
[in] | A | |
[in] | strideA | : stride of A, i.e. the amount of elements in the array between each row of A |
[in] | m | number of rows of A. |
[in] | n | number of columns of A. |
[in] | Lx | vector describing the square root of the diagonal weight matrix in x-space, has n elements. |
[in] | Ly | vector describing the square root of the diagonal weight matrix in y-space, has m elements. |
- Returns:
- 0 if successfull.
- Warning:
- changes the U, V, S, tmp members
Definition at line 409 of file pinv.cpp.
int PseudoInverse::smallestSV |
( |
double |
eps |
) |
|
Smallest eigenvalue larger then eps.
- Parameters:
-
| eps | : tollerance level, singular values smaller than eps are considered to be zero. |
- Returns:
- the index into S of the smallest eigenvalue larger then eps.
Definition at line 451 of file pinv.cpp.
Member Data Documentation
a reference to the matrix of which you take the pseudo-inverse
Definition at line 58 of file pinv.hpp.
weights in x-space
Definition at line 68 of file pinv.hpp.
weights in y-space
Definition at line 73 of file pinv.hpp.
nr of rows
Definition at line 78 of file pinv.hpp.
nr of columns
Definition at line 83 of file pinv.hpp.
index to determine the sorted singular values : i = ndx[j], where j==1 corresponds to the largest, and j==n corresponds to the smallest singular value and where i corresponds to the index in S.
Definition at line 118 of file pinv.hpp.
the prepare method() has been called
Definition at line 88 of file pinv.hpp.
array containing the diagonal elements of
Definition at line 112 of file pinv.hpp.
the stride for U.
Definition at line 98 of file pinv.hpp.
the stride for V
Definition at line 108 of file pinv.hpp.
left orthonormal matrix when prepare() is called, U contains the left orthonormal matrix of the singular value decomposition.
Definition at line 94 of file pinv.hpp.
right orthonormal matrix when prepare is called, V contains the right orthonormal matrix of the singular value decomposition.
Definition at line 104 of file pinv.hpp.
The documentation for this class was generated from the following files: