Discussion of article "Matrix and Vector operations in MQL5" - page 3

 
Rashid Umarov #:
Or look in the MatrixSetValues article, it's all in plain sight.

Got it, thanks, it's like a two-dimensional array in the end.

 
Rashid Umarov #:

I am honestly confused, there is a description here 1 and here 2, and the first variant is according to the article, but nothing is reproduced from the second one. Or is it that I do not reproduce, and it is possible to read data into the matrix from a binary file bypassing the array?

The second link has such a solution.

void matrix .FromFile(const int rows, condt int cols, const int file_handle, const int count=-1, const int offset=0)

fromfile

Creates a matrix from data in a text or binary file

Документация по MQL5: Методы матриц и векторов
Документация по MQL5: Методы матриц и векторов
  • www.mql5.com
Методы матриц и векторов - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 

It's written right in the introduction

Если кратко, то вектор — это одномерный массив типа double, матрица — двумерный массив типа double. Векторы бывают вертикальные и горизонтальные, но в MQL5 они не разделяются.

Матрицы можно представить как массив горизонтальных векторов, где первый индекс матрицы означает номер строки, а второй индекс — номер столбца.


Only row and column numbering, unlike in linear algebra, starts from zero, as in arrays.

 
Aleksey Vyazmikin #:

The second link has this solution.

void matrix .FromFile(const int rows, condt int cols, const int file_handle, const int count=-1, const int offset=0)

fromfile

Creates a matrix from data in a text or binary file

This is not implemented yet

 
Rashid Umarov #:

It says it right in the introduction

It's hard to imagine which things are to be taken literally and which are to be taken abstractly....

 
Rashid Umarov #:

This has not yet been implemented

Got it, let's wait for.... although of course it is desirable to do the same way as bin file is read, i.e. that there would be different filling - what is required, and then already specify from a specific place where the matrix is there...

 

I don't understand, a matrix is a two-dimensional array, right?

I want to find the maximum value in a certain column in this array, I'm going to look at the instructions.

//Пример:

   matrix matrix_a={{10,3,2},{1,8,12},{6,5,4},{7,11,9}};
   Print("matrix_a\n",matrix_a);
 
   vector cols_max=matrix_a.ArgMax(0);
   vector rows_max=matrix_a.ArgMax(1);
   ulong  matrix_max=matrix_a.ArgMax();
 
   Print("cols_max=",cols_max);
   Print("rows_max=",rows_max);
   Print("max index ",matrix_max,"  max value ",matrix_a.Flat(matrix_max));
 
   /*
 matrix_a
 [[10,3,2]
 [1,8,12]
 [6,5,4]
 [7,11,9]]
 cols_max=[0,3,1]
 rows_max=[0,2,0,1]
 max index 5 max value 12.0
 */

And how am I supposed to understand 3 and 4 digits in the coordinates when there should be only two?

And, how do I get the maximum value of a given column in the end?

 
How to copy a specific column/row of a matrix into a vector or array?
 

Why do I have to reopen the terminal to clear the matrix?

Essence - write code - fill matrix - print matrix results - run script - comment matrix filling - run script - print matrix with old values.

 
Rashid Umarov #:

It says it right in the introduction

Well, in the picture you could change the numbering from 00, 01, 02.... first row, it would be clearer immediately.