TSparseMtx.Sgn Method

Overload List

#SignatureDescription
1TMtxVec SgnComputes signum function of calling object elements.
└ indexed: TMtxVec Sgn(Int32 Index, Int32 Len)
2TMtxVec Sgn(TMtxVec Src)Computes signum function from Src elements and stores the result in the calling object.
└ indexed: TMtxVec Sgn(TMtxVec Src, Int32 SrcIndex, Int32 Index, Int32 Len)

Overload 1: TMtxVec Sgn

Computes signum function of calling object elements.

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

Remarks:

Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.

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

Indexed: TMtxVec Sgn(Int32 Index, Int32 Len)

Computes signum function of calling object elements [Index..Index+Len-1].

#NameTypeDescription
1IndexInt32start index
2LenInt32element count

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

Remarks:

Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.

Overload 2: TMtxVec Sgn(TMtxVec Src)

Computes signum function from Src elements and stores the result in the calling object.

#NameTypeDescription
1SrcTMtxVecsource 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. Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.

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

Indexed: TMtxVec Sgn(TMtxVec Src, Int32 SrcIndex, Int32 Index, Int32 Len)

Computes signum function from Src elements [SrcIndex..SrcIndex+Len-1] and stores the result in the calling object [Index..Index+Len-1].

#NameTypeDescription
1SrcTMtxVecsource TVec or TMtx
2SrcIndexInt32source start index
3IndexInt32start index
4LenInt32element count

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

Remarks:

Size and Dew.Math.TMtxVec.Complex properties of calling object are adjusted automatically. Signum(X) is 1 for X > 0 , equal to zero for X = 0 and -1 for X < 0.