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

Matrix multiplication.

Pascal
function Mul(const A: TMtx; const B: TMtx): TMtx; overload;

Performs matrix multiplication. In most general case the matrix multiplication is defined by the following equation (result = calling matrix): 

 

 

where a and b are TMtxVec.Alfa and TMtxVec.Beta variables. The default values for a and b are Cplx(1,0) and Cplx(0,0), so the above equation is reduced to: 

 

 

The Operation1 and Operation2 indicate additional TMtxOperation, performed on Mtx1 and Mtx2 respectively. Default value for operation is opNone (no additional operation). The Mtx1Type and Mtx2Type parameters indicate the TMtxType of Mtx1 and Mtx2 matrices. Depending what type of matrices you are multiplying, the Mul method will choose most optimized multiplication method. So, choosing the correct values for Mtx1Type and Mtx2Type can significantly speed up the multiplication. 

This overloaded function performs a left side multiply operation B with A matrix and stores the results in the calling matrix. If Operation1 and/or Operation2 parameters are specified, perform additional operation on A or B. If Operation1 and/or Operation2 parameters are omitted, the default values (no operation) will be used. The Rows, Cols and TMtxVec.ComplexComplexproperties of the calling matrix are adjusted automatically. An exception is raised is A Cols property does not match the B Rows property (matrix multiplication is not possible). An exception is raised, if TMtxVec.ComplexComplexproperty of A and B does not match.

  • If you are not sure, which TMtxType of matrix are you multiplying, you can use the mtGeneral type (general case).
  • You can also use the DetectMtxType method to determine the type of matrix.
  • The routine is multithreaded, if specified by the environment variable.
var A,B,C: TMtx; begin CreateIt(A,B,C); try A.SetIt(2,2,False,[1,2, 2,4]); B.SetIt(2,2,False,[1,2, 2,4]); C.Mul(A,B); finally FreeIt(A,B,C); end; end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!