Matrix::Frac Method

Overload List

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

Overload 1: TMtxVec *Frac() const;

Fractional part of values.

Remarks:

Calculates the fractional part for all object values in-place.

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

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;
    a.SetIt(2, 2, false, DewArray<double>{ 1.2, 2.7, -0.5, 3.9 });
    a.Frac();
    Matrix expected;
    expected.SetIt(2, 2, false, DewArray<double>{ 0.2, 0.7, -0.5, 0.9 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Matrix.Frac: mismatch");
}
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;
    int ind;

    a.SetIt(2, 2, false, DewArray<double>{1, 5.5, -1.6, 6}); // a = [1, 5.5, -1.6, 6]
    a.Frac(); // a = [0, 0.5, -0.6, 0]
}
See Also: Matrix::Trunc, Matrix::Round
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

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

Calculates the fractional part for all X object values and stores the result in calling object.

#NameTypeDescription
1XTMtxVec *
Remarks:

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

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

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;
    Matrix x;
    x.SetIt(2, 2, false, DewArray<double>{ 1.2, 2.7, -0.5, 3.9 });
    a.Frac(x);
    Matrix expected;
    expected.SetIt(2, 2, false, DewArray<double>{ 0.2, 0.7, -0.5, 0.9 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Matrix.Frac: mismatch");
}
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

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

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::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

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

Calculates the fractional part for X object elements [XIndex]..[XIndex+Len-1] and stores the result in calling object elements [Index]..[Index+Len-1].

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

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

Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler