TVec::NormL1 Method

Overload List

#SignatureDescription
1double NormL1(TDenseMtxVec *Vec, bool RelativeError = false);The L1-norm.
2double NormL1(TDenseMtxVec *Vec, int VecIndex, int Index, int Len, bool RelativeError = false);Calculates the L1 norm ||V-Vec|| between Vec elements [VecIndex]..[VecIndex+Len-1] and calling vector elements [Index]..[Index+Len-1].
3double NormL1();Calculate the L1-norm of the calling vector.
4double NormL1(int Index, int Len);Calculates the L1 norm from calling vector elements [Index]..[Index+Len-1].

Overload 1: double NormL1(TDenseMtxVec *Vec, bool RelativeError = false);

The L1-norm.

#NameTypeDescription
1VecTDenseMtxVec *
2RelativeError = falsebool

Returns: L-1 norm, defined by: ||V-Vec||, where V is calling vector.

Remarks:

If the NormL1 is called without any parameters, the NormL1 calculates the norm of calling vector. The L1 norm of ||V-Vec|| is defined by the formula:

∥V−Vec∥L1=∑k=0Length−1∣V[k]−Vec[k]∣\|\text{V} - \text{Vec}\| _{L1} = \sum _{k=0} ^{\text{Length}-1}|\text{V}[k]-\text{Vec}[k]|

If RelativeError is true then the computed norm is divided by the norm of V, and the function returns the "relative error":

∥V−Vec∥∥V∥\frac{\| \text{V} - \text{Vec}\|}{\|\text{V}\|}
Examples
#include "MtxVec.h"
#include "Units.MtxVec.h"

using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;

void Example()
{
    TVec *a, *b;
    CreateIt(a, b);
    a->SetIt(false, DewArray<double>{1,2,3,4});
    a->SetIt(false, DewArray<double>{4,3,2,1});
    double c = a->NormL1(b,true);
    FreeIt(a,b);
}
See Also: TVec::NormC, TVec::NormL2
Declared in Dew::Math::TDenseMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 2: double NormL1(TDenseMtxVec *Vec, int VecIndex, int Index, int Len, bool RelativeError = false);

Calculates the L1 norm ||V-Vec|| between Vec elements [VecIndex]..[VecIndex+Len-1] and calling vector elements [Index]..[Index+Len-1].

#NameTypeDescription
1VecTDenseMtxVec *
2VecIndexint
3Indexint
4Lenint
5RelativeError = falsebool
Declared in Dew::Math::TDenseMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler

Overload 3: double NormL1();

Calculate the L1-norm of the calling vector.

Returns: L-1 norm, defined by the following equation: NormL1 = Sum(|a[i]|), 0 < i < Length-1

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

Overload 4: double NormL1(int Index, int Len);

Calculates the L1 norm from calling vector elements [Index]..[Index+Len-1].

#NameTypeDescription
1Indexint
2Lenint
Declared in Dew::Math::TDenseMtxVec · Dew.Math/AbstractMtxVec.h · Cross-compiler