Matrix::Reverse Method

Overload List

#SignatureDescription
1TMtxVec *Reverse(TMtxVec *Vec, int VecIndex, int Index, int Len) const;Reverse Matrix elements.
2TMtxVec *Reverse(int Index, int Len) const;Reverses the calling object elements [Index]..[Index+Len-1].

Overload 1: TMtxVec *Reverse(TMtxVec *Vec, int VecIndex, int Index, int Len) const;

Reverse Matrix elements.

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

The method reverses Vec Matrix elements from [VecIndex].. [VecIndex+Len-1] and stores them in the calling Matrix from [Index]...[Index+Len-1] by using the following equation:

V[k]=Vec[N−k],0≤k≤N,where N=Vec.Length−1\text{V}[k]=\text{Vec}[N-k],\quad 0\leq k \leq N, \quad \text{where } N=\text{Vec.Length}-1

This overload reverses calling Matrix elements in-place.

Examples
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;

    a.SetIt(2, 2, false, DewArray<double>{1, 2, 3, 4});
    a.Reverse(0, 2); // a = [2,1,3,4]
}
See Also: Matrix::Rotate, Matrix::Shift
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

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

Reverses the calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1Indexint
2Lenint
Remarks:

An exception is raised if array borders are overrun.

Examples
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;

    a = {{1, 2}, {3, 4}};
    a.Reverse(0, 2); // a = [2,1,3,4]
}
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler