TVec.AddScaled Method

Overload List

#SignatureDescription
1function AddScaled(const Vec: TMtxVec; const aScale: TCplx): TMtxVec;Add each of Vec elements to corresponding elements in the calling object.
└ indexed: function AddScaled(const Vec: TMtxVec; const aScale: TCplx; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
2function AddScaled(const X: TMtxVec; const xScale: TCplx; const Y: TMtxVec; const yScale: TCplx): TMtxVec;self = X*xScale + Y*yScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: TCplx; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; Index: Integer; Len: Integer): TMtxVec;
3function AddScaled(const X: TMtxVec; const xScale: TCplx; const Y: TMtxVec; const yScale: TCplx; const Z: TMtxVec; const zScale: TCplx): TMtxVec;self = X*xScale + Y*yScale + Z*zScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: TCplx; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; const Z: TMtxVec; zIndex: Integer; const zScale: TCplx; Index: Integer; Len: Integer): TMtxVec;
4function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: TCplx): TMtxVec;self = X + Y*yScale with complex arguments
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; Index: Integer; Len: Integer): TMtxVec;
5function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: TCplx; const Z: TMtxVec; const zScale: TCplx): TMtxVec;self = X + Y*yScale + Z*zScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; const Z: TMtxVec; zIndex: Integer; const zScale: TCplx; Index: Integer; Len: Integer): TMtxVec;
6function AddScaled(const X: TMtxVec; const Y: TMtxVec; const Z: TMtxVec; const zScale: TCplx): TMtxVec;self = X + Y + Z*zScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; const zScale: TCplx; Index: Integer; Len: Integer): TMtxVec;
7function AddScaled(const X: TMtxVec; const Y: TMtxVec; const Z: TMtxVec; const zScale: Double): TMtxVec;self = X + Y + Z*zScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; const zScale: Double; Index: Integer; Len: Integer): TMtxVec;
8function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: Double): TMtxVec;self = X + Y*yScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: Double; Index: Integer; Len: Integer): TMtxVec;
9function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: Double; const Z: TMtxVec; const zScale: Double): TMtxVec;self = X + Y*yScale + Z*zScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: Double; const Z: TMtxVec; zIndex: Integer; const zScale: Double; Index: Integer; Len: Integer): TMtxVec;
10function AddScaled(const Vec: TMtxVec; const aScale: Double): TMtxVec;Add each of Vec elements to corresponding elements in the calling object.
└ indexed: function AddScaled(const Vec: TMtxVec; const aScale: Double; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
11function AddScaled(const X: TMtxVec; const xScale: Double; const Y: TMtxVec; const yScale: Double): TMtxVec;self = X*xScale + Y*yScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: Double; const Y: TMtxVec; YIndex: Integer; const yScale: Double; Index: Integer; Len: Integer): TMtxVec;
12function AddScaled(const X: TMtxVec; const xScale: Double; const Y: TMtxVec; const yScale: Double; const Z: TMtxVec; const zScale: Double): TMtxVec;self = X*xScale + Y*yScale + Z*zScale
└ indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: Double; const Y: TMtxVec; YIndex: Integer; const yScale: Double; const Z: TMtxVec; zIndex: Integer; const zScale: Double; Index: Integer; Len: Integer): TMtxVec;
13function AddScaled(const Vec: TMtxVec; const RScale: Double; const IScale: Double): TMtxVec;Add each of Vec elements to corresponding elements in the calling object.

Overload 1: function AddScaled(const Vec: TMtxVec; const aScale: TCplx): TMtxVec;

Add each of Vec elements to corresponding elements in the calling object.

#NameTypeDescription
1VecTMtxVecsource TVec or TMtx
2aScaleTCplxscalar

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

Remarks:

In addition, the following formula is being used:

result = result+ aScale*Vec .

