TMtx *AddTensorProd(TVec *Vec1, TVec *Vec2, bool ConjVec2 = false);
Calculates the tensor product of two vectors and adds the result to calling matrix.
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 TMtx::Rows property is set to Vec1. TMtx::Length and TMtx::Cols property is set to Vec2. TMtx::Length and TMtx::Complex property of the calling matrix is adjusted automatically.
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;
TVec *v1, *v2;
CreateIt(a, b);
CreateIt(v1, v2);
// Test non quadratic general matrix
a->SetIt(2, 2, false, DewArray<double>{0, 2, 2, 0});
v1->SetIt(false, DewArray<double>{1, 0});
v2->SetIt(false, DewArray<double>{0, 1});
a->AddTensorProd(v1, v2, false);
b->SetIt(2, 2, false, DewArray<double>{0, 3, 2, 0});
if (!a->Equal(b)) throw tException("Not same");
FreeIt(a, b);
FreeIt(v1, v2);
}
See Also: TMtx::TensorProd
Declared in Dew::Math::TMtx · Dew.Math/MtxVec.h · Cross-compiler