#include <stdio.h>
#include <stdlib.h>

#include "Matrix2D.h"

/* Fill a matrix */
void FillMatrix(TMatrix2D mat)
{
  int i,j;
  
  for (i= 0;i<3;i++)
    for (j= 0;j<3;j++)
    {
      printf("enter value (Row=%d,Col=%d): ",i,j);
      scanf("%f",&Mat2D_getDataFloat(mat)[i][j]);
    }
}


/* Display a Matrix */
void DisplayMatrix(TMatrix2D mat)
{
  int i,j;
  
  for (i= 0;i<3;i++)
  {
    printf("[\t");
    for (j= 0;j<3;j++)
    {
      printf("%f\t",Mat2D_getDataFloat(mat)[i][j]);
    }
    printf("]\n");    
  }
}

int main(int argc, char *argv[])
{
  TMatrix2D mat1,mat2;
  
  /* Create a matrix 3x3 */
  mat1= Mat2D_create(3,3,MAT2D_FLOAT);
  mat2= Mat2D_createNull();
 
  FillMatrix(mat1);
  Mat2D_saveToMat(mat1,"test.mat");
  
  /* Size and type of the matrix are automatically changed */
  Mat2D_loadFromMat(mat2,"test.mat");
  DisplayMatrix(mat2);
     
  Mat2D_destroy(&mat1);
  Mat2D_destroy(&mat2);
  
  return 0;
}

