Overload List
Overload 1: TMtxVec *MulElem(TMtxVec *X, TMtxVec *Y, TMtxVec *Z) const;
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
#include "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Matrix A, B, C;
A = {{1, 2}, {2, 4}};
B = {{1, 2}, {2, 4}};
C.MulElem(A, B);
// C becomes:
// [1, 4,
// 4,16]
}
Overload 2: TMtxVec *MulElem(TMtxVec *X, TMtxVec *Y, const double Z) const;
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
#include "MtxExpr.h"
#include "Units.Math387.h"
#include "Units.MtxExpr.h"
#include "Units.MtxVec.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;
using namespace Dew::Math::Units::MtxExpr;
using namespace Dew::Math::Units::MtxVec;
void Example()
{
Vector X, Y, Z, A1, A2, A3;
X = {1, 2, 3, 4};
Y = {2, 3, 4, 5};
Z = {3, 4, 5, 6};
A1 = X * Y * Z;
A2 = MulElem(X, Y, Z);
A3.Mul(X, Y, Z);
if (!A2.IsEqual(A1))
ERaise("Problem");
if (!A3.IsEqual(A1))
ERaise("Problem");
}
Overload 3: TMtxVec *MulElem(TMtxVec *X, TMtxVec *Y, const TCplx &Z) const;
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
#include "MtxExpr.h"
#include "Units.Math387.h"
#include "Units.MtxExpr.h"
#include "Units.MtxVec.h"
using namespace Dew;
using namespace Dew::Math;
using namespace Dew::Math::Units::Math387;
using namespace Dew::Math::Units::MtxExpr;
using namespace Dew::Math::Units::MtxVec;
void Example()
{
Vector X, Y, A1, A2, A3;
double zScalar;
zScalar = 2.0;
X = {1, 2, 3, 4};
Y = {2, 3, 4, 5};
A1 = (X * Y) * zScalar;
A2 = MulElem(X, Y, zScalar);
A3.Mul(X, Y, zScalar);
if (!A2.IsEqual(A1))
ERaise("Problem");
if (!A3.IsEqual(A1))
ERaise("Problem");
}
Overload 4: TMtxVec *MulElem(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, TMtxVec *Z, int zIndex, int Index, int Len) const;
Compute X*Y*Z on sub array
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec * | |
| 2 | XIndex | int | |
| 3 | Y | TMtxVec * | |
| 4 | YIndex | int | |
| 5 | Z | TMtxVec * | |
| 6 | zIndex | int | |
| 7 | Index | int | |
| 8 | Len | int |
Overload 5: TMtxVec *MulElem(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, const double Z, int Index, int Len) const;
Compute X*Y*zScalar on sub array
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec * | |
| 2 | XIndex | int | |
| 3 | Y | TMtxVec * | |
| 4 | YIndex | int | |
| 5 | Z | const double | |
| 6 | Index | int | |
| 7 | Len | int |
Overload 6: TMtxVec *MulElem(TMtxVec *X, int XIndex, TMtxVec *Y, int YIndex, const TCplx &Z, int Index, int Len) const;
Compute X*Y*zScalar on sub array
| # | Name | Type | Description |
|---|---|---|---|
| 1 | X | TMtxVec * | |
| 2 | XIndex | int | |
| 3 | Y | TMtxVec * | |
| 4 | YIndex | int | |
| 5 | Z | const TCplx & | |
| 6 | Index | int | |
| 7 | Len | int |
Overload 7: TMtx *MulElem(TMtx *Mtx) const;
Matrix array 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 Matrix::Rows, Matrix::Cols and Matrix::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 "MtxExpr.h"
using namespace Dew;
using namespace Dew::Math;
void Example()
{
Matrix 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]
}
Overload 8: TMtx *MulElem(TMtx *Mtx1, TMtx *Mtx2) const;
Multiplies elements in Mtx1 matrix with the elements in Mtx2 matrix (array multiplication) and stores the results in calling matrix.
The Matrix::Rows, Matrix::Cols and 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.
#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");
}