You are here: Symbol Reference > MtxExpr Namespace > Classes > Matrix Record > public > LUSolve Method > Matrix.LUSolve Method (TVec, TVec, TMtxType, TMtxOperation)
MtxVec VCL
ContentsIndex
PreviousUpNext
Matrix.LUSolve Method (TVec, TVec, TMtxType, TMtxOperation)

Solves system of linear equations by using LU factorization.

Pascal
function LUSolve(const B: TVec; const X: TVec; MtxType: TMtxType = mtGeneral; Operation: TMtxOperation = opNone): TMtx; overload;

Uses the LU factorization to solve the system of linear equations. AX = B. The matrix must be full rank. If there are more rows than columns use the least square solver LQRSolve and if the matrix is also rank deficient use the 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: SubDiag and 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); [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.

Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!