MatrixInt::CumSum Method

Overload List

#SignatureDescription
1TMtxVecInt *CumSum(int Index, int Len) const;Cumulative sum.
2TMtxVecInt *CumSum(TMtxVecInt *Vec, int VecIndex, int Index, int Len) const;Calculate the cumulative sum for Vec elements [VecIndex]..[VecIndex+Len-1].
3TMtxInt *CumSum() const;Cumulative sum for each of the matrix columns.
4TMtxInt *CumSum(TMtxInt *Mtx) const;Calculate the cumulative sum for each of the X matrix columns.

Overload 1: TMtxVecInt *CumSum(int Index, int Len) const;

Cumulative sum.

#NameTypeDescription
1Indexint
2Lenint
Remarks:

Calculate the cumulative sum for calling object elements [Index]..[Index+Len-1] in-place. An exception is raised if TMtxVecBase::ConditionCheck is true and array borders are overrun.

Examples
#include "MtxVecInt.h"
#include "Units.MtxVecInt.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVecInt;

void Example()
{
    TVecInt* a;
    CreateIt(a);
    a->SetIt(DewArray<int>{1,2,3,4});
    a->CumSum();  // a = [1,3,6,10]
    FreeIt(a);
}
See Also: MatrixInt::Sum
Declared in Dew::Math::MatrixInt · Dew.Math/MtxExprInt.h · Cross-compiler

Overload 2: TMtxVecInt *CumSum(TMtxVecInt *Vec, int VecIndex, int Index, int Len) const;

Calculate the cumulative sum for Vec elements [VecIndex]..[VecIndex+Len-1].

#NameTypeDescription
1VecTMtxVecInt *
2VecIndexint
3Indexint
4Lenint
Remarks:

Store the results in calling object elements [Index]..[Index+Len-1]. Size and MatrixInt::IntPrecision properties of the calling object must be set explicitly. Exception is raised if TMtxVecBase::ConditionCheck property is True and array borders are overrun.

Declared in Dew::Math::MatrixInt · Dew.Math/MtxExprInt.h · Cross-compiler

Overload 3: TMtxInt *CumSum() const;

Cumulative sum for each of the matrix columns.

Remarks:

Calculate the cumulative sum for each of the calling matrix columns in-place. Function performs no overflow checking. It is users responsibility to ensure that the sum does not overflow the range of the used integer storage type.

Examples
#include "MtxVecInt.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    TMtxInt* Mtx;

    Mtx = new TMtxInt();
    Mtx->SetIt(3, 2, DewArray<int>{1, 2,
        2, 5,
        3, 1});
    Mtx->CumSum();
    // Mtx becomes:
    // 1, 2
    // 3, 7
    // 6, 8
    delete Mtx;
}
See Also: MatrixInt::SumCols
Declared in Dew::Math::MatrixInt · Dew.Math/MtxExprInt.h · Cross-compiler

Overload 4: TMtxInt *CumSum(TMtxInt *Mtx) const;

Calculate the cumulative sum for each of the X matrix columns.

#NameTypeDescription
1MtxTMtxInt *
Remarks:

Store the results in calling matrix. The MatrixInt::Rows, MatrixInt::Cols and TMtxVecInt::IntPrecision properties of the callig matrix are adjusted implicitly to match those of Mtx matrix.

Declared in Dew::Math::MatrixInt · Dew.Math/MtxExprInt.h · Cross-compiler