Matrix.MulElem Method

Overload List

#SignatureDescription
1TMtx MulElem(TMtx Mtx)Matrix array 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.
3TMtxVec MulElem(TMtxVec X, TMtxVec Y, TCplx Z)self = X*Y*zScalar
└ indexed: TMtxVec MulElem(TMtxVec X, Int32 XIndex, TMtxVec Y, Int32 YIndex, TCplx Z, Int32 Index, Int32 Len)
4TMtxVec MulElem(TMtxVec X, TMtxVec Y, TMtxVec Z)self = X*Y*Z
└ indexed: TMtxVec MulElem(TMtxVec X, Int32 XIndex, TMtxVec Y, Int32 YIndex, TMtxVec Z, Int32 zIndex, Int32 Index, Int32 Len)
5TMtxVec MulElem(TMtxVec X, TMtxVec Y, Double Z)self = X*Y*zScalar
└ indexed: TMtxVec MulElem(TMtxVec X, Int32 XIndex, TMtxVec Y, Int32 YIndex, Double Z, Int32 Index, Int32 Len)

Overload 1: TMtx MulElem(TMtx Mtx)

Matrix array 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.Matrix.Rows, Dew.Math.Matrix.Cols and Dew.Math.Matrix.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");
Matrix A;
Matrix B;
Matrix C;
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]
See Also: Matrix.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.Matrix.Rows, Dew.Math.Matrix.Cols and Dew.Math.Matrix.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 exception is 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: TMtxVec 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

Indexed: TMtxVec MulElem(TMtxVec X, Int32 XIndex, TMtxVec Y, Int32 YIndex, TCplx Z, Int32 Index, Int32 Len)

Compute X*Y*zScalar on sub array

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexInt32X start index
3YTMtxVecsource TVec or TMtx
4YIndexInt32Y start index
5ZTCplxscalar
6IndexInt32start index
7LenInt32element count

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

Overload 4: TMtxVec 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

Indexed: TMtxVec MulElem(TMtxVec X, Int32 XIndex, TMtxVec Y, Int32 YIndex, TMtxVec Z, Int32 zIndex, Int32 Index, Int32 Len)

Compute X*Y*Z on sub array

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexInt32X start index
3YTMtxVecsource TVec or TMtx
4YIndexInt32Y start index
5ZTMtxVecsource TVec or TMtx
6zIndexInt32
7IndexInt32start index
8LenInt32element count

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

Overload 5: TMtxVec 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

Indexed: TMtxVec MulElem(TMtxVec X, Int32 XIndex, TMtxVec Y, Int32 YIndex, Double Z, Int32 Index, Int32 Len)

Compute X*Y*zScalar on sub array

#NameTypeDescription
1XTMtxVecsource TVec or TMtx
2XIndexInt32X start index
3YTMtxVecsource TVec or TMtx
4YIndexInt32Y start index
5ZDoublescalar
6IndexInt32start index
7LenInt32element count

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