Matrix.Sum Method

Overload List

#SignatureDescription
1function Sum: Double;Sums Matrix values.
└ indexed: function Sum(Index: Integer; Len: Integer): Double;
2procedure Sum(out ASum: TCplx);Calculates the sum of all calling object complex elements.
└ indexed: procedure Sum(out ASum: TCplx; Index: Integer; Len: Integer);
3procedure Sum(out ASum: Double; Index: Integer; Len: Integer);Calculates the sum of calling object elements [Index]..[Index+Len-1].

Overload 1: function Sum: Double;

Sums Matrix values.

Returns: Double - the sum of all calling object elements.

Remarks:

An exception is raised if calling object Matrix.Complex property is true.

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;
See Also: Matrix.Sumc

Indexed: function Sum(Index: Integer; Len: Integer): Double;

Returns the sum of calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1IndexIntegerstart index
2LenIntegerelement count

Returns: Double

Remarks:

An exception is raised if calling object Matrix.Complex property is True or array borders are overrun/underrun.

Overload 2: procedure Sum(out ASum: TCplx);

Calculates the sum of all calling object complex elements.

#NameTypeDescription
1ASumTCplxoutput sum

Result: stored in self (calling object)

Remarks:

Stores the result in complex ASum variable. An exception is raised if calling object Matrix.Complex property is False.

Indexed: procedure Sum(out ASum: TCplx; Index: Integer; Len: Integer);

Calculates the sum of calling object complex elements [Index]..[Index+Len-1] and stores the result in complex ASum variable.

#NameTypeDescription
1ASumTCplxoutput sum
2IndexIntegerstart index
3LenIntegerelement count

Result: stored in self (calling object)

Remarks:

An exception is raised if calling object Matrix.Complex property is False or array borders are overrun/underrun.

Overload 3: procedure Sum(out ASum: Double; Index: Integer; Len: Integer);

Calculates the sum of calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1ASumDoubleoutput sum
2IndexIntegerstart index
3LenIntegerelement count

Result: stored in self (calling object)

Remarks:

Stores the result in real ASum variable. An exception is raised if calling object Matrix.Complex property is True or array borders are overrun/underrun.