The results are stored in the calling object. Size and TMtxVec.Complex properties of the calling object are set implicitly to match the Vec object.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, A1, A2, A3: Vector;
    yScale: Double;
begin
    yScale := 1.5;
    X := [1,2,3,4];
    Y := [2,3,4,5];
    A1 := X + Y * yScale;
    A2 := AddScaled(X, Y, yScale);
    A3.AddScaled(X, Y, yScale);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;

Indexed: function AddScaled(const Vec: TMtxVec; const aScale: TCplx; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Adds Vec elements [VecIndex]..[VecIndex+Len-1] to calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1VecTMtxVecsource TVec or TMtx
2aScaleTCplxscalar
3VecIndexInteger
4IndexIntegerstart index
5LenIntegerelement count

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

Remarks:

In addition, the following formula is being used:

result = result+ aScale*Vec .

An exception is raised if TMtxVecBase.ConditionCheck is true and array borders are overrun.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, Z, A1, A2, A3: Vector;
    yScale, zScale: Double;
begin
    yScale := 1.5;
    zScale := 2.0;
    X := [1,2,3,4];
    Y := [2,3,4,5];
    Z := [3,4,5,6];
    A1 := X + Y * yScale + Z * zScale;
    A2 := AddScaled(X, Y, yScale, Z, zScale);
    A3.AddScaled(X, Y, yScale, Z, zScale);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;

Overload 2: function AddScaled(const X: TMtxVec; const xScale: TCplx; const Y: TMtxVec; const yScale: TCplx): TMtxVec;

Compute X*xScale + Y*yScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2xScaleTCplxscalar
3YTMtxVecsource TVec or TMtx
4yScaleTCplxscalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: TCplx; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; Index: Integer; Len: Integer): TMtxVec;

Compute X*xScale + Y*yScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3xScaleTCplxscalar
4YTMtxVecsource TVec or TMtx
5YIndexIntegerY start index
6yScaleTCplxscalar
7IndexIntegerstart index
8LenIntegerelement count

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

Overload 3: function AddScaled(const X: TMtxVec; const xScale: TCplx; const Y: TMtxVec; const yScale: TCplx; const Z: TMtxVec; const zScale: TCplx): TMtxVec;

Compute X*xScale + Y*yScale + Z*zScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2xScaleTCplxscalar
3YTMtxVecsource TVec or TMtx
4yScaleTCplxscalar
5ZTMtxVecsource TVec or TMtx
6zScaleTCplxscalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: TCplx; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; const Z: TMtxVec; zIndex: Integer; const zScale: TCplx; Index: Integer; Len: Integer): TMtxVec;

Compute X*xScale + Y*yScale + Z*zScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3xScaleTCplxscalar
4YTMtxVecsource TVec or TMtx
5YIndexIntegerY start index
6yScaleTCplxscalar
7ZTMtxVecsource TVec or TMtx
8zIndexInteger
9zScaleTCplxscalar
10IndexIntegerstart index
11LenIntegerelement count

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

Overload 4: function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: TCplx): TMtxVec;

Compute X + Y*yScale with complex arguments.

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2YTMtxVecsource TVec or TMtx
3yScaleTCplxscalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; Index: Integer; Len: Integer): TMtxVec;

Compute X + Y*yScale on sub arrays with complex arguments.

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3YTMtxVecsource TVec or TMtx
4YIndexIntegerY start index
5yScaleTCplxscalar
6IndexIntegerstart index
7LenIntegerelement count

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

Overload 5: function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: TCplx; const Z: TMtxVec; const zScale: TCplx): TMtxVec;

Compute X + Y*yScale + Z*zScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2YTMtxVecsource TVec or TMtx
3yScaleTCplxscalar
4ZTMtxVecsource TVec or TMtx
5zScaleTCplxscalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: TCplx; const Z: TMtxVec; zIndex: Integer; const zScale: TCplx; Index: Integer; Len: Integer): TMtxVec;

