Vector.Sum Method

Overload List

#SignatureDescription
1function Sum: Double;Sums vector 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 vector values.

Returns: Double

Remarks:

Returns the sum of all calling object elements. An exception is raised if calling object Vector.Complex property is true.

Examples
var a: Vector;
    b: double;
begin
    a.SetIt(False,[1,2,3,4]);
    b := a.Sum; // b = 10
end;
var
    a: Vector;
    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('Vector.Sum: expected 10.0, got ' + result.ToString);
end;
See Also: Vector.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 Vector.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 Vector.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]-

#NameTypeDescription
1ASumTCplxoutput sum
2IndexIntegerstart index
3LenIntegerelement count

Result: stored in self (calling object)

Remarks:

Stores the result in complex ASum variable. An exception is raised if calling object Vector.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 Vector.Complex property is True or array borders are overrun/underrun.