function Sum: Integer;
Sums vector values.
Returns: Int32 - the sum of all calling object elements.
Examples
var a: Matrix;
b: double;
begin
a.SetIt(1,4,False,[1,2,3,4]);
b := a.Sum; // b = 10
end;
var
a: Matrix;
result: double;
begin
a := [[1.0, 2.0], [3.0, 4.0]];
result := a.Sum;
if Abs(result - 10.0) > 1e-10 then
raise Exception.Create('Matrix.Sum: expected 10.0, got ' + result.ToString);
end;
Indexed: function Sum(Index: Integer; Len: Integer): Integer;
Returns the sum of calling object elements [Index]..[Index+Len-1].
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Index | Integer | start index |
| 2 | Len | Integer | element count |
Returns: Int32
Remarks:
An exception is raised if array borders are overrun/underrun.
Examples
Uses MtxVecInt;
procedure Example;
var a: TMtxInt;
b: integer;
begin
CreateIt(a);
a.SetIt(2,2,[1,2,3,4]);
b := a.Sum; // b = 10
FreeIt(a);
end;