clMatrix.NormC Method

Overload List

#SignatureDescription
1Double NormCCalculate the C-norm of calling vector.
└ indexed: Double NormC(Int32 Index, Int32 Len)
2Double NormC(TOpenCLMtxVec Vec, Boolean RelativeError)The C-norm.
└ indexed: Double NormC(TOpenCLMtxVec Vec, Int32 VecIndex, Int32 Index, Int32 Len, Boolean RelativeError)

Overload 1: Double NormC

Calculate the C-norm of calling vector.

Returns: Double - NormC = max|a[i]|, 0 < i < Length-1 .

Indexed: Double NormC(Int32 Index, Int32 Len)

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

#NameTypeDescription
1IndexInt32start index
2LenInt32element count

Returns: Double

Overload 2: Double NormC(TOpenCLMtxVec Vec, Boolean RelativeError)

The C-norm.

#NameTypeDescription
1VecTOpenCLMtxVecsource TOpenCLVector or TOpenCLMatrix
2RelativeErrorBoolean

Returns: Double - C norm: ||V-Vec||, where V is the calling vector.

Remarks:

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

VVecC=maxkV[k]Vec[k]\|\text{V} - \text{Vec}\| _C = \max _k |\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":

VVecV\frac{\| \text{V} - \text{Vec}\|}{\|\text{V}\|}
Examples
using Dew.Math;
using Dew.Math.Units;

namespace Dew.Examples
{
    void Example()
    {
        TOpenCLMatrix a,b;
        clMtxVec.CreateIt(out a, out b);
        try
        {
            a.Size(2,2, TclFloatPrecision.clFloat, false);
            b.Size(2,2, TclFloatPrecision.clFloat, false);

            a.CopyFromArray(new double[] {1,2,3,4});
            b.CopyFromArray(new double[] {4,3,2,1});

            double c = a.NormC(b,true);
        }
        finally
        {
            clMtxVec.FreeIt(out a, out b);
        }
    }
}
See Also: clMatrix.NormL1, clMatrix.NormL2

Indexed: Double NormC(TOpenCLMtxVec Vec, Int32 VecIndex, Int32 Index, Int32 Len, Boolean RelativeError)

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

#NameTypeDescription
1VecTOpenCLMtxVecsource TOpenCLVector or TOpenCLMatrix
2VecIndexInt32
3IndexInt32start index
4LenInt32element count
5RelativeErrorBoolean

Returns: Double