Vector.Sum Method

Overload List

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

Overload 1: function Sum: double; overload;

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 := [1,2,3,4];
    b := a.Sum; // b = 10
end;
See Also: Vector.Sumc, Vector.Sumc

Indexed: function Sum(Index,Len: integer): double; overload;

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); overload;

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, Len: integer); overload;

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, Len: integer); overload;

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.