TMtx AddTensorProd(TVec Vec1, TVec Vec2, Boolean ConjVec2)
Calculates the tensor product of two vectors and adds the result to calling matrix.
Result: stored in self (calling object), returns self for chaining
Remarks:
Calculates the tensor product of Vec1 and Vec2 vectors and adds the result to the calling matrix by using the following formula:
Y=Vec1 x Vec2 + Y.
If the ConjVec2 parameter is true, then the result will be tensor product of Vec1 and conjugated Vec2. The Dew.Math.TMtx.Rows property is set to Vec1. Dew.Math.TMtxVecBase.Length and Dew.Math.TMtx.Cols property is set to Vec2. Dew.Math.TMtxVecBase.Length and Dew.Math.TMtxVec.Complex property of the calling matrix is adjusted automatically.
Examples
TMtx a;
TMtx b;
TVec v1;
TVec v2;
MtxVec.CreateIt(out a, out b);
MtxVec.CreateIt(out v1, out v2);
try
{
// Test non quadratic general matrix
a.SetIt(2,2,false,new double[] {0,2,2,0});
v1.SetIt(false,new double[] {1,0});
v2.setIt(false,new double[] {0,1});
a.AddTensorProd(v1,v2,false);
b.SetIt(false,new double[] {1,2,2,1});
if !a.Equal(b) then raise Exception.Create(@"Not same");
}
finally
{
MtxVec.FreeIt(ref a, ref b);
MtxVec.FreeIt(ref v1, ref v2);
}
See Also: TMtx.TensorProd