#ifndef _WIN32
#include "../include/lminmaxgd.h"
#else
#include "..\include\lminmaxgd.h"
using namespace std;
#endif
#include <time.h>




/////////////////////////////////////////////////////////////////////
/* Example :
we try to find a counter example to the follwoing assertion
A*B (CA*B \ CA*B) = A*B => (A*B/CA*B) CA*B =A*B
*/
#include "..\src\gd.cpp"
#include "..\src\poly.cpp"
#include "..\src\serie.cpp"
#include "..\src\smatrix.cpp"
#include "..\src\tools.cpp"
#define N 5
using namespace std;

int main(void)
{
try{
clock_t start, finish;
srand(time(NULL));
//struct rusage ru;
clock_t duration,duration2;
poly p1;
poly p2,p3,p4;
smatrix l;
smatrix abcabcab;
smatrix cabcab;
smatrix lcab;
smatrix c(1,1);
smatrix cab(1,1);
smatrix ab(1,1);
smatrix abab(1,1);



int i,j;
int n0=_infinity,t0=_infinity;
int n,t;
gd r;

 p1.init(2,5);
 p2.init(6,7)(9,11)(11,13)(18,25);
 r.init(9,25);
 c(0,0).init(p1,p2,r);
cout <<"cab"<<cab<<endl;
 p1.init(0,0)(2,5);
 p2.init(0,0)(2,5);
 r.init(3,7);
 ab(0,0).init(p1,p2,r);
cout <<"ab"<<ab<<endl;

abab=lfrac(ab,ab);
cout <<"abab"<<abab<<endl;
c=inf(c,abab); // to ensure the observaility it is necessar
cab=otimes(c,ab);
cout <<"cab"<<cab<<endl;
 cabcab=lfrac(cab,cab);
cout <<"cabcab"<<cabcab<<endl;
 abcabcab=otimes(ab,cabcab);
cout <<"abcabcab"<<abcabcab<<endl;
 if(ab==abcabcab&& abab==cabcab)
 {
     cout<<" observable"<<endl;
     lcab=rfrac(ab,cab);
     cout<<"l"<<lcab<<endl;
     lcab=otimes(lcab,cab);
cout<<"lcab"<<lcab<<endl;
     if(lcab==ab)
     {
         cout<<"l is ok"<<endl;
     }
     else{
            cout<<"l is not ok"<<endl;
     }

 }
 else
 {
     cout<<" not observable"<<endl;
 }






//cout<<"AS= "<<AS<<endl;
return(0);
 }
  catch(mem_limite l)
 {
	 cout<<"Exception : too many coefficent 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é uniquement
	 cout<<"Exception  "<<obj.erreur<<endl;
	 return(1);
 }
}
