Overload List
| # | Signature | Description |
|---|---|---|
| 1 | TMtx *MulElem(TMtx *Mtx); | Matrix element-wise multiplication. |
| 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. |
| 3 | TMtx *MulElem(TMtxVec *X, TMtxVec *Y, TMtxVec *Z); | Compute X*Y*Z |
| 4 | TMtx *MulElem(TMtxVec *X, TMtxVec *Y, const double Z); | Compute X*Y*zScalar |
| 5 | TMtx *MulElem(TMtxVec *X, TMtxVec *Y, const TCplx &Z); | Compute X*Y*zScalar |
Overload 1: TMtx *MulElem(TMtx *Mtx);
Matrix element-wise multiplication.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Mtx | TMtx * |
Multiplies elements in Mtx matrix with the elements in the calling matrix (array multiplication) and stores the results in calling matrix. The TMtx::Rows, TMtx::Cols and TMtx::Complex properties of both matrices must match, otherwise an exception is raised.
#include "Math387.h"
#include "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Matrix a;
a.SetIt(2, 2, false, DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
Matrix b;
b.SetIt(2, 2, false, DewArray<double>{ 5.0, 6.0, 7.0, 8.0 });
a.MulElem(b);
Matrix expected;
expected.SetIt(2, 2, false, DewArray<double>{ 5.0, 12.0, 21.0, 32.0 });
if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
throw tException("Matrix.MulElem: mismatch");
}
#include "MtxVec.h"
#include "Units.MtxVec.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::MtxVec;
void Example()
{
TMtx *A, *B, *C;
CreateIt(A, B, C);
A->SetIt(2, 2, false, DewArray<double>{1, 2, 2, 4});
B->SetIt(2, 2, false, DewArray<double>{1, 2, 2, 4});
C->MulElem(A, B);
// C becomes:
// [1, 4,
// 4,16]
FreeIt(A, B, C);
}
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.
The TMtx::Rows, TMtx::Cols and TMtx::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.
#include "Math387.h"
#include "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Matrix a;
Matrix x;
x.SetIt(2, 2, false, DewArray<double>{ 1.0, 2.0, 3.0, 4.0 });
Matrix y;
y.SetIt(2, 2, false, DewArray<double>{ 5.0, 6.0, 7.0, 8.0 });
a.MulElem(x, y);
Matrix expected;
expected.SetIt(2, 2, false, DewArray<double>{ 5.0, 12.0, 21.0, 32.0 });
if (!a.IsEqual(expected, 1e-10, TCompare::cmpAbsolute))
throw tException("Matrix.MulElem: mismatch");
}
Overload 3: TMtx *MulElem(TMtxVec *X, TMtxVec *Y, TMtxVec *Z);
Compute X*Y*Z
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec * | |
| 2 | Y | TMtxVec * | |
| 3 | Z | TMtxVec * |
The following expression would also run at the same or higher speed, when passing X also for the Z parameter:
X^2*Y
Overload 4: TMtx *MulElem(TMtxVec *X, TMtxVec *Y, const double Z);
Compute X*Y*zScalar
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec * | |
| 2 | Y | TMtxVec * | |
| 3 | Z | const double |
The following expression would also run at the same or higher speed, when passing X also for the Z parameter:
X^2*zScalar
Overload 5: TMtx *MulElem(TMtxVec *X, TMtxVec *Y, const TCplx &Z);
Compute X*Y*zScalar
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec * | |
| 2 | Y | TMtxVec * | |
| 3 | Z | const TCplx & |
The following expression would also run at the same or higher speed, when passing X also for the Z parameter:
X^2*zScalar