

#include "auxilary.h"

void MatrixToStringGrid(const Matrix & m, TStringGrid * tsg)
  {
  if ((m.nrows()!=0) && (m.nrows()!=0))
    {
    tsg->RowCount=m.nrows()+1;
    tsg->ColCount=m.ncols()+1;
    tsg->Cells[0][0]="n";
    for (int i=1; i < tsg->RowCount; i++)
      {
      tsg->Cells[i][0]="x"+IntToStr(i);
      tsg->Cells[0][i]=IntToStr(i);
      }
    for (unsigned int i=0; i < m.nrows(); i++)
      {
      for (unsigned int j=0; j < m.ncols(); j++)
        {
        tsg->Cells[j+1][i+1]=FloatToStrF(m.PobierzElement(i,j),ffExponent,4,2);
      //tsg->Cells[0][i+1]=i;
      //tsg->Cells[1][i+1]=m.PobierzElement(i,0);
      //tsg->Cells[2][i+1]=m.PobierzElement(i,1);
        }
      }
    }
    else
      {
      tsg->RowCount=30;
      tsg->ColCount=5;
      for (int i=0; i < tsg->RowCount; i++)
        for (int j=0; j < tsg->ColCount; j++)
          tsg->Cells[j][i]="";
      }
  }
