Overload List
| # | Signature | Description |
|---|---|---|
| 1 | TVec *TensorProd(TMtx *Mtx, TVec *Vec, TMtxType MtxType = TMtxType::mtGeneral, TMtxOperation Operation = TMtxOperation::opNone); | Tensor product between vector and matrix. |
| 2 | TVec *TensorProd(TVec *Vec, TMtx *Mtx, TMtxType MtxType = TMtxType::mtGeneral, TMtxOperation Operation = TMtxOperation::opNone); | Calculates the left tensor product between vector and matrix. |
Overload 1: TVec *TensorProd(TMtx *Mtx, TVec *Vec, TMtxType MtxType = TMtxType::mtGeneral, TMtxOperation Operation = TMtxOperation::opNone);
Tensor product between vector and matrix.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Mtx | TMtx * | |
| 2 | Vec | TVec * | |
| 3 | MtxType = TMtxType::mtGeneral | TMtxType | |
| 4 | Operation = TMtxOperation::opNone | TMtxOperation |
Remarks:
Calculates the right tensor product between matrix and vector. The result is placed in the calling vector. Depending on the TMtxType the following operations are available:
- mtSymmetric:
y = alfa*a*x + beta*y - mtSymmPosDef:
y = alfa*a*x + beta*y - mtHermitian:
y = alfa*a*x + beta*y - mtHermPosDef:
y = alfa*a*x + beta*y - mtTriangular:
y = op(a)*x - mtGeneral:
y = alfa*op(a)*x + beta*y
The TVec::Alfa and TVec::Beta are TVec complex public variables. Their default values are:
- Alfa = Cplx(1,0)
- Beta = Cplx(0,0).
Note
Each time you call TensorProd the values of Alfa and Beta are reset to default. If the matrix is not complex, only the real part of Alfa and Beta is used. If matrix complex and symmetric the general type is used.
Examples
#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, *t;
TVec *d, *e, *f;
CreateIt(a, b, c, t);
CreateIt(d, e, f);
// Test non quadratic general matrix
a->SetIt(2, 3, false, DewArray<double>{4, 3, 3, 3, 4, 2});
e->SetIt(false, DewArray<double>{1, 2});
d->TensorProd(e, a);
f->SetIt(false, DewArray<double>{10, 11, 7});
if (!f->Equal(d))
throw tException("Not same");
// Test on triangular matrices, left
a->TriangleForm = TTriangleForm::tfUpper;
a->TriangleUnit = false;
a->SetIt(2, 2, false, DewArray<double>{4, 3, 0, 4});
e->SetIt(false, DewArray<double>{1, 2});
d->TensorProd(e, a, TMtxType::mtTriangle);
f->SetIt(false, DewArray<double>{4, 11});
if (!f->Equal(d))
throw tException("Not same");
// Test on triangular matrices, right
a->TriangleForm = TTriangleForm::tfUpper; // data to be referenced is in upper triangle
a->TriangleUnit = false; // non unit diagonal
a->SetIt(2, 2, false, DewArray<double>{4, 3, 0, 4});
e->SetIt(false, DewArray<double>{1, 2});
d->TensorProd(a, e, TMtxType::mtTriangle);
f->SetIt(false, DewArray<double>{10, 8});
if (!f->Equal(d))
throw tException("Not same");
// Test on symmetric matrices, right
a->TriangleForm = TTriangleForm::tfUpper;
a->SetIt(2, 2, false, DewArray<double>{4, 3, 3, 4});
e->SetIt(false, DewArray<double>{1, 2});
d->TensorProd(e, a, TMtxType::mtSymmetric);
f->SetIt(false, DewArray<double>{10, 11});
if (!f->Equal(d))
throw tException("Not same");
// Test on symmetric matrices, Left
a->TriangleForm = TTriangleForm::tfUpper;
a->SetIt(2, 2, false, DewArray<double>{4, 3, 3, 4});
e->SetIt(false, DewArray<double>{1, 2});
d->TensorProd(a, e, TMtxType::mtSymmetric);
f->SetIt(false, DewArray<double>{10, 11});
if (!f->Equal(d))
throw tException("Not same");
FreeIt(a, b, c, t);
FreeIt(d, e, f);
}
See Also: TMtx::TensorProd
Declared in Dew::Math::TVec · Dew.Math/MtxVec.h · Cross-compiler
Overload 2: TVec *TensorProd(TVec *Vec, TMtx *Mtx, TMtxType MtxType = TMtxType::mtGeneral, TMtxOperation Operation = TMtxOperation::opNone);
Calculates the left tensor product between vector and matrix.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec | TVec * | |
| 2 | Mtx | TMtx * | |
| 3 | MtxType = TMtxType::mtGeneral | TMtxType | |
| 4 | Operation = TMtxOperation::opNone | TMtxOperation |
Declared in Dew::Math::TVec · Dew.Math/MtxVec.h · Cross-compiler