# Initialization There are several ways to declare and initialize matrices and vectors. | Function | Action | | --- | --- | | Assign | Copies a matrix, vector or array with auto cast | | CopyIndicatorBuffer | Get the data of the specified indicator buffer in the specified quantity to a vector | | CopyRates | Gets the historical series of the MqlRates structure of the specified symbol-period in the specified amount into a matrix or vector | | CopyTicks | Get ticks from an MqlTick structure into a matrix or a vector | | CopyTicksRange | Get ticks from an MqlTick structure into a matrix or a vector within the specified date range | | Eye | Return a matrix with ones on the diagonal and zeros elsewhere | | Identity | Create an identity matrix of the specified size | | Ones | Create and return a new matrix filled with ones | | Zeros | Create and return a new matrix filled with zeros | | Full | Create and return a new matrix filled with given value | | Tri | Construct a matrix with ones at and below the given diagonal and zeros elsewhere | | Init | Initialize a matrix or a vector | | Fill | Fill an existing matrix or vector with the specified value | | Random | Static function. Create and return a new matrix or vector filled with random values. Random values are generated uniformly within the specified range | Declaration without specifying the size (no memory allocation for the data): ```   matrix         matrix_a;   // double type matrix   matrix matrix_a1;  // another way to declare a double matrix; can be used in templates   matrixf        matrix_a2;  // float matrix   matrix  matrix_a3;  // float matrix   vector         vector_a;   // double vector   vector vector_a1;   vectorf        vector_a2;  // float vector   vector  vector_a3; ``` Declaration with the specified size (with memory allocation for the data, but without any initialization): ```   matrix         matrix_a(128,128);           // the parameters can be either constants   matrix matrix_a1(InpRows,InpCols);  // or variables   matrixf        matrix_a2(1,128);            // analog of a horizontal vector   matrix  matrix_a3(InpRows,1);        // analog of a vertical vector   vector         vector_a(256);   vector vector_a1(InpSize);   vectorf        vector_a2(SomeFunc());       // function SomeFunc returns a number of type ulong, which is used to set the vector size   vector  vector_a3(InpSize+16);       // expression can be used as a parameter ``` Declaration with initialization (matrix and vector sizes are determined by the initializing sequence): ```   matrix         matrix_a={{0.1,0.2,0.3},{0.4,0.5,0.6}};   matrix matrix_a1=matrix_a;                      // must be matrices of the same type   matrixf        matrix_a2={{1,0,0},{0,1,0},{0,0,1}};   matrix  matrix_a3={{1,2},{3,4}};   vector         vector_a={-5,-4,-3,-2,-1,0,1,2,3,4,5};   vector vector_a1={1,5,2.4,3.3};   vectorf        vector_a2={0,1,2,3};   vector  vector_a3=vector_a2;                     // must be vectors of the same type ``` Declaration with initialization: ``` template void MatrixArange(matrix &mat,T value=0.0,T step=1.0)   {    for(ulong i=0; i void VectorArange(vector &vec,T value=0.0,T step=1.0)   {    for(ulong i=0; i matrix_a1=matrix::Full(3,4,M_PI);   matrixf        matrix_a2=matrixf::Identity(5,5);   matrixf matrix_a3=matrixf::Ones(5,5);   matrix         matrix_a4=matrix::Tri(4,5,-1);   vector         vector_a =vector::Ones(256);   vectorf        vector_a1=vector::Zeros(16);   vector  vector_a2=vectorf::Full(128,float_value); ``` Methods for initializing already created matrices and vectors: ```   matrix  matrix_a;   matrix_a.Init(size_m,size_k,MatrixArange,-M_PI,0.1);   matrixf matrix_a1(3,4);   matrix_a1.Init(10,20,MatrixArange);   vector  vector_a;   vector_a.Init(128,VectorArange);   vectorf vector_a1(10);   vector_a1.Init(vector_size,VectorArange,start_value,step);     matrix_a.Fill(double_value);   vector_a1.Fill(FLT_MIN);   matrix_a1.Identity(); ```