Compute X + Y*yScale + Z*zScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3YTMtxVecsource TVec or TMtx
4YIndexIntegerY start index
5yScaleTCplxscalar
6ZTMtxVecsource TVec or TMtx
7zIndexInteger
8zScaleTCplxscalar
9IndexIntegerstart index
10LenIntegerelement count

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

Overload 6: function AddScaled(const X: TMtxVec; const Y: TMtxVec; const Z: TMtxVec; const zScale: TCplx): TMtxVec;

Compute X + Y + Z*zScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2YTMtxVecsource TVec or TMtx
3ZTMtxVecsource TVec or TMtx
4zScaleTCplxscalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; const zScale: TCplx; Index: Integer; Len: Integer): TMtxVec;

Compute X + Y + Z*zScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3YTMtxVecsource TVec or TMtx
4YIndexIntegerY start index
5ZTMtxVecsource TVec or TMtx
6zIndexInteger
7zScaleTCplxscalar
8IndexIntegerstart index
9LenIntegerelement count

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

Overload 7: function AddScaled(const X: TMtxVec; const Y: TMtxVec; const Z: TMtxVec; const zScale: Double): TMtxVec;

Compute X + Y + Z*zScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2YTMtxVecsource TVec or TMtx
3ZTMtxVecsource TVec or TMtx
4zScaleDoublescalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; const zScale: Double; Index: Integer; Len: Integer): TMtxVec;

Compute X + Y + Z*zScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3YTMtxVecsource TVec or TMtx
4YIndexIntegerY start index
5ZTMtxVecsource TVec or TMtx
6zIndexInteger
7zScaleDoublescalar
8IndexIntegerstart index
9LenIntegerelement count

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

Overload 8: function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: Double): TMtxVec;

Compute X + Y*yScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2YTMtxVecsource TVec or TMtx
3yScaleDoublescalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: Double; Index: Integer; Len: Integer): TMtxVec;

Compute X + Y*yScale on sub arrays.

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3YTMtxVecsource TVec or TMtx
4YIndexIntegerY start index
5yScaleDoublescalar
6IndexIntegerstart index
7LenIntegerelement count

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

Overload 9: function AddScaled(const X: TMtxVec; const Y: TMtxVec; const yScale: Double; const Z: TMtxVec; const zScale: Double): TMtxVec;

Compute X + Y*yScale + Z*zScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2YTMtxVecsource TVec or TMtx
3yScaleDoublescalar
4ZTMtxVecsource TVec or TMtx
5zScaleDoublescalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const yScale: Double; const Z: TMtxVec; zIndex: Integer; const zScale: Double; Index: Integer; Len: Integer): TMtxVec;

Compute X + Y*yScale + Z*zScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3YTMtxVecsource TVec or TMtx
4YIndexIntegerY start index
5yScaleDoublescalar
6ZTMtxVecsource TVec or TMtx
7zIndexInteger
8zScaleDoublescalar
9IndexIntegerstart index
10LenIntegerelement count

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

Overload 10: function AddScaled(const Vec: TMtxVec; const aScale: Double): TMtxVec;

Add each of Vec elements to corresponding elements in the calling object.

#NameTypeDescription
1VecTMtxVecsource TVec or TMtx
2aScaleDoublescalar

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

Remarks:

In addition, the following formula is being used:

result = result+ aScale*Vec .

The results are stored in the calling object. Size and TMtxVec.Complex properties of the calling object are set implicitly to match the Vec object.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, A1, A2, A3: Vector;
    xScale, yScale: Double;
begin
    xScale := 1.5;
    yScale := -1.5;
    X := [1,2,3,4];
    Y := [2,3,4,5];
    A1 := X * xScale + Y * yScale;           // easiest to read, but creates temporaries
    A2 := AddScaled(X, xScale, Y, yScale);     // faster, but still one temporary
    A3.AddScaled(X, xScale, Y, yScale);        // fastest (in-place)

    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;

