Skip to content

Matrix and Vector Types

Matrix and Vector Types

  • Matrix and vector are special data types in MQL5 which enable linear algebra operations. The following data types exist:
  • matrix — a matrix containing double elements.
  • matrixf — a matrix containing float elements.
  • matrixc — a matrix containing complex elements.
  • vector — a vector containing double elements.
  • vectorf — a vector containing float elements.
  • vectorc — a vector containing complex elements.

Template functions support notations like matrix, matrix, vector, vector instead of the corresponding types.

Matrix and vector initialization methods

FunctionAction
EyeReturn a matrix with ones on the diagonal and zeros elsewhere
IdentityCreate an identity matrix of the specified size
OnesCreate and return a new matrix filled with ones
ZerosCreate and return a new matrix filled with zeros
FullCreate and return a new matrix filled with given value
TriConstruct a matrix with ones at and below the given diagonal and zeros elsewhere
InitInitialize a matrix or a vector
FillFill an existing matrix or vector with the specified value
Last updated on