Overload List
| # | Signature | Description |
|---|---|---|
| 1 | TMtx LUSolve(TMtx B, TMtx X, TMtxType MtxType, TMtxOperation Operation) | Matrix version of LUSolve. Perfroms a LUSolve for each B and X matrices columns in single pass. |
| 2 | TMtx LUSolve(TMtx B, TMtx X, TMtxType MtxType, TMtxOperation Operation, TMtx Mtx, TMtx OrigMtx, TVecInt pipiv) | Finds solution with an already precomputed factorzation. |
| 3 | TMtx LUSolve(TMtxType MtxType, TMtx Mtx, TMtx OrigMtx, TVecInt pipiv) | Performs factorization for LUSolve. |
| 4 | TMtx LUSolve(TVec B, TVec X, TMtxType MtxType, TMtxOperation Operation) | Solves system of linear equations by using LU factorization. |
| 5 | TMtx LUSolve(TVec B, TVec X, TMtxType MtxType, TMtxOperation Operation, TMtx Mtx, TMtx OrigMtx, TVecInt pipiv) | Finds solution with an already precomputed factorization. |
Overload 1: TMtx LUSolve(TMtx B, TMtx X, TMtxType MtxType, TMtxOperation Operation)
Matrix version of LUSolve. Perfroms a LUSolve for each B and X matrices columns in single pass.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | B | TMtx | source TMtx |
| 2 | X | TMtx | source TMtx |
| 3 | MtxType | TMtxType | |
| 4 | Operation | TMtxOperation |
Result: stored in self (calling object), returns self for chaining
Overload 2: TMtx LUSolve(TMtx B, TMtx X, TMtxType MtxType, TMtxOperation Operation, TMtx Mtx, TMtx OrigMtx, TVecInt pipiv)
Finds solution with an already precomputed factorzation.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | B | TMtx | source TMtx |
| 2 | X | TMtx | source TMtx |
| 3 | MtxType | TMtxType | |
| 4 | Operation | TMtxOperation | |
| 5 | Mtx | TMtx | source TMtx |
| 6 | OrigMtx | TMtx | source TMtx |
| 7 | pipiv | TVecInt | source TVecInt |
Result: stored in self (calling object), returns self for chaining
Mtx, origMtx and ipiv contain result of factorization on exit. The factorization was obtained with a previous call to LUSolve, which did not require B and X params.
Overload 3: TMtx LUSolve(TMtxType MtxType, TMtx Mtx, TMtx OrigMtx, TVecInt pipiv)
Performs factorization for LUSolve.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | MtxType | TMtxType | |
| 2 | Mtx | TMtx | source TMtx |
| 3 | OrigMtx | TMtx | source TMtx |
| 4 | pipiv | TVecInt | source TVecInt |
Result: stored in self (calling object), returns self for chaining
Mtx, origMtx and ipiv contain result of factorization on exit. This result is again to be passed to the LUSolve together with B to obtain solution for X.
TMtx LU;
TMtx A;
TMtx W1;
TMtx W2;
TVecInt P;
TVec B;
TVec X;
MtxVec.CreateIt(out LU, out A, out W1, out W2);
MtxVec.CreateIt(out P);
MtxVec.CreateIt(out B, out X);
try
{
A.RefineSolution = true; //it is false by default
A.SetIt(2,2,false,[1,2,
3,4]);
B.SetIt(2,false, [1,
0 ]);
//Perform factorization:
A.LUSolve(mtGeneral, W1, W2, P); //OrigMtx param can be nil, if A.RefineSolution = false
//Perform solution with given factorization:
A.LUSolve(B, X, mtGeneral, opNone, W1, W2, P); //X now holds solution
}
finally
{
MtxVec.FreeIt(ref LU, ref A, ref W1, ref W2);
MtxVec.FreeIt(ref B, ref X);
MtxVec.FreeIt(ref P);
}
Overload 4: TMtx LUSolve(TVec B, TVec X, TMtxType MtxType, TMtxOperation Operation)
Solves system of linear equations by using LU factorization.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | B | TVec | source TVec |
| 2 | X | TVec | source TVec |
| 3 | MtxType | TMtxType | |
| 4 | Operation | TMtxOperation |
Result: stored in self (calling object), returns self for chaining
Uses the LU factorization to solve the system of linear equations. A X = B. The matrix must be full rank. If there are more rows than columns use the least square solver Dew.Math.TMtx.LQRSolve and if the matrix is also rank deficient use the Dew.Math.TMtx.SVDSolve method. MtxType allows the selection of an optimized algorithm and Op defines the operation to be performed on the calling matrix prior to solve.
LUSolve also supports banded matrices. The banded matrix storage is defined with the help of two additional properties: Dew.Math.TMtx.SubDiag and Dew.Math.TMtx.SuperDiag. SubDiag defines the number of non-zero subdiagonals and the SuperDiag the number of non-zero super diagonals. An example of the storage format for the first sub and super diagonal:
A.SubDiag := 1; A.SuperDiag := 1; A.Size(3,6); // ... [0 , ud2, ud3, ud4 ,ud5 ,ud6] first upper diagonal [md1, md2, md3, md4, md5, md6] main diagonal [ld1, ld2, ld3, ld4, ld5, 0] first lower diagonal
The columns must be aligned. All the diagonals between the SubDiag and SuperDiag diagonals including the main diagonal must always be included. Similarly you can define two sub/super diagonal storage format:
aXY = (X Row index, Y Column index) [a11, a12, a13, 0, 0, 0] [a21, a22, a23, a24, 0, 0] [a31, a32, a33, a34, a35, 0] [0, a42, a43, a44, a45, a46] [0, 0, a53, a54, a55, a56] [0, 0, 0, a64, a65, a66] A.SubDiag := 2; A.SuperDiag := 2; A.Size(5,6); // 5 here is the number of rows for the banded, not for the dense matrix storage format [0 , 0, a13, a24 ,a35, a46] second upper diagonal [0 , a12, a23, a34, a45, a56] first upper diagonal [a11 , a22, a33, a44, a55, a66] main diagonal [a21 , a32, a43, a54, a65, 0] first lower diagonal [a31 , a42, a53, a64, 0, 0] second lower diagonal
If you would like to solve X for several different B vectors (from the formula AX= B), you can pass TMtx objects to LUSolve method. With one call you solve the system for several different B vectors and save time.
Overload 5: TMtx LUSolve(TVec B, TVec X, TMtxType MtxType, TMtxOperation Operation, TMtx Mtx, TMtx OrigMtx, TVecInt pipiv)
Finds solution with an already precomputed factorization.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | B | TVec | source TVec |
| 2 | X | TVec | source TVec |
| 3 | MtxType | TMtxType | |
| 4 | Operation | TMtxOperation | |
| 5 | Mtx | TMtx | source TMtx |
| 6 | OrigMtx | TMtx | source TMtx |
| 7 | pipiv | TVecInt | source TVecInt |
Result: stored in self (calling object), returns self for chaining
Mtx, origMtx and ipiv contain result of factorization on exit. The factorization was obtained with a previous call to LUSolve, which did not require B and X params.