TSparseMtx::Solve Method

Overload List

#SignatureDescription
1void Solve(TMtx *B, TMtx *X, TMtxType MtxType = TMtxType::mtGeneral);Direct solve.
2void Solve(TVec *B, TVec *X, TMtxType MtxType = TMtxType::mtGeneral);Vector version of Solve.

Overload 1: void Solve(TMtx *B, TMtx *X, TMtxType MtxType = TMtxType::mtGeneral);

Direct solve.

#NameTypeDescription
1BTMtx *
2XTMtx *
3MtxType = TMtxType::mtGeneralTMtxType
Remarks:

Solve the system A*X = B, where A is the calling matrix. The actual system being solved is defined by TSparseMtx::SparseSystem property. A is sparse and unsymmetric. It is based on the Unsymmetric MultiFrontal method, which factorizes PAQ into the product LU, where L and U are lower and upper triangular, respectively, and P are Q are permutation matrices. Both P and Q are chosen to reduce fill-in (new nonzeros in L and U that are not present in A). The permutation P has the dual role of reducing fill-in and maintaining numerical accuracy (via relaxed partial pivoting and row interchanges).

The Solve method uses BLAS level 3 dgeem matrix multiply routine and takes full advantage of CPU specific optimized code and symmetric multiprocessing.

Examples
#include "MtxExpr.h"
#include "sparse.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector x, b;
    TSparseMtx* SparseA;

    SparseA = new TSparseMtx();
    // create the files loaded below
    Matrix A = {{4, 1, 0}, {1, 4, 1}, {0, 1, 4}};
    SparseA->DenseToSparse(A);
    SparseA->SaveToMatrixMarketFile("system.mtx");
    b = {1, 2, 3};
    b.SaveToFile("coefficients.Vec");

    // load data
    SparseA->LoadFromMatrixMarketFile("system.mtx");
    b.LoadFromFile("coefficients.Vec");
    // set solution size
    x.Size(b);
    // solve
    SparseA->SparseSolver = TSparseSolver::ssUmfPack;
    SparseA->Solve(b, x);
    //view solution
    delete SparseA;
}
See Also: TSparseMtx::SparseSolver
Declared in Dew::Math::TSparseMtx · Dew.Math/sparse.h · Cross-compiler

Overload 2: void Solve(TVec *B, TVec *X, TMtxType MtxType = TMtxType::mtGeneral);

Vector version of Solve.

#NameTypeDescription
1BTVec *
2XTVec *
3MtxType = TMtxType::mtGeneralTMtxType
Declared in Dew::Math::TSparseMtx · Dew.Math/sparse.h · Cross-compiler