You are here: Symbol Reference > MtxVec Namespace > Classes > TVec Class > public > TensorProd Method > TVec.TensorProd Method (TMtx, TVec, TMtxType, TMtxOperation)
MtxVec VCL
ContentsIndex
PreviousUpNext
TVec.TensorProd Method (TMtx, TVec, TMtxType, TMtxOperation)

Tensor product between vector and matrix.

Pascal
function TensorProd(const Mtx: TMtx; const Vec: TVec; MtxType: TMtxType = mtGeneral; Operation: TMtxOperation = opNone): TVec; overload;

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 TMtxVec.Alfa and TMtxVec.Beta are TVec complex public variables. Their default values are: 

 

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.

var a,b,c,t: TMtx; d,e,f: TVec; begin CreateIt(a,b,c,t); CreateIt(d,e,f); try // Test non quadratic general matrix a.SetIt(2,3,False,[4,3,3, 3,4,2]); e.SetIt(false,[1,2]); d.TensorProd(e,a); f.SetIt(False,[10,11,7]); if not 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,[1,2]); d.TensorProd(e,a,mtTriangle); f.SetIt(False,[4,11]); if not f.Equal(d) then raise Exception.Create('Not same'); // Test on triangular matrices, right 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,[1,2]); d.TensorProd(a,e,mtTriangle); f.SetIt(False,[10,8]); if not f.Equal(d) then raise Exception.Create('Not same'); // Test on symmetric matrices, right a.TriangleForm := tfUpper; a.SetIt(2,2,False,[4,3, 3,4]); e.SetIt(false,[1,2]); d.TensorProd(e,a,mtSymmetric); f.SetIt(False,[10,11]); if not f.Equal(d) then raise Exception.Create('Not same'); // Test on symmetric matrices, Left a.TriangleForm := tfUpper; a.SetIt(2,2,False,[4,3, 3,4]); e.SetIt(false,[1,2]); d.TensorProd(a,e,mtSymmetric); f.SetIt(False,[10,11]); if not f.Equal(d) then raise Exception.Create('Not same'); finally FreeIt(a,b,c,t); FreeIt(d,e,f); end; end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!