Matrix.Divide Method

Overload List

#SignatureDescription
1function Divide(const X: TCplx; const Y: TMtxVec; const Z: TMtxVec): TMtxVec;self = xScalar / (Y*Z)
└ indexed: function Divide(const X: TCplx; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
2function Divide(const Vec: TMtxVec): TMtxVec;Divide each of calling Matrix elements with corresponding elements in the Vec object.
└ indexed: function Divide(const Vec: TMtxVec; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
3function Divide(Num: TMtxVec; Den: TMtxVec): TMtxVec;Divide each of Num elements with corresponding elements in Den.
4function Divide(const X: TMtxVec; const Y: TMtxVec; const Z: TMtxVec): TMtxVec;self = X / (Y*Z)
└ indexed: function Divide(const X: TMtxVec; XIndex: Integer; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
5function Divide(const Vec1: TMtxVec; const Vec2: TMtxVec; Threshold: Double): TMtxVec;Divide each of Vec1 elements with corresponding elements in the Vec2 object.
└ indexed: function Divide(const Vec1: TMtxVec; const Vec2: TMtxVec; Threshold: Double; Vec1Index: Integer; Vec2Index: Integer; Index: Integer; Len: Integer): TMtxVec;
6function Divide(const Vec: TMtxVec; Threshold: Double): TMtxVec;Matrix division.
└ indexed: function Divide(const Vec: TMtxVec; Threshold: Double; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
7function Divide(const X: Double; const Y: TMtxVec; const Z: TMtxVec): TMtxVec;self = xScalar / (Y*Z)
└ indexed: function Divide(const X: Double; const Y: TMtxVec; YIndex: Integer; const Z: TMtxVec; zIndex: Integer; Index: Integer; Len: Integer): TMtxVec;
8function Divide(Num: TMtxVec; Den: TMtxVec; NumIndex: Integer; DenIndex: Integer; Index: Integer; Len: Integer): TMtxVec;Divide [NumIndex]..[NumIndex+Len-1] Num elements with [DenIndex]..[DenIndex+Len-1] elements in Den.

Overload 1: function Divide(const X: TCplx; const Y: TMtxVec; const Z: TMtxVec): TMtxVec;

Compute xScalar / (Y*Z)

#NameTypeDescription
1XTCplx
2YTMtxVec
3ZTMtxVec

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

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

Compute xScalar / (Y*Z) on sub array

#NameTypeDescription
1XTCplx
2YTMtxVec
3YIndexIntegerY start index
4ZTMtxVec
5zIndexInteger
6IndexIntegerstart index
7LenIntegerelement count

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

Overload 2: function Divide(const Vec: TMtxVec): TMtxVec;

Divide each of calling Matrix elements with corresponding elements in the Vec object.

#NameTypeDescription
1VecTMtxVec

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

Remarks:

Size and Matrix.Complex property of the calling object are set automatically. The result is stored in the calling object.

Note
The result of division by zero will be the INF constant. Division of zero by zero will result in NAN.

Examples
var
    a, b, expected: Matrix;
begin
    a := [[1.0, 2.0], [3.0, 4.0]];
    b := [[5.0, 6.0], [7.0, 8.0]];
    a.Divide(b);
    expected := [[0.2, 0.333333333333333], [0.428571428571429, 0.5]];
    if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
        raise Exception.Create('Matrix.Divide: mismatch');
end;

Indexed: function Divide(const Vec: TMtxVec; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Divide calling Matrix elements [Index]...[Index+Len-1] with corresponding elements [VecIndex]...[VecIndex+Len-1] from the Vec object.

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

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

Remarks:

Store the result in the claling Matrix. The Matrix.Length of the calling Matrix is not changed. An exception is raised if Matrix.ConditionCheck is True and array borders are overrun or underrun.

Note
The result of division by zero will be the INF constant. Division of zero by zero will result in NAN.

Overload 3: function Divide(Num: TMtxVec; Den: TMtxVec): TMtxVec;

Divide each of Num elements with corresponding elements in Den.

#NameTypeDescription
1NumTMtxVecsource TVec or TMtx
2DenTMtxVecsource TVec or TMtx

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

Remarks:

Size and Matrix.Complex property of the calling object are set automatically. The result is stored in the calling object.

Note
The result of division by zero will be the INF constant. Division of zero by zero will result in NAN.

Examples
var
    a, x, y, expected: Matrix;
begin
    x := [[1.0, 2.0], [3.0, 4.0]];
    y := [[5.0, 6.0], [7.0, 8.0]];
    a.Divide(x, y);
    expected := [[0.2, 0.333333333333333], [0.428571428571429, 0.5]];
    if not a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute) then
        raise Exception.Create('Matrix.Divide: mismatch');
end;

Overload 4: function Divide(const X: TMtxVec; const Y: TMtxVec; const Z: TMtxVec): TMtxVec;

Compute X / (Y*Z)

#NameTypeDescription
1XTMtxVec
2YTMtxVec
3ZTMtxVec

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

Remarks:

The following expression would also run at the same or higher speed, when passing Y also for the Z parameter:

X / (Y^2)

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

Compute X/( Y*Z ) on sub array

#NameTypeDescription
1XTMtxVec
2XIndexIntegerX start index
3YTMtxVec
4YIndexIntegerY start index
5ZTMtxVec
6zIndexInteger
7IndexIntegerstart index
8LenIntegerelement count

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

Overload 5: function Divide(const Vec1: TMtxVec; const Vec2: TMtxVec; Threshold: Double): TMtxVec;

Divide each of Vec1 elements with corresponding elements in the Vec2 object.

#NameTypeDescription
1Vec1TMtxVec
2Vec2TMtxVec
3ThresholdDoublescalar

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

Remarks:

Store the result in the calling Matrix.

Indexed: function Divide(const Vec1: TMtxVec; const Vec2: TMtxVec; Threshold: Double; Vec1Index: Integer; Vec2Index: Integer; Index: Integer; Len: Integer): TMtxVec;

Divide Vec1 elements [Vec1Index]...[Vec1Index+Len-1] with corresponding elements [Vec2Index]...[Vec2Index+Len-1] from the Vec object.

#NameTypeDescription
1Vec1TMtxVec
2Vec2TMtxVec
3ThresholdDoublescalar
4Vec1IndexInteger
5Vec2IndexInteger
6IndexIntegerstart index
7LenIntegerelement count

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

Remarks:

Store the result in the calling Matrix [Index]...[Index+Len-1].

Overload 6: function Divide(const Vec: TMtxVec; Threshold: Double): TMtxVec;

Matrix division.

#NameTypeDescription
1VecTMtxVec
2ThresholdDoublescalar

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

Remarks:

Divide each of Vec elements with corresponding elements in the calling object. Size and Matrix.Complex property of the calling object are set automatically. The result is stored in the calling object.

The threshold parameter is used to prevent against division by zero and numerical instabilities in the follow on processing. All values of Vec smaller than Threshold will be replaced with Threshold.

See Also: Matrix.Mul

Indexed: function Divide(const Vec: TMtxVec; Threshold: Double; VecIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Divide each of Vec elements with corresponding elements in the calling object.

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

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

Remarks:

Store the result in the calling object. Size and Matrix.Complex property of the calling object are set automatically.

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

Compute xScalar / (Y*Z)

#NameTypeDescription
1XDouble
2YTMtxVec
3ZTMtxVec

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

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

Compute xScalar / (Y*Z) on sub array

#NameTypeDescription
1XDouble
2YTMtxVec
3YIndexIntegerY start index
4ZTMtxVec
5zIndexInteger
6IndexIntegerstart index
7LenIntegerelement count

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

Overload 8: function Divide(Num: TMtxVec; Den: TMtxVec; NumIndex: Integer; DenIndex: Integer; Index: Integer; Len: Integer): TMtxVec;

Divide [NumIndex]..[NumIndex+Len-1] Num elements with [DenIndex]..[DenIndex+Len-1] elements in Den.

#NameTypeDescription
1NumTMtxVecsource TVec or TMtx
2DenTMtxVecsource TVec or TMtx
3NumIndexInteger
4DenIndexInteger
5IndexIntegerstart index
6LenIntegerelement count

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

Remarks:

Store result in the calling Matrix at positions [Index]..[Index+Len-1] Matrix.Size and Matrix.Complex property of the calling object are not changed. An exception is raised if Matrix.ConditionCheck is True and array borders are overrun or underrun.

Note
The result of division by zero will be the INF constant. Division of zero by zero will result in NAN.