Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function Sign: TMtxVec; | Changes elements sign. |
| └ indexed: function Sign(Index: Integer; Len: Integer): TMtxVec; | ||
| 2 | function Sign(const X: TMtxVec): TMtxVec; | Change all X object elements sign and store the results in calling object. |
| └ indexed: function Sign(const X: TMtxVec; XIndex: Integer; Index: Integer; Len: Integer): TMtxVec; |
Overload 1: function Sign: TMtxVec;
Changes elements sign.
Result: stored in self (calling object), returns self for chaining
Changes all calling object elements sign (v -> -v) in-place.
var a: Vector;
begin
a.SetIt(False,[1,2,-3,4]);
a.Sign; // a = [-1,-2,3,-4]
end;
var
a, expected: Vector;
begin
a := [-3.0, -1.0, 1.0, 2.0];
a.Sign;
expected := [3.0, 1.0, -1.0, -2.0];
if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
raise Exception.Create('Vector.Sign: mismatch');
end;
Indexed: function Sign(Index: Integer; Len: Integer): TMtxVec;
Change calling object elements [Index]..[Index+Len-1] sign in-place.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Index | Integer | start index |
| 2 | Len | Integer | element count |
Result: stored in self (calling object), returns self for chaining
An exception is raised if array borders are overrun or underrun.
Overload 2: function Sign(const X: TMtxVec): TMtxVec;
Change all X object elements sign and store the results in calling object.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec |
Result: stored in self (calling object), returns self for chaining
Size and Vector.Complex properties of calling object are adjusted automatically.
var
a, x, expected: Vector;
begin
x := [-3.0, -1.0, 1.0, 2.0];
a.Sign(x);
expected := [3.0, 1.0, -1.0, -2.0];
if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
raise Exception.Create('Vector.Sign: mismatch');
end;
Indexed: function Sign(const X: TMtxVec; XIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
Change X object elements [XIndex]..[XIndex+Len-1] sign and store the results in calling object elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec | |
| 2 | XIndex | Integer | X start index |
| 3 | Index | Integer | start index |
| 4 | Len | Integer | element count |
Result: stored in self (calling object), returns self for chaining
An exception is raised if array borders are overrun or underrun.