You are here: Symbol Reference > MtxVec Namespace > Classes > TMtx Class > public > LUSolve Method > TMtx.LUSolve Method (TMtx, TMtx, TMtxType, TMtxOperation)
MtxVec VCL
ContentsIndex
PreviousUpNext
TMtx.LUSolve Method (TMtx, TMtx, TMtxType, TMtxOperation)

Performs factorization for LUSolve.

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

calls LU and solves L and U in the caller, does not owerwrites  

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.

var LU,A, W1, W2: TMtx; P: TVecInt; B,X: TVec; begin CreateIt(LU, A, W1, W2); CreateIt(P); CreateIt(B,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 FreeIt(LU,A, W1, W2); FreeIt(B,X); FreeIt(P); end; end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!