Matrix.Abs Method

Overload List

#SignatureDescription
1function Abs: TMtxVec;Absolute values.
└ indexed: function Abs(Index: Integer; Len: Integer): TMtxVec;
2function Abs(const X: TMtxVec): TMtxVec;Calculate the absolute value for all X object.
└ indexed: function Abs(const X: TMtxVec; XIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Overload 1: function Abs: TMtxVec;

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
var a,b: Matrix;
begin
    a.SetIt(1,2,True,[1,-2,3,4]);
    a.Abs;
    a := Abs(a); //same as a.Abs
    b.Abs(a);   //same as b := Abs(a);
    b := Abs(a);
end;
var
    a, expected: Matrix;
begin
    a := [[-3.0, -1.0], [1.0, 2.0]];
    a.Abs;
    expected := [[3.0, 1.0], [1.0, 2.0]];
    if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
        raise Exception.Create('Matrix.Abs: mismatch');
end;
See Also: Matrix.Mag

Indexed: function Abs(Index: Integer; Len: Integer): TMtxVec;

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

#NameTypeDescription
1IndexIntegerstart index
2LenIntegerelement 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: function Abs(const X: TMtxVec): TMtxVec;

Calculate the absolute value for all X object.

#NameTypeDescription
1XTMtxVec

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

Remarks:

Store the results in the calling object. Size and Matrix.Complex property of calling object are adjusted automatically.

Examples
var
    a, x, expected: Matrix;
begin
    x := [[-3.0, -1.0], [1.0, 2.0]];
    a.Abs(x);
    expected := [[3.0, 1.0], [1.0, 2.0]];
    if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
        raise Exception.Create('Matrix.Abs: mismatch');
end;

Indexed: function Abs(const X: TMtxVec; XIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

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

#NameTypeDescription
1XTMtxVec
2XIndexIntegerX start index
3IndexIntegerstart index
4LenIntegerelement 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.