TSparseMtx::Abs Method

Overload List

#SignatureDescription
1TMtxVec *Abs();Absolute values.
2TMtxVec *Abs(int Index, int Len);Calculate the absolute value for calling object elements [Index]..[Index+Len-1].
3TMtxVec *Abs(TMtxVec *X);Calculate the absolute value for all X object and store the results in the calling object.
4TMtxVec *Abs(TMtxVec *X, int XIndex, int Index, int Len);Calculate the absolute value of X object elements [XIndex]..[XIndex+Len-1].

Overload 1: TMtxVec *Abs();

Absolute values.

Remarks:

Calculate the absolute value of all calling object elemets in-place.

Examples
#include "Units.MtxVec.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;

void Example()
{
    TVec* a;
    CreateIt(a);
    a->SetIt(true, DewArray<double>{1,-2,3,4});
    a->Abs(); // a = [1,2,3,4]
    FreeIt(a);
}
#include "Math387.h"
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;
    a.SetIt(DewArray<double>{ -3.0, -1.0, 1.0, 2.0 });
    a.Abs();
    Vector expected;
    expected.SetIt(DewArray<double>{ 3.0, 1.0, 1.0, 2.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Vector.Abs: mismatch");
}
See Also: TSparseMtx::Mag
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 2: TMtxVec *Abs(int Index, int Len);

Calculate the absolute value for calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1Indexint
2Lenint
Remarks:

An exception is raised if array borders are overrun or underrun.

Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 3: TMtxVec *Abs(TMtxVec *X);

Calculate the absolute value for all X object and store the results in the calling object.

#NameTypeDescription
1XTMtxVec *
Remarks:

Size and TSparseMtx::Complex properties of calling object are adjusted automatically.

Examples
#include "Math387.h"
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;
    Vector x;
    x.SetIt(DewArray<double>{ -3.0, -1.0, 1.0, 2.0 });
    a.Abs(x);
    Vector expected;
    expected.SetIt(DewArray<double>{ 3.0, 1.0, 1.0, 2.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Vector.Abs: mismatch");
}
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 4: TMtxVec *Abs(TMtxVec *X, int XIndex, int Index, int Len);

Calculate the absolute value of X object elements [XIndex]..[XIndex+Len-1].

#NameTypeDescription
1XTMtxVec *
2XIndexint
3Indexint
4Lenint
Remarks:

Store the results in calling object elements [Index]..[Index+Len-1]. An exception is raised if array borders are overrun or underrun.

Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler