Matrix::Round Method

Overload List

#SignatureDescription
1TMtxVec *Round() const;Elements rounded to the nearest whole number.
2TMtxVec *Round(int Index, int Len) const;Round calling object elements [Index]..[Index+Len-1] in-place.
3TMtxVec *Round(TMtxVec *Src) const;Round all Src object elements and store the results in calling object elements.
4void Round(DewArray<int> &Dst) const;Rounds the calling object elements to 4 byte integers and stores the result in the Dst array.
5TMtxVec *Round(TMtxVec *Src, int SrcIndex, int Index, int Len) const;Round Src object elements [SrcIndex]..[SrcIndex+Len-1].

Overload 1: TMtxVec *Round() const;

Elements rounded to the nearest whole number.

Remarks:

Rounds all calling object elements to the nearest whole number. The result can be stored to an array of integers or as floating point number.

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.Round();
    Matrix expected;
    expected.SetIt(2, 2, false, DewArray<double>{ 1.0, 3.0, -1.0, 4.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Matrix.Round: mismatch");
}
See Also: Matrix::Trunc, Matrix::Frac
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

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

Round calling object elements [Index]..[Index+Len-1] in-place.

#NameTypeDescription
1Indexint
2Lenint
Remarks:

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

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

Overload 3: TMtxVec *Round(TMtxVec *Src) const;

Round all Src object elements and store the results in calling object elements.

#NameTypeDescription
1SrcTMtxVec *
Remarks:

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

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.Round();
    Matrix expected;
    expected.SetIt(2, 2, false, DewArray<double>{ 1.0, 3.0, -1.0, 4.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Matrix.Round: mismatch");
}
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

Overload 4: void Round(DewArray<int> &Dst) const;

Rounds the calling object elements to 4 byte integers and stores the result in the Dst array.

#NameTypeDescription
1DstDewArray<int> &
Remarks:

The size of the Dst array is set automatically. If the complex property is True then the length of the array will be equal to Self.Length*2.

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.Round();
    Matrix expected;
    expected.SetIt(2, 2, false, DewArray<double>{ 1.0, 3.0, -1.0, 4.0 });
    if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
        throw tException("Matrix.Round: mismatch");
}
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

Overload 5: TMtxVec *Round(TMtxVec *Src, int SrcIndex, int Index, int Len) const;

Round Src object elements [SrcIndex]..[SrcIndex+Len-1].

#NameTypeDescription
1SrcTMtxVec *
2SrcIndexint
3Indexint
4Lenint
Remarks:

Store the results to calling object elements [Index]..[Index+Len-1]. Size and Matrix::Complex property of the calling object must be set explicitly. An exception is raised if array borders are overrun/underrun.

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