TVec.Abs Method

Overload List

#SignatureDescription
1TMtxVec AbsAbsolute values.
└ indexed: TMtxVec Abs(Int32 Index, Int32 Len)
2TMtxVec Abs(TMtxVec X)Calculate the absolute value for all X object and store the results in the calling object.
└ indexed: TMtxVec Abs(TMtxVec X, Int32 XIndex, Int32 Index, Int32 Len)

Overload 1: TMtxVec Abs

Absolute values.

Result: stored in self (calling object), returns self for chaining

Remarks:

Calculate the absolute value of all calling object elements in-place.

Examples
Vector a = new Vector();
a.SetIt(new double[] { -3.0, -1.0, 1.0, 2.0 });
a.Abs();
Vector expected = new Vector();
expected.SetIt(new double[] { 3.0, 1.0, 1.0, 2.0 });
if (!a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute))
    throw new Exception("Vector.Abs: mismatch");
Vector a;
Vector b;
a.SetIt(true,new double[] {1,-2,3,4});
a.Abs;
a = Math.Abs(a); //same as a.Abs
b.Math.Abs(a);   //same as b = Math.Abs(a);
b = Math.Abs(a);

Indexed: TMtxVec Abs(Int32 Index, Int32 Len)

Calculate the absolute value for calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1IndexInt32start index
2LenInt32element count

Result: stored in self (calling object), returns self for chaining

Remarks:

An exception is raised if array borders are overrun or underrun.

Overload 2: TMtxVec Abs(TMtxVec X)

Calculate the absolute value for all X object and store the results in the calling object.

#NameTypeDescription
1XTMtxVecsource TVec or TMtx

Result: stored in self (calling object), returns self for chaining

Remarks:

Size and Dew.Math.TMtxVec.Complex properties of calling object are adjusted automatically.

Examples
Vector a = new Vector();
Vector x = new Vector();
x.SetIt(new double[] { -3.0, -1.0, 1.0, 2.0 });
a.Abs(x);
Vector expected = new Vector();
expected.SetIt(new double[] { 3.0, 1.0, 1.0, 2.0 });
if (!a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute))
    throw new Exception("Vector.Abs: mismatch");

Indexed: TMtxVec Abs(TMtxVec X, Int32 XIndex, Int32 Index, Int32 Len)

Calculate the absolute value of X object elements [XIndex]..[XIndex+Len-1].

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexInt32X start index
3IndexInt32start index
4LenInt32element count

Result: stored in self (calling object), returns self for chaining

Remarks:

Store the results in calling object elements [Index]..[Index+Len-1]. An exception is raised if array borders are overrun or underrun.