TMtx::RMS Method

Overload List

#SignatureDescription
1double RMS();Root mean square (RMS).
2double RMS(int Index, int Len);Calculate the RMS for calling object elements [Index]..[Index+Len-1] in-place.

Overload 1: double RMS();

Root mean square (RMS).

Remarks:

Calculate the root mean square value for all calling object elements in-place. The root mean square (RMS) is defined by the equation:

RMS=1Length−1∑k=0Length−1V[k]2\text{RMS}=\sqrt{\frac{1}{\text{Length}-1}\sum _{k=0} ^{\text{Length}-1} V[k] ^2 }
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}); // 1+2i ; 3+4i
    double c = a->RMS();
    FreeIt(a);
}
#include "MtxExpr.h"
#include "Units.Math387.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;

void Example()
{
    Vector a;
    a.SetIt(DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
    double result = a.RMS();
    if (Abs(result - 2.73861278752583) > 1e-10)
        throw tException(DewString("Vector.RMS: expected 2.73861278752583, got ") + SampleToStr(result));
}
See Also: TMtx::StdDev
Declared in Dew::Math::TMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 2: double RMS(int Index, int Len);

Calculate the RMS for calling object elements [Index]..[Index+Len-1] in-place.

#NameTypeDescription
1Indexint
2Lenint
Remarks:

An exception is raised if array borders are overrun.

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