TMtx.MulElem Method

Overload List

#SignatureDescription
1TMtx MulElem(TMtx Mtx)Matrix element-wise multiplication.
2TMtx MulElem(TMtx Mtx1, TMtx Mtx2)Multiplies elements in Mtx1 matrix with the elements in Mtx2 matrix (array multiplication) and stores the results in calling matrix.
3TMtx MulElem(TMtxVec X, TMtxVec Y, TCplx Z)self = X*Y*zScalar
4TMtx MulElem(TMtxVec X, TMtxVec Y, TMtxVec Z)self = X*Y*Z
5TMtx MulElem(TMtxVec X, TMtxVec Y, Double Z)self = X*Y*zScalar

Overload 1: TMtx MulElem(TMtx Mtx)

Matrix element-wise multiplication.

#NameTypeDescription
1MtxTMtxsource TMtx

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

Remarks:

Multiplies elements in Mtx matrix with the elements in the calling matrix (array multiplication) and stores the results in calling matrix. The Dew.Math.TMtx.Rows, Dew.Math.TMtx.Cols and Dew.Math.TMtxVec.Complex properties of both matrices must match, otherwise an exception is raised.

Examples
Matrix a = new Matrix();
a.SetIt(2, 2, false, new double[] { 1.0, 2.0, 3.0, 4.0 });
Matrix b = new Matrix();
b.SetIt(2, 2, false, new double[] { 5.0, 6.0, 7.0, 8.0 });
a.MulElem(b);
Matrix expected = new Matrix();
expected.SetIt(2, 2, false, new double[] { 5.0, 12.0, 21.0, 32.0 });
if (!a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute))
    throw new Exception("Matrix.MulElem: mismatch");
TMtx A;
TMtx B;
TMtx C;
MtxVec.CreateIt(out A, out B, out C);
try
    {
        A.SetIt(2,2,false,[1,2,
        2,4]);
        B.SetIt(2,2,false,[1,2,
        2,4]);
        C.MulElem(A,B);
        // C becomes:
        // [1, 4,
        //  4,16]
    }
finally
    {
        MtxVec.FreeIt(ref A, ref B, ref C);
    }
See Also: TMtx.InvElem

Overload 2: TMtx MulElem(TMtx Mtx1, TMtx Mtx2)

Multiplies elements in Mtx1 matrix with the elements in Mtx2 matrix (array multiplication) and stores the results in calling matrix.

#NameTypeDescription
1Mtx1TMtxsource TMtx
2Mtx2TMtxsource TMtx

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

Remarks:

The Dew.Math.TMtx.Rows, Dew.Math.TMtx.Cols and Dew.Math.TMtxVec.Complex properties of calling matrix are set implicitly to match those of Mtx1 and Mtx2 matrices. Mtx1 and Mtx2 Rows, Cols, and Complex properties must be the same, otherwise an excetion is raised. raised.

Examples
Matrix a = new Matrix();
Matrix x = new Matrix();
x.SetIt(2, 2, false, new double[] { 1.0, 2.0, 3.0, 4.0 });
Matrix y = new Matrix();
y.SetIt(2, 2, false, new double[] { 5.0, 6.0, 7.0, 8.0 });
a.MulElem(x, y);
Matrix expected = new Matrix();
expected.SetIt(2, 2, false, new double[] { 5.0, 12.0, 21.0, 32.0 });
if (!a.IsEqual(expected, 1e-10, TCompare.cmpAbsolute))
    throw new Exception("Matrix.MulElem: mismatch");

Overload 3: TMtx MulElem(TMtxVec X, TMtxVec Y, TCplx Z)

Compute X*Y*zScalar

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

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 X also for the Z parameter:

X^2*zScalar

Overload 4: TMtx MulElem(TMtxVec X, TMtxVec Y, TMtxVec Z)

Compute X*Y*Z

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

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 X also for the Z parameter:

X^2*Y

Overload 5: TMtx MulElem(TMtxVec X, TMtxVec Y, Double Z)

Compute X*Y*zScalar

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

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 X also for the Z parameter:

X^2*zScalar