Contains functions to solve a linear system AX=B with LU decomposition.
More...
Functions |
int | LUdecmpDoolittle (double *A, int n) |
int | LUsolveDoolittle (double *LU, double *X, int nRows, int nCols) |
int | LUdecmpCrout (double *A, int n, int *indx) |
int | LUsolveCrout (double *LU, double *B, double *X, int nRows, int nCols, int *order) |
Detailed Description
Contains functions to solve a linear system AX=B with LU decomposition.
This namespace contains two algorithms to solve the linear equation AX=B where size(A)=nxn and size(B)=size(X)=nxm, with n>0,m>0. It was written to efficiently calculate the Gain K in the unscented Kalman Filter of UKF Tractography. As of now, curiously, VNL doesnt provide an efficient solution for matrix RHSs. Be careful with this file, it was only tested with this particular problem.
-
Doolittle Algorithm: Slightly faster for the current problem
-
Crout Algorithm: Numerically more stable because it employs a pivoting strategy. For this application it made no difference.
- Author:
- Christian Baumgartner (c.f.baumgartner@gmail.com)
Function Documentation
int LU_Solver::LUdecmpCrout |
( |
double * |
A, |
|
|
int |
n, |
|
|
int * |
indx | |
|
) |
| | |
Calculates the LU decomposition of the square Matrix A : p(A) = LU, where p is a row permutation function. For this version the crout algorithm is used. It was adapted from "Numerical Recipes in C"
- Parameters:
-
| A | nxn matrix to be decomposed and result of LU decomposition (in/out) |
| n | Dimension of the matrix. |
| indx | A vector stores the original order of the rows, and is used to unscramble a later. |
- Returns:
- 0 if succesful, and -1 if A is singular
int LU_Solver::LUdecmpDoolittle |
( |
double * |
A, |
|
|
int |
n | |
|
) |
| | |
Calculates the LU decomposition of the square Matrix A : A=LU using the Doolittle algorithm, and stores it in the same Matrix. See http://en.wikipedia.org/wiki/Lu_decomposition#Doolittle_algorithm
- Parameters:
-
| A | nxn matrix to be decomposed and result of LU decomposition (in/out) |
| n | Dimension of the matrix. |
- Returns:
- 0 if succesful, and -1 if A is singular
int LU_Solver::LUsolveCrout |
( |
double * |
LU, |
|
|
double * |
B, |
|
|
double * |
X, |
|
|
int |
nRows, |
|
|
int |
nCols, |
|
|
int * |
order | |
|
) |
| | |
Given the LU decomposition from LUdecmpCrout solves the linear system AX=B where X and B are also matrices.
- Parameters:
-
| LU | the decomposition of A (nRowsxnRows) : A = LU where the upper triangle contains U, and the lower L without the diagonal. |
| X | the righthand side matrix B (nRowsxnCols) as input, and X (nRowsxnCols) as output |
| nRows | The number of rows in B, X and LU |
| nCols | The number of columns in B, and X |
| order | The original order of the rows. It's used to undo the permutation of the LU decomposition later. (out) |
- Returns:
- returns 0 if succesful, and -1 if singular
int LU_Solver::LUsolveDoolittle |
( |
double * |
LU, |
|
|
double * |
X, |
|
|
int |
nRows, |
|
|
int |
nCols | |
|
) |
| | |
Given the LU decomposition from LUdecmpDoolittle solves the linear system AX=B where X and B are also matrices.
- Parameters:
-
| LU | the decomposition of A (nRowsxnRows) : A = LU where the upper triangle contains U, and the lower L without the diagonal. |
| X | the righthand side matrix B (nRowsxnCols) as input, and X (nRowsxnCols) as output |
| nRows | The number of rows in B, X and LU |
| nCols | The number of columns in B, and X |
- Returns:
- returns 0 if succesful, and -1 if singular