MtxExpr.MulAndAdd Method

Overload List

#SignatureDescription
1function MulAndAdd(const X: TMtx; const Y: TCplx; const Z: TCplx): Matrix;Result = (X*yScalar) + zScalar, where X is a Matrix
2function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: TCplx; const Z: TCplx): Matrix;Result = (X*Y)*xyScale + zScalar, where X is a Matrix
3function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: TCplx; const Z: TMtxVec; const zScale: TCplx): Matrix;Result = (X*Y)*xyScale + Z*zScale, where X is a Matrix
4function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: Double; const Z: TMtxVec; const zScale: Double): Matrix;Result = (X*Y)*xyScale + Z*zScale, where X is a Matrix
5function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: Double; const Z: Double): Matrix;Result = (X*Y)*xyScale + zScalar, where X is a Matrix
6function MulAndAdd(const X: TMtx; const Y: Double; const Z: Double): Matrix;Result = (X*yScalar) + zScalar, where X is a Matrix
7function MulAndAdd(const X: TVec; const Y: TCplx; const Z: TCplx): Vector;Result = (X*yScalar) + zScalar, where X is a Matrix
8function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: TCplx; const Z: TCplx): Vector;Result = (X*Y)*xyScale + zScalar
9function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: TCplx; const Z: TMtxVec; const zScale: TCplx): Vector;Result = (X*Y)*xyScale + Z*zScale
10function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: Double; const Z: TMtxVec; const zScale: Double): Vector;Result = (X*Y)*xyScale + Z*zScale
11function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: Double; const Z: Double): Vector;Result = (X*Y)*xyScale + zScalar
12function MulAndAdd(const X: TVec; const Y: Double; const Z: Double): Vector;Result = (X*yScalar) + zScalar

Overload 1: function MulAndAdd(const X: TMtx; const Y: TCplx; const Z: TCplx): Matrix;

Compute (X*yScalar) + zScalar, where X is a Matrix.

#NameTypeDescription
1XTMtx
2YTCplx
3ZTCplx

Returns: Matrix

Overload 2: function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: TCplx; const Z: TCplx): Matrix;

Compute (X*Y)*xyScale + zScalar, where X is a Matrix.

#NameTypeDescription
1XTMtx
2YTMtxVec
3xyScaleTCplx
4ZTCplx

Returns: Matrix

Remarks:

The operation does only per-element math.

Overload 3: function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: TCplx; const Z: TMtxVec; const zScale: TCplx): Matrix;

Compute (X*Y)*xyScale + Z*zScale, where X is a Matrix.

#NameTypeDescription
1XTMtx
2YTMtxVec
3xyScaleTCplx
4ZTMtxVec
5zScaleTCplx

Returns: Matrix

Remarks:

The operation does only per-element math.

Overload 4: function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: Double; const Z: TMtxVec; const zScale: Double): Matrix;

Compute (X*Y)*xyScale + Z*zScale, where X is a Matrix.

#NameTypeDescription
1XTMtx
2YTMtxVec
3xyScaleDouble
4ZTMtxVec
5zScaleDouble

Returns: Matrix

Remarks:

The operation does only per-element math.

Overload 5: function MulAndAdd(const X: TMtx; const Y: TMtxVec; const xyScale: Double; const Z: Double): Matrix;

Compute (X*Y)*xyScale + zScalar, where X is a Matrix.

#NameTypeDescription
1XTMtx
2YTMtxVec
3xyScaleDouble
4ZDouble

Returns: Matrix

Remarks:

The operation does only per-element math.

Overload 6: function MulAndAdd(const X: TMtx; const Y: Double; const Z: Double): Matrix;

Compute (X*yScalar) + zScalar, where X is a Matrix.

#NameTypeDescription
1XTMtx
2YDouble
3ZDouble

Returns: Matrix

Overload 7: function MulAndAdd(const X: TVec; const Y: TCplx; const Z: TCplx): Vector;

Compute (X*yScalar) + zScalar, where X is a Matrix.

#NameTypeDescription
1XTVec
2YTCplx
3ZTCplx

Returns: Vector

Overload 8: function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: TCplx; const Z: TCplx): Vector;

Compute (X*Y)*xyScale + zScalar

#NameTypeDescription
1XTVec
2YTMtxVec
3xyScaleTCplx
4ZTCplx

Returns: Vector

Remarks:

The operation does only per-element math.

Overload 9: function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: TCplx; const Z: TMtxVec; const zScale: TCplx): Vector;

Compute (X*Y)*xyScale + Z*zScale.

#NameTypeDescription
1XTVec
2YTMtxVec
3xyScaleTCplx
4ZTMtxVec
5zScaleTCplx

Returns: Vector

Remarks:

The operation does only per-element math.

Overload 10: function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: Double; const Z: TMtxVec; const zScale: Double): Vector;

Compute (X*Y)*xyScale + Z*zScale

#NameTypeDescription
1XTVec
2YTMtxVec
3xyScaleDouble
4ZTMtxVec
5zScaleDouble

Returns: Vector

Remarks:

Computes the product of X and Y scaled by xyScale, and then adds Z scaled by zScale, without creating temporary objects.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, Z, A1, A2, A3: Vector;
    xyScale, zScale: Double;
begin
    xyScale := 1.5;
    zScale  := 2.0;
    X := [2,4,6,8];
    Y := [1,1,1,1];
    Z := [3,4,5,6];
    A1 := (X * Y * xyScale) + (Z * zScale);
    A2 := MulAndAdd(X, xyScale, Y, xyScale, Z, zScale);  // Note: Overload uses given scales
    A3.MulAndAdd(X, xyScale, Y, xyScale, Z, zScale);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;

Overload 11: function MulAndAdd(const X: TVec; const Y: TMtxVec; const xyScale: Double; const Z: Double): Vector;

Compute (X*Y)*xyScale + zScalar

#NameTypeDescription
1XTVec
2YTMtxVec
3xyScaleDouble
4ZDouble

Returns: Vector

Remarks:

Computes the product of X and Y scaled by xyScale, then adds a scalar zScalar, without creating temporary objects.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, Y, A1, A2, A3: Vector;
    xyScale, zScalar: Double;
begin
    xyScale := 1.5;
    zScalar := 2.0;
    X := [2,4,6,8];
    Y := [1,1,1,1];
    A1 := (X * Y * xyScale) + zScalar;
    A2 := MulAndAdd(X, xyScale, Y, xyScale, zScalar);
    A3.MulAndAdd(X, xyScale, Y, xyScale, zScalar);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;

Overload 12: function MulAndAdd(const X: TVec; const Y: Double; const Z: Double): Vector;

Compute (X*yScalar) + zScalar

#NameTypeDescription
1XTVec
2YDouble
3ZDouble

Returns: Vector

Remarks:

Computes the result of multiplying X by a scalar yScalar and then adding a scalar zScalar, without creating temporary objects.

Examples
uses MtxVec, MtxExpr, Math387;

var
    X, A1, A2, A3: Vector;
    yScalar, zScalar: Double;
begin
    yScalar := 2.0;
    zScalar := 3.0;
    X := [2,4,6,8];
    A1 := (X * yScalar) + zScalar;
    A2 := MulAndAdd(X, yScalar, zScalar);
    A3.MulAndAdd(X, yScalar, zScalar);
    if not A2.IsEqual(A1) then ERaise('Problem');
    if not A3.IsEqual(A1) then ERaise('Problem');
end;