Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function Frac: TMtxVec; | Fractional part of values. |
| └ indexed: function Frac(Index: Integer; Len: Integer): TMtxVec; | ||
| 2 | function Frac(const X: TMtxVec): TMtxVec; | Calculates the fractional part for all X object values and stores the result in calling object. |
| └ indexed: function Frac(const X: TMtxVec; XIndex: Integer; Index: Integer; Len: Integer): TMtxVec; |
Overload 1: function Frac: TMtxVec;
Fractional part of values.
Result: stored in self (calling object), returns self for chaining
Calculates the fractional part for all object values in-place.
var a: Matrix;
ind: Integer;
begin
a.SetIt(2,2,False,[1,5.5,-1.6,6]); // a = [1, 5.5, -1.6, 6]
a.Frac; // a = [0, 0.5, -0.6, 0]
end;
var
a, expected: Matrix;
begin
a := [[1.2, 2.7], [-0.5, 3.9]];
a.Frac;
expected := [[0.2, 0.7], [-0.5, 0.9]];
if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
raise Exception.Create('Matrix.Frac: mismatch');
end;
Indexed: function Frac(Index: Integer; Len: Integer): TMtxVec;
Calculates the fractional part for calling object elements [Index]..[Index+Len-1] 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 Frac(const X: TMtxVec): TMtxVec;
Calculates the fractional part for all X object values and stores the result in calling object.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec |
Result: stored in self (calling object), returns self for chaining
Size and Matrix.Complex properties of calling object are adjusted automatically.
var
a, x, expected: Matrix;
begin
x := [[1.2, 2.7], [-0.5, 3.9]];
a.Frac(x);
expected := [[0.2, 0.7], [-0.5, 0.9]];
if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
raise Exception.Create('Matrix.Frac: mismatch');
end;
Indexed: function Frac(const X: TMtxVec; XIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
Calculates the fractional part for X object elements [XIndex]..[XIndex+Len-1] and stores the result 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.