- Matrix and Vector Types
- Initialization
- Manipulations
- Operations
- Products
- Transformations
- Statistics
- Features
- Solutions
- Machine learning
- OpenBLAS
Matrices and vectors
A matrix is a two-dimensional array of double, float, or complex numbers.
A vector is a one-dimensional array of double, float, or complex numbers. The vector has no indication of whether it is vertical or horizontal. It is determined from the use context. For example, the vector operation Dot assumes that the left vector is horizontal and the right one is vertical. If the type indication is required, one-row or one-column matrices can be used. However, this is generally not necessary.
Matrices and vectors allocate memory for data dynamically. In fact, matrices and vectors are objects that have certain properties, such as the type of data they contain and dimensions. Matrix and vector properties can be obtained using methods such as vector_a.Size(), matrix_b.Rows(), vector_c.Norm(), matrix_d.Cond() and others. Any dimension can be changed.
When creating and initializing matrices, so-called static methods are used (these are like static methods of a class). For example: matrix::Eye(), matrix::Identity(), matrix::Ones(), vector::Ones(), matrix: :Zeros(), vector::Zeros(), matrix::Full(), vector::Full(), matrix::Tri().
At the moment, matrix and vector operations do not imply the use of the complex data type, as this development direction has not yet been completed.
MQL5 supports passing of matrices and vectors to DLLs. This enables the import of functions utilizing the relevant types, from external variables.
Matrices and vectors are passed to a DLL as a pointer to a buffer. For example, to pass a matrix of type float, the corresponding parameter of the function exported from the DLL must take a float-type buffer pointer.
MQL5
#import "mmlib.dll"
|
C++
extern "C" __declspec(dllexport) bool sgemm(UINT flags, float *C, const float *A, const float *B, UINT64 M, UINT64 N, UINT64 K, float alpha, float beta) |
In addition to buffers, you should pass matrix and vector sizes for correct processing.
All matrix and vector methods are listed below in alphabetical order.
Function |
Action |
Category |
---|---|---|
Compute activation function values and write them to the passed vector/matrix |
||
Return the index of the maximum value |
||
Return the index of the minimum value |
||
Return the sorted index |
||
Copies a matrix, vector or array with auto cast |
||
Compute the weighted average of matrix/vector values |
||
Compute the Cholesky decomposition |
||
Limits the elements of a matrix/vector to a given range of valid values |
||
Return a column vector. Write a vector to the specified column. |
||
Return the number of columns in a matrix |
||
Compare the elements of two matrices/vectors with the specified precision |
||
Compare the elements of two matrices/vectors with the significant figures precision |
||
Compute the condition number of a matrix |
||
Return the discrete, linear convolution of two vectors |
||
Return a copy of the given matrix/vector |
||
Get the data of the specified indicator buffer in the specified quantity to a vector |
||
Gets the historical series of the MqlRates structure of the specified symbol-period in the specified amount into a matrix or vector |
||
Get ticks from an MqlTick structure into a matrix or a vector |
||
Get ticks from an MqlTick structure into a matrix or a vector within the specified date range |
||
Compute the Pearson correlation coefficient (linear correlation coefficient) |
||
Compute the cross-correlation of two vectors |
||
Compute the covariance matrix |
||
Return the cumulative product of matrix/vector elements, including those along the given axis |
||
Return the cumulative sum of matrix/vector elements, including those along the given axis |
||
Compute activation function derivative values and write them to the passed vector/matrix |
||
Compute the determinant of a square invertible matrix |
||
Extract a diagonal or construct a diagonal matrix |
||
Dot product of two vectors |
||
Computes the eigenvalues and right eigenvectors of a square matrix |
||
Computes the eigenvalues of a general matrix |
||
Return a matrix with ones on the diagonal and zeros elsewhere |
||
Fill an existing matrix or vector with the specified value |
||
Access a matrix element through one index instead of two |
||
Create and return a new matrix filled with the given value |
||
The GeMM (General Matrix Multiply) method implements the general multiplication of two matrices |
||
Return the number of NaN values in a matrix/vector |
||
Split a matrix horizontally into multiple submatrices. Same as Split with axis=0 |
||
Create an identity matrix of the specified size |
||
Matrix or vector initialization |
||
Inner product of two matrices |
||
Compute the multiplicative inverse of a square invertible matrix by the Jordan-Gauss method |
||
Return Kronecker product of two matrices, matrix and vector, vector and matrix or two vectors |
||
Compute loss function values and write them to the passed vector/matrix |
||
Return the least-squares solution of linear algebraic equations (for non-square or degenerate matrices) |
||
Implement an LU decomposition of a matrix: the product of a lower triangular matrix and an upper triangular matrix |
||
Implement an LUP factorization with partial permutation, which refers to LU decomposition with row permutations only: PA=LU |
||
Matrix product of two matrices |
||
Return the maximum value in a matrix/vector |
||
Compute the arithmetic mean of element values |
||
Compute the median of the matrix/vector elements |
||
Return the minimum value in a matrix/vector |
||
Return matrix or vector norm |
||
Create and return a new matrix filled with ones |
||
Compute the outer product of two matrices or two vectors |
||
Return the specified percentile of values of matrix/vector elements or elements along the specified axis |
||
Compute the pseudo-inverse of a matrix by the Moore-Penrose method |
||
Raise a square matrix to an integer power |
||
Return the product of matrix/vector elements, which can also be executed for the given axis |
||
Return the range of values of a matrix/vector or of the given matrix axis |
||
Compute the qr factorization of a matrix |
||
Return the specified quantile of values of matrix/vector elements or elements along the specified axis |
||
Return matrix rank using the Gaussian method |
||
Compute the regression metric as the deviation error from the regression line constructed on the specified data array |
||
Change the shape of a matrix without changing its data |
||
Return a new matrix with a changed shape and size |
||
Return a row vector. Write the vector to the specified row |
||
Return the number of rows in a matrix |
||
Sets the value for a vector element by the specified index |
||
Return the size of vector |
||
Compute the sign and logarithm of the determinant of an matrix |
||
Solve a linear matrix equation or a system of linear algebraic equations |
||
Sort by place |
||
Compute spectrum of a matrix as the set of its eigenvalues from the product AT*A |
||
Split a matrix into multiple submatrices |
||
Return the standard deviation of values of matrix/vector elements or elements along the specified axis |
||
Return the sum of matrix/vector elements, which can also be executed for the given axis (axes) |
||
Singular value decomposition |
||
Swap columns in a matrix |
||
Swap rows in a matrix |
||
Return the sum along diagonals of the matrix |
||
Transpose (swap the axes) and return the modified matrix |
||
Construct a matrix with ones on a specified diagonal and below, and zeros elsewhere |
||
Return a copy of a matrix with elements above the k-th diagonal zeroed. Lower triangular matrix |
||
Return a copy of a matrix with the elements below the k-th diagonal zeroed. Upper triangular matrix |
||
Compute the variance of values of matrix/vector elements |
||
Split a matrix vertically into multiple submatrices. Same as Split with axis=1 |
||
Create and return a new matrix filled with zeros |