/* all the libray is compiled, you can create a library */
#ifndef _WIN32
#include "../include/lminmaxgd.h"
#include "../src/gd.cpp"
#include "../src/poly.cpp"
#include "../src/serie.cpp"
#include "../src/smatrix.cpp"
#include "../src/tools.cpp"
#else
#include "..\include\lminmaxgd.h"
#include "..\src\gd.cpp"
#include "..\src\poly.cpp"
#include "..\src\serie.cpp"
#include "..\src\smatrix.cpp"
#include "..\src\tools.cpp"
using namespace std;
#endif
#include <time.h>
/////////////////////////////////////////////////////////////////////
/* Example : HOW TO handle date from matrices of series

*/
/////////////////////////////////////////////////////////////////////


int main()
{
try
{

	smatrix A(2,2);	// matrice d'état
	smatrix B(2,1);
	smatrix C(1,2);
    gd r; // a monomial
    poly p,q; // two polynomials
	serie s; // series
	int i,j;

	smatrix As;

    C(0,1)=gd(0,0);

    B(0,0)=e;
    B(1,0)=e;

	A(0,0)=gd(2,5);//(g^1,d^4)
	// HOW TO Declare an entry of the  matrix with random value
	A(0,1)=gd(1,0); // ramdom exponent in [0-9]
	A(1,0)=gd(0,1);
	A(1,1)=gd(1,2);
	// HOW TO delcare a polynomial
	p.init(0,4)(4,9); // polynomial p
	q.init(5,infinity); // polynomail q
	r.init(0,0);

	s.init(p,q,r); // you create a series




  /// TAKE CARE OF THE MATRICES DIMENSION, EXCEPTION IS GENERATED IF THE MATRICES DIMENSION ARE WRONG
	As=star(A); // the size of the result is ajusted automatically
	cout<<"star illustration\n As \n"<<As<<endl;

    smatrix AB,CAB,y,u;
    AB=otimes(As,B);
    CAB=otimes(C,AB);
    cout<<"CAB \n"<<CAB<<endl;
    u(0,0)=s;
    cout<<"u \n"<<u<<endl;
   y=otimes(CAB,u);
   cout<<"y \n"<<y<<endl;
   smatrix udivy;

   udivy=lfrac(u,y);
   cout<<"u/y \n"<<udivy<<endl;
	return(0);
}

 catch(mem_limite l)
 {
	 cout<<"Exception : too many coefficents in polynom "<<l.memoire<<endl;
	 return(1);
 }

 catch(taille_incorrecte obj)
 { // 0 : r non causal
   // 1 : tentative d'accès à un element d'une matrice avec un indice incorrect
   // 2 : matrice de taille incompatible pour oplus, inf, otimes, rfrac, lfrac
   // 3 : etoile de matrice carrée uniquement
	 cout<<"Exception  "<<obj.erreur<<endl;
	 return(1);
 }
}