Indexed: function AddScaled(const Vec: TMtxVec; const aScale: Double; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Adds Vec elements [VecIndex]..[VecIndex+Len-1] to calling object elements [Index]..[Index+Len-1].

#NameTypeDescription
1VecTMtxVecsource TVec or TMtx
2aScaleDoublescalar
3VecIndexInteger
4IndexIntegerstart index
5LenIntegerelement count

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

Remarks:

The following formula is being used:

result = result + aScale*Vec .

An exception is raised if TMtxVecBase.ConditionCheck is true and array borders are overrun.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, Z, A1, A2, A3: Vector;
    zScale: Double;
begin
    zScale := 2.0;
    X := [1,2,3,4];
    Y := [2,3,4,5];
    Z := [3,4,5,6];
    A1 := X + Y + Z * zScale;
    A2 := AddScaled(X, Y, Z, zScale);
    A3.AddScaled(X, Y, Z, zScale);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;

Overload 11: function AddScaled(const X: TMtxVec; const xScale: Double; const Y: TMtxVec; const yScale: Double): TMtxVec;

Compute X*xScale + Y*yScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2xScaleDoublescalar
3YTMtxVecsource TVec or TMtx
4yScaleDoublescalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: Double; const Y: TMtxVec; YIndex: Integer; const yScale: Double; Index: Integer; Len: Integer): TMtxVec;

Compute X*xScale + Y*yScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3xScaleDoublescalar
4YTMtxVecsource TVec or TMtx
5YIndexIntegerY start index
6yScaleDoublescalar
7IndexIntegerstart index
8LenIntegerelement count

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

Overload 12: function AddScaled(const X: TMtxVec; const xScale: Double; const Y: TMtxVec; const yScale: Double; const Z: TMtxVec; const zScale: Double): TMtxVec;

Compute X*xScale + Y*yScale + Z*zScale

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2xScaleDoublescalar
3YTMtxVecsource TVec or TMtx
4yScaleDoublescalar
5ZTMtxVecsource TVec or TMtx
6zScaleDoublescalar

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

Indexed: function AddScaled(const X: TMtxVec; XIndex: Integer; const xScale: Double; const Y: TMtxVec; YIndex: Integer; const yScale: Double; const Z: TMtxVec; zIndex: Integer; const zScale: Double; Index: Integer; Len: Integer): TMtxVec;

Compute X*xScale + Y*yScale + Z*zScale on sub arrays

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexIntegerX start index
3xScaleDoublescalar
4YTMtxVecsource TVec or TMtx
5YIndexIntegerY start index
6yScaleDoublescalar
7ZTMtxVecsource TVec or TMtx
8zIndexInteger
9zScaleDoublescalar
10IndexIntegerstart index
11LenIntegerelement count

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

Overload 13: function AddScaled(const Vec: TMtxVec; const RScale: Double; const IScale: Double): TMtxVec;

Add each of Vec elements to corresponding elements in the calling object.

#NameTypeDescription
1VecTMtxVecsource TVec or TMtx
2RScaleDoublescalar
3IScaleDoublescalar

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

Remarks:

In addition, the following formula is being used:

result = result+ Cplx(RScale,IScale)*Vec .

When default values for parameters are being used the "normal" addition is being performed. The results are stored in the calling object. Size and TMtxVec.Complex properties of the calling object are set implicitly to match the Vec object.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, Z, A1, A2, A3: Vector;
    xScale, yScale, zScale: Double;
begin
    xScale := 1.0;
    yScale := 2.0;
    zScale := 3.0;
    X := [1,2,3,4];
    Y := [2,3,4,5];
    Z := [3,4,5,6];
    A1 := X * xScale + Y * yScale + Z * zScale;
    A2 := AddScaled(X, xScale, Y, yScale, Z, zScale);
    A3.AddScaled(X, xScale, Y, yScale, Z, zScale);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;