Matrix::RMS Method

Overload List

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

Overload 1: double RMS() const;

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 "MtxExpr.h"
#include "Units.Math387.h"

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

void Example()
{
    Matrix a;
    a.SetIt(2, 2, false, DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
    double result = a.RMS();
    if (Abs(result - 2.73861278752583) > 1e-10)
        throw tException(DewString("Matrix.RMS: expected 2.73861278752583, got ") + SampleToStr(result));
}
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;
    double c;

    a.SetIt(1, 4, false, DewArray<double>{1, 2, 3, 4});
    c = a.RMS();
}
See Also: Matrix::StdDev
Declared in Dew::Math::Matrix · Dew.Math/MtxExpr.h · Cross-compiler

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

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.

Examples
#include "MtxExpr.h"

using namespace Dew;
using namespace Dew::Math;

void Example()
{
    Matrix a;
    double c;

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