TSparseMtx::Value Property

__declspec(property(get = GetValue)) TSparseValue2D*Value;

Allows setting and getting value at position Row and Col.

Read: TSparseValue2D *GetValue();
Remarks:

Allows setting and getting value at position Row and Col. This property is to be used to form a new sparse matrix only. See the TSparseMtx::TripletsToSparseAndFlush method, on how to use this property. This property should not be used to access individual values of a sparse matrix. To access individual values, the following pattern can be used:

for i := 0 to SparseMtx.Cols-1 do
  for j := SparseMtx.ap[i] to SparseMtx.ap[i+1]-1 do
  begin
    aRow := SparseMtx.ai[j];
    aValue := SparseMtx.Values[j];
    //...       The aValue is stored at i'th column and aRow
    //i'th column values are stored in the Values array from index ap[i] to ap[i+1]
    //the row indices for the i'th column are stored in the Ai array
  end;
Examples
#include "MtxExpr.h"
#include "sparse.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    TSparseMtx* SparseMtx = new TSparseMtx();
    Matrix A;
    int i, j, aRow;
    double aValue;
    A.SetIt(3, 3, false, DewArray<double>{1, 0, 0, 0, 2, 0, 0, 1, 3});
    SparseMtx->DenseToSparse(A);

    for (i = 0; i <= SparseMtx->Cols - 1; i++)
        for (j = SparseMtx->Ap[i]; j <= SparseMtx->Ap[i + 1] - 1; j++)
        {
            aRow = SparseMtx->AI[j];
            aValue = SparseMtx->Values(j);
            //...       The aValue is stored at i'th column and aRow
            //i'th column values are stored in the Values array from index ap[i] to ap[i+1]
            //the row indices for the i'th column are stored in the Ai array
        }
    delete SparseMtx;
}
Declared in Dew::Math::TSparseMtx · Dew.Math/sparse.h · Cross-compiler