Overload List
| # | Signature | Description |
|---|---|---|
| 1 | TVec TensorProd(TMtx Mtx, TVec Vec, TMtxType MtxType, TMtxOperation Operation) | Tensor product between vector and matrix. |
| 2 | TVec TensorProd(TVec Vec, TMtx Mtx, TMtxType MtxType, TMtxOperation Operation) | Calculates the left tensor product between vector and matrix. |
Overload 1: TVec TensorProd(TMtx Mtx, TVec Vec, TMtxType MtxType, TMtxOperation Operation)
Tensor product between vector and matrix.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Mtx | TMtx | source TMtx |
| 2 | Vec | TVec | source TVec |
| 3 | MtxType | TMtxType | |
| 4 | Operation | TMtxOperation |
Result: stored in self (calling object), returns self for chaining
Calculates the right tensor product between matrix and vector. The result is placed in the calling vector. Depending on the Dew.Math.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 Dew.Math.Vector.Alfa and Dew.Math.Vector.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.
Matrix a;
Matrix b;
Matrix c;
Matrix t;
Vector d;
Vector e;
Vector f;
// Test non quadratic general matrix
a.SetIt(2,3,false,[4,3,3,
3,4,2]);
e.SetIt(false,new double[] {1,2});
d.TensorProd(e,a);
f.SetIt(false,new double[] {10,11,7});
if !f.Equal(d) then raise Exception.Create(@"Not same");
// Test on triangular matrices, left
a.TriangleForm = tfUpper;
a.TriangleUnit = false;
a.SetIt(2,2,false,[4,3,
0,4]);
e.SetIt(false,new double[] {1,2});
d.TensorProd(e,a,mtTriangle);
f.SetIt(false,new double[] {4,11});
if !f.Equal(d) then raise Exception.Create(@"Not same");
// Test on triangular matrices, right
a.Reset;
a.TriangleForm = tfUpper; // data to be referenced is in upper triangle
a.TriangleUnit = false; // non unit diagonal
a.SetIt(2,2,false,[4,3,
0,4]);
e.SetIt(false,new double[] {1,2});
d.TensorProd(a,e,mtTriangle);
f.SetIt(false,new double[] {10,8});
if !f.Equal(d) then raise Exception.Create(@"Not same");
// Test on symmetric matrices, right
a.Reset;
a.TriangleForm = tfUpper;
a.SetIt(2,2,false,[4,3,
3,4]);
e.SetIt(false,new double[] {1,2});
d.TensorProd(e,a,mtSymmetric);
f.SetIt(false,new double[] {10,11});
if !f.Equal(d) then raise Exception.Create(@"Not same");
// Test on symmetric matrices, Left
a.Reset;
a.TriangleForm = tfUpper;
a.SetIt(2,2,false,[4,3,
3,4]);
e.SetIt(false,new double[] {1,2});
d.TensorProd(a,e,mtSymmetric);
f.SetIt(false,new double[] {10,11});
if !f.Equal(d) then raise Exception.Create(@"Not same");
Overload 2: TVec TensorProd(TVec Vec, TMtx Mtx, TMtxType MtxType, TMtxOperation Operation)
Calculates the left tensor product between vector and matrix.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Vec | TVec | source TVec |
| 2 | Mtx | TMtx | source TMtx |
| 3 | MtxType | TMtxType | |
| 4 | Operation | TMtxOperation |
Result: stored in self (calling object), returns self for chaining