Vector.CumSum Method

Overload List

#SignatureDescription
1function CumSum: TVec;Cumulative sum.
└ indexed: function CumSum(Index: Integer; Len: Integer): TMtxVec;
2function CumSum(const Vec: TVec): TVec;Calculate the cumulative sum for all Vec elements.
3function CumSum(const Vec: TMtxVec; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;Calculate the cumulative sum for Vec elements [VecIndex]..[VecIndex+Len-1] and store the results in calling object elements [Index]..[Index+Len-1].

Overload 1: function CumSum: TVec;

Cumulative sum.

Result: stored in self (calling object), returns self for chaining

Remarks:

Calculate the cumulative sum for all calling object elements in-place.

Examples
var a: Vector;
begin
    a.SetIt(false,[1,2,3,4];
    a.CumSum; // a = [1,3,6,10]
end;
See Also: Vector.Sum

Indexed: function CumSum(Index: Integer; Len: Integer): TMtxVec;

Cumulative sum.

#NameTypeDescription
1IndexIntegerstart index
2LenIntegerelement count

Result: stored in self (calling object), returns self for chaining

Remarks:

Calculate the cumulative sum for calling object elements [Index]..[Index+Len-1] in-place. An exception is raised if Vector.ConditionCheck is true and array borders are overrun.

Examples
var a: Vector;
begin
    a.SetIt(false,[1,2,3,4];
    a.CumSum; // a = [1,3,6,10]
end;
See Also: Vector.Sum

Overload 2: function CumSum(const Vec: TVec): TVec;

Calculate the cumulative sum for all Vec elements.

#NameTypeDescription
1VecTVec

Result: stored in self (calling object), returns self for chaining

Remarks:

Store the results in calling object. Size and Vector.Complex properties of the calling object are set implicitly.

Overload 3: function CumSum(const Vec: TMtxVec; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Calculate the cumulative sum for Vec elements [VecIndex]..[VecIndex+Len-1] and store the results in calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1VecTMtxVec
2VecIndexInteger
3IndexIntegerstart index
4LenIntegerelement count

Result: stored in self (calling object), returns self for chaining

Remarks:

Size and Vector.Complex properties of the calling object must be set explicitly. Exception is raised if Vector.ConditionCheck property is True and array borders are overrun.