Skip to content

Commit

Permalink
new Append function
Browse files Browse the repository at this point in the history
  • Loading branch information
MegaJoctan committed Mar 10, 2024
1 parent 80dc568 commit f9e30d0
Showing 1 changed file with 12 additions and 21 deletions.
33 changes: 12 additions & 21 deletions Tensors.mqh
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public:
template<typename T>
bool Add(matrix<T> &mat_ , ulong POS);
template<typename T>
bool Append(vector<T> &v, ulong POS);

bool Append(matrix<T> mat_);
void Print_();
matrix Get(ulong POS);

template<typename T>
void Fill(T value);
void MemoryClear();
Expand Down Expand Up @@ -92,36 +92,27 @@ bool CTensors::Add(matrix<T> &mat_ , ulong POS)
return (true);
}
//+------------------------------------------------------------------+
//| Appending rows to the Get Matrix at POS index |
//| |
//+------------------------------------------------------------------+
template<typename T>
bool CTensors::Append(vector<T> &v, ulong POS)
bool CTensors::Append(matrix<T> mat_)
{
if (POS > SIZE)
{
Print(__FUNCTION__," Index Error POS =",POS," greater than TENSOR_DIM ",SIZE);

return (false);
}

//---

matrix<T> mat = this.matrices[POS].Matrix;

mat.Resize(mat.Rows()+1, mat.Cols());
mat.Row(v, mat.Rows()-1);
if (ArrayResize(matrices, SIZE+1)<0)
return false;

SIZE = matrices.Size();

Add(mat, POS);
matrices[SIZE-1].Matrix = mat_;

return (true);
return true;
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void CTensors::Print_(void)
{
for (ulong i=0; i<SIZE; i++)
Print("TENSOR INDEX <<",i,">>\n",this.matrices[i].Matrix);
Print("TENSOR INDEX [",i,"] matrix-size=(",this.matrices[i].Matrix.Rows(),"x",this.matrices[i].Matrix.Cols(),")\n",this.matrices[i].Matrix);
}
//+------------------------------------------------------------------+
//| |
Expand Down Expand Up @@ -244,7 +235,7 @@ bool CTensorsVectors::Add(vector &v, ulong POS)
void CTensorsVectors::Print_(void)
{
for (ulong i=0; i<SIZE; i++)
Print("TENSOR INDEX <<",i,">>\n",this.vectors[i].Vector);
Print("TENSOR INDEX [",i,"] vector-size =(",this.vectors[i].Vector.Size(),")\n",this.vectors[i].Vector);
}
//+------------------------------------------------------------------+
//| |
Expand Down

0 comments on commit f9e30d0

Please sign in to comment.