TVec::Frac Method

Overload List

#SignatureDescription
1TMtxVec *Frac();Fractional part of values.
2TMtxVec *Frac(TMtxVec *X);Calculates the fractional part for all X object values.
3TMtxVec *Frac(int Index, int Len);Calculates the fractional part for calling object elements [Index]..[Index+Len-1] in-place.
4TMtxVec *Frac(TMtxVec *X, int XIndex, int Index, int Len);Calculates the fractional part for X object elements [XIndex]..[XIndex+Len-1].

Overload 1: TMtxVec *Frac();

Fractional part of values.

Remarks:

Calculates the fractional part for all object values 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(false, DewArray<double>{1,5.5,-1.6,6});
    a->Frac();  // a = [0, 0.5, -0.6, 0]
    FreeIt(a);
}
#include "Math387.h"
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Vector a;
    a.SetIt(DewArray<double>{ 1.2, 2.7, -0.5, 3.9 });
    a.Frac();
    Vector expected;
    expected.SetIt(DewArray<double>{ 0.2, 0.7, -0.5, 0.9 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Vector.Frac: mismatch");
}
See Also: TVec::Trunc, TVec::Round
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 2: TMtxVec *Frac(TMtxVec *X);

Calculates the fractional part for all X object values.

#NameTypeDescription
1XTMtxVec *
Remarks:

Stores the result in calling object. Size and TVec::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>{ 1.2, 2.7, -0.5, 3.9 });
    a.Frac(x);
    Vector expected;
    expected.SetIt(DewArray<double>{ 0.2, 0.7, -0.5, 0.9 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Vector.Frac: mismatch");
}
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 3: TMtxVec *Frac(int Index, int Len);

Calculates the fractional part for calling object elements [Index]..[Index+Len-1] in-place.

#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 4: TMtxVec *Frac(TMtxVec *X, int XIndex, int Index, int Len);

Calculates the fractional part for X object elements [XIndex]..[XIndex+Len-1].

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

Stores the result 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