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

Matrix multiplication.

Pascal
function Mul(const Mtx1: TMtx; const Mtx2: 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 and 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 Mtx2 with Mtx1 matrix and stores the results in the calling matrix. If Operation1 and/or Operation2 parameters are specified, perform additional operation on Mtx1 or Mtx2. If Operation1 and/or Operation2 parameters are omitted, the default values (no operation) will be used. The Rows, Cols and Complex properties of the calling matrix are adjusted automatically. An exception is raised is Mtx1 Cols property does not match the Mtx2 Rows property (matrix multiplication is not possible). An exception is raised, if Complex property of Mtx1 and Mtx2 does not match. 

Notes

  1. NOTE: 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.

  1. The routine is multithreaded, if specified by the environment variable.
var A,B,C: Matrix; begin A.SetIt(2,2,False,[1,2, 2,4]); B.SetIt(2,2,False,[1,2, 2,4]); C.Mul(A,B); //or C := Mul(a,b); // but this is not the same as: c := a*b; //which is the same as c.MulElem(A,B);s end;
Examples on GitHub
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!