Parcourir la source

Add zlfint module

Jean Fromentin il y a 7 ans
Parent
commit
c00a0c75d2
6 fichiers modifiés avec 715 ajouts et 0 suppressions
  1. 14 0
      ext/zflint/Makefile
  2. 352 0
      ext/zflint/flint.cpp
  3. 92 0
      ext/zflint/flint.hpp
  4. 138 0
      ext/zflint/init.cpp
  5. 93 0
      ext/zflint/init.hpp
  6. 26 0
      ext/zflint/main.cpp

+ 14 - 0
ext/zflint/Makefile

@@ -0,0 +1,14 @@
+CPP 	= g++ -g --std=c++11 -march=corei7 -Wno-return-local-addr -fPIC -fmax-errors=1 -I/usr/local/include
+LDFLAGS = -L/usr/local/lib -lgmpxx -lgmp -lflint
+MOD 	= ../zflint.so
+
+all: $(MOD)
+
+flint.o: flint.cpp flint.hpp
+	$(CPP) -c $< -o $@
+
+$(MOD): init.cpp init.hpp flint.o
+	$(CPP) -shared  $(LDFLAGS) $^ -o $@
+
+clean:
+	-$(RM) $(MOD) *.o

+ 352 - 0
ext/zflint/flint.cpp

@@ -0,0 +1,352 @@
+/**
+ * This file is part of Gomu.
+ *
+ *  Copyright 2016 by Jean Fromentin <jean.fromentin@math.cnrs.fr>
+ *
+ * Gomu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gomu is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gomu. If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#include "flint.hpp"
+
+string
+display(fmpz* z){
+  char* disp=fmpz_get_str(NULL,10,z);  
+  string res="\033[34m";
+  res+=disp;
+  res+="\033[0m";
+  free(disp);
+  return res;
+}
+
+string
+display(fmpz_poly_struct* P){
+  slong len=fmpz_poly_length(P);
+  if(len==0) return "\033[34m0\033[0m";
+  if(len==1) return display(fmpz_poly_get_coeff_ptr(P,0));
+  string str;
+  fmpz_t temp;
+  fmpz_init(temp);
+  for(slong i=len-1;i>=0;--i){
+    fmpz* coeff=fmpz_poly_get_coeff_ptr(P,i);
+    int sgn=fmpz_sgn(coeff);
+    //Display coeff
+    if(i==len-1){
+      if(sgn==-1){
+	fmpz_neg(temp,coeff);
+	str+="\033[34m-\033[36m";
+	if(not fmpz_is_one(temp)){
+	  str+=display(temp);
+	  str+='.';
+	}
+      }
+      else{
+	if(not fmpz_is_one(coeff)){
+	  str+=display(coeff);
+	  str+='.';
+	}
+      }
+    }
+    else{
+      if(sgn==-1){
+	fmpz_neg(temp,coeff);
+	str+="\033[34m-\033[0m";
+	if(i==0) str+=display(temp);
+	else if(not fmpz_is_one(temp)){
+	  str+=display(temp);
+	  str+='.';
+	}
+      }
+      else if(sgn==1){
+	str+="\033[34m+\033[0m";
+	if(i==0) str+=display(coeff);
+	else if(not fmpz_is_one(coeff)){
+	  str+=display(coeff);
+	  str+='.';
+	}
+      }
+    }
+    if(i>0 and not fmpz_is_zero(coeff)){
+      str+="x";
+      if(i>1){
+	str+="^\033[35m"+to_string(i)+"\033[0m";
+      }
+    }
+  }
+  fmpz_clear(temp);
+  return str;
+}
+
+string display(fmpz_poly_factor_struct* F){
+  string str="";
+  if(not fmpz_is_one(&F->c)){
+    str+="\033[34m"+to_string(F->c)+"\033[0m.";
+  }
+  for(ulong i=0;i<(F->num);++i){
+    if(i!=0) str+='.';
+    fmpz_poly_struct* P=&F->p[i];
+    if(fmpz_is_zero(fmpz_poly_get_coeff_ptr(P,0))) str+=display(P);
+    else{
+      str+='(';
+      str+=display(P);
+      str+=')';
+    }
+    slong e=F->exp[i];
+    if(e!=1) str+="^\033[35m"+to_string(e)+"\033[0m";
+  }
+  return str;
+}
+  
+string
+display(fmpz_poly_q_struct* R){
+  char* disp=fmpz_poly_q_get_str_pretty(R,"x");
+  string res=disp;
+  free(disp);
+  return res;
+}
+
+string
+display(fmpz_mat_struct* A){
+  char* disp;
+  string str;
+  for(ulong i=0;i<A->r;++i){
+    if(i!=0) str+='\n';
+    str+="\033[37m[\033[0m";
+    for(long j=0;j<A->c;++j){
+      if(j!=0) str+=' ';
+      str+=display(get(A,i,j));
+    }
+    str+="\033[37m]\033[0m";
+  }
+  return str;
+}
+
+string
+display(fmpz_poly_mat_struct* A){
+  string str;
+  for(ulong i=0;i<A->r;++i){
+    if(i!=0) str+='\n';
+    str+='[';
+    for(ulong j=0;j<A->c;++j){
+      if(j!=0) str+=' ';
+      str+=" "+display(get(A,i,j));
+    }
+    str+=']';
+  }
+  return str;
+}
+
+ostream& operator<<(ostream& os,const fmpz_mat_t A){
+  if(A->c==1){
+    os<<'['<<get(A,0,0)<<']';
+    for(ulong i=1;i<A->r;++i) os<<endl<<'['<<get(A,i,0)<<']';
+  }
+  else{
+    os<<'['<<get(A,0,0);
+    for(ulong j=1;j<A->c;++j) os<<' '<<get(A,0,j);
+    os<<']';
+    for(ulong i=1;i<A->r;++i){
+      os<<endl<<'['<<get(A,i,0);
+      for(ulong j=1;j<A->c;++j) os<<' '<<get(A,i,j);
+      os<<']';
+    }
+  }
+  return os;
+}
+
+ostream& operator<<(ostream& os,const fmpz_poly_factor_t F){
+  if(not fmpz_is_one(&F->c)) os<<F->c<<'.';
+  for(ulong i=0;i<(F->num);++i){
+    if(i!=0) os<<'.';
+    fmpz_poly_struct* P=&F->p[i];
+    if(fmpz_is_zero(fmpz_poly_get_coeff_ptr(P,0))) os<<&F->p[i];
+    else os<<'('<<&F->p[i]<<')';
+    slong e=F->exp[i];
+    if(e!=1) os<<'^'<<e;
+  }
+  return os;
+}
+
+string toHtml(const fmpz_poly_t P){
+  fmpz_t temp;
+  fmpz_init(temp);
+  string str;
+  slong length=fmpz_poly_length(P);
+  if(length==0) return "0";
+  if(length==1){
+    fmpz* coeff=fmpz_poly_get_coeff_ptr(P,0);
+    return toHtml(coeff);
+  }
+  for(slong i=length-1;i>=0;--i){
+    fmpz* coeff=fmpz_poly_get_coeff_ptr(P,i);
+    if(not fmpz_is_zero(coeff)){
+      if(fmpz_is_one(coeff)){
+	if(i==0) str+=" + 1";
+	else if(i==1) str+="x";
+	else if(i==length-1) str+="x<sup>"+to_string(i)+"</sup>";
+	else str+=" + x<sup>"+to_string(i)+"</sup>";
+      }
+      else if(fmpz_is_pm1(coeff)){
+	if(i==0) str+=" - 1";
+	else if(i==1) str+=" - x";
+	else str+=" - x<sup>"+to_string(i)+"</sup>";
+      }
+      else if(fmpz_sgn(coeff)==-1){
+	fmpz_neg(temp,coeff);
+	str+=" - "+toHtml(temp);
+	if(i==1) str+=" x";
+	if(i>1) str+=" x<sup>"+to_string(i)+"</sup>";
+      }
+      else{
+	if(i<length-1) str+=" + ";
+	str+=toHtml(coeff);
+	if(i==1) str+=" x ";
+	if(i>1) str+=" x<sup>"+to_string(i)+"</sup>";
+      }
+    }
+  }
+  return str;
+}
+
+string toHtml(const fmpz_poly_q_t R){
+  return toHtml(fmpz_poly_q_numref(R))+"/"+toHtml(fmpz_poly_q_denref(R));
+}
+
+string toHtml(const fmpz_poly_factor_t F){
+  string str;
+  if(not fmpz_is_one(&F->c)) str=toHtml(&F->c)+" &middot; ";
+  for(ulong i=0;i<(F->num);++i){
+    if(i!=0) str+=" &middot; ";
+    fmpz_poly_struct* P=&F->p[i];
+    if(fmpz_is_zero(fmpz_poly_get_coeff_ptr(P,0))) str+=toHtml(&F->p[i]);
+    else str+="("+toHtml(&F->p[i])+")";
+    slong e=F->exp[i];
+    if(e!=1) str+="<sup>"+to_string(e)+"</sup>";
+  }
+  return str;
+}
+
+int cmp(fmpz_poly_struct* P,fmpz_poly_struct* Q){
+  if(fmpz_poly_length(P)==fmpz_poly_length(Q)){
+    for(slong i=fmpz_poly_degree(P);i>=0;--i){
+      int c=fmpz_cmp(fmpz_poly_get_coeff_ptr(P,i),fmpz_poly_get_coeff_ptr(Q,i));
+      if(c!=0) return c;
+    }
+    return 0;
+  }
+  if(fmpz_poly_length(P)<fmpz_poly_length(Q)) return -1;
+  return 1;
+}
+
+int cmp(fmpz_poly_q_struct* R,fmpz_poly_q_struct* Q){
+  int c=cmp(fmpz_poly_q_denref(R),fmpz_poly_q_denref(Q));
+  if(c!=0) return c;
+  return cmp(fmpz_poly_q_numref(R),fmpz_poly_q_numref(Q));
+}
+
+int cmp(fmpz_poly_factor_struct* F1,fmpz_poly_factor_struct* F2){
+  if(F1->num==F2->num){
+    int c=fmpz_cmp(&F1->c,&F2->c);
+    if(c==0){
+      for(int i=0;i<F1->num;++i){
+	int d=cmp(&F1->p[i],&F2->p[i]);
+	if(d==0){
+	  if(F1->exp[i]!=F2->exp[i]){
+	    if(F1->exp[i]<F2->exp[i]) return -1;
+	    return 1;
+	  }
+	}
+	return d;
+      }
+      return 0;
+    }
+    return c;
+  }
+  if(F1->num<F2->num) return -1;
+  return 1;
+}
+
+int cmp(fmpz_mat_struct* A,fmpz_mat_struct* B){
+  if(A->r==B->r){
+    if(A->c==B->c){
+      for(slong i=0;i<A->r;++i){
+	for(slong j=0;j<A->c;++j){
+	  int c=fmpz_cmp(fmpz_mat_entry(A,i,j),fmpz_mat_entry(B,i,j));
+	  if(c!=0) return c;
+	}
+      }
+      return 0;
+    }
+    if(A->c<B->c) return -1;
+    return 1;
+  }
+  if(A->r<B->r) return -1;
+  return 1;
+}
+
+int cmp(fmpz_poly_mat_struct* A,fmpz_poly_mat_struct* B){
+  if(A->r==B->r){
+    if(A->c==B->c){
+      for(slong i=0;i<A->r;++i){
+	for(slong j=0;j<A->c;++j){
+	  int c=cmp(fmpz_poly_mat_entry(A,i,j),fmpz_poly_mat_entry(B,i,j));
+	  if(c!=0) return c;
+	}
+      }
+      return 0;
+    }
+    if(A->c<B->c) return -1;
+    return 1;
+  }
+  if(A->r<B->r) return -1;
+  return 1;
+}
+
+
+void dispSage(ostream& os,const fmpz_mat_t A){
+  os<<"matrix(QQ,"<<A->r<<','<<A->c<<",[";
+  for(ulong i=0;i<A->r;++i){
+    for(ulong j=0;j<A->c;++j){
+      if(i!=0 or j!=0) os<<',';
+      os<<get(A,i,j);
+    }
+  }
+  os<<"])";
+}
+
+ostream& operator<<(ostream& os,const fmpz_poly_mat_t A){
+  if(A->c==1){
+    os<<'['<<get(A,0,0)<<']';
+    for(ulong i=1;i<A->r;++i) os<<endl<<'['<<get(A,i,0)<<']';
+  }
+  else{
+    os<<'['<<get(A,0,0);
+    for(ulong j=1;j<A->c;++j) os<<' '<<get(A,0,j);
+    os<<']';
+    for(ulong i=1;i<A->r;++i){
+      os<<endl<<'['<<get(A,i,0);
+      for(ulong j=1;j<A->c;++j) os<<' '<<get(A,i,j);
+      os<<']';
+    }
+  }
+  return os;
+}
+
+ void fmpz_poly_mat_init_set(fmpz_poly_mat_t A,fmpz_mat_t B){
+  fmpz_poly_mat_init(A,B->r,B->c);
+  for(slong i=0;i<B->r;++i){
+    for(slong j=0;j<B->c;++j){
+      fmpz_poly_set_coeff_fmpz(fmpz_poly_mat_entry(A,i,j),0,fmpz_mat_entry(B,i,j));
+    }
+  }
+}

+ 92 - 0
ext/zflint/flint.hpp

@@ -0,0 +1,92 @@
+/**
+ * This file is part of Gomu.
+ *
+ *  Copyright 2016 by Jean Fromentin <jean.fromentin@math.cnrs.fr>
+ *
+ * Gomu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gomu is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gomu. If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#ifndef FLINT_HPP
+#define FLINT_HPP
+
+#include <iostream>
+#include "flint/fmpz.h"
+#include "flint/fmpz_mat.h"
+#include "flint/fmpz_poly.h"
+#include "flint/fmpz_poly_q.h"
+#include "flint/fmpz_poly_mat.h"
+
+using namespace std;
+
+
+ostream& operator<<(ostream&,const fmpz_t);
+ostream& operator<<(ostream&,const fmpz_mat_t);
+ostream& operator<<(ostream&,const fmpz_poly_t);
+ostream& operator<<(ostream&,const fmpz_poly_factor_t);
+ostream& operator<<(ostream&,const fmpz_poly_mat_t);
+string display(fmpz*);
+string display(fmpz_poly_struct*);
+string display(fmpz_poly_factor_struct*);
+string display(fmpz_poly_q_struct*);
+string display(fmpz_mat_struct*);
+string display(fmpz_poly_mat_struct*);
+
+
+string toHtml(const fmpz_t);//obsolete
+string toHtml(const fmpz_poly_t);
+string toHtml(const fmpz_poly_q_t);
+string toHtml(const fmpz_poly_factor_t);
+int cmp(fmpz_mat_struct*,fmpz_mat_struct*);
+int cmp(fmpz_poly_struct*,fmpz_poly_struct*);
+int cmp(fmpz_poly_q_struct*,fmpz_poly_q_struct*);
+int cmp(fmpz_poly_factor_struct*,fmpz_poly_factor_struct*);
+int cmp(fmpz_poly_mat_struct*,fmpz_poly_mat_struct*);
+fmpz* get(const fmpz_mat_t,slong,slong);
+fmpz_poly_struct* get(const fmpz_poly_mat_t,slong,slong);
+void fmpz_poly_mat_init_set(fmpz_poly_mat_t,fmpz_mat_t);
+void dispSage(ostream&,const fmpz_mat_t);
+
+
+inline ostream& operator<<(ostream& os,const fmpz_t z){
+  char* str=fmpz_get_str(NULL,10,z);  
+  os<<str;
+  free(str);
+  return os;
+}
+
+
+inline ostream& operator<<(ostream& os,const fmpz_poly_t P){
+  char* str=fmpz_poly_get_str_pretty(P,"x");
+  os<<str;
+  free(str);
+  return os;
+}
+
+inline string toHtml(const fmpz_t z){
+  char* str=fmpz_get_str(NULL,10,z);  
+  string res(str);
+  return res;
+}
+
+
+inline fmpz* get(const fmpz_mat_t A,slong i,slong j){
+  return fmpz_mat_entry(A,i,j);
+}
+
+inline fmpz_poly_struct* get(const fmpz_poly_mat_t A,slong i,slong j){
+  return fmpz_poly_mat_entry(A,i,j);
+}
+
+
+#endif

+ 138 - 0
ext/zflint/init.cpp

@@ -0,0 +1,138 @@
+/**
+ * This file is part of Gomu.
+ *
+ *  Copyright 2016 by Jean Fromentin <jean.fromentin@math.cnrs.fr>
+ *
+ * Gomu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gomu is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gomu. If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#include "init.hpp"
+
+Gomu::Type* type_ZPoly;
+Gomu::Type* type_ZPolyFact;
+Gomu::Type* type_ZRatFrac;
+Gomu::Type* type_ZMatrix;
+Gomu::Type* type_ZPolyMat;
+
+extern "C"{
+  Gomu::Module::Type types[]={
+    {"ZPoly",dispPoly,delPoly,copyPoly,cmpPoly,&type_ZPoly},
+    {"ZPolyFact",dispPolyFact,delPolyFact,copyPolyFact,cmpPolyFact,&type_ZPolyFact},
+    {"ZRatFrac",dispRat,delRat,copyRat,cmpRat,&type_ZRatFrac},
+    {"ZMatrix",dispMatrix,delMatrix,copyMatrix,cmpMatrix,&type_ZMatrix},
+    {"ZPolyMat",dispPolyMatrix,delPolyMatrix,copyPolyMatrix,cmpPolyMatrix,&type_ZPolyMat},
+    TYPE_SENTINEL
+  };
+
+  Gomu::Module::Function memberFunctions[]={
+    //ZMatrix
+    {"ZPoly","charpoly",{"ZMatrix"},FUNC(charpoly)},
+    {"String","toSage",{"ZMatrix"},FUNC(toSage)},
+    {"ZPolyMat","toZPolyMat",{"ZMatrix"},FUNC(toPolyMatrix)},
+    //ZPoly
+    {"ZPolyFact","factorize",{"ZPoly"},FUNC(factorize)},
+    FUNC_SENTINEL
+  };
+}
+
+//**************
+//* Polynomial *
+//**************
+
+void*
+copyPoly(void* v){
+  fmpz_poly_struct* res=new fmpz_poly_struct;
+  fmpz_poly_init(res);
+  fmpz_poly_set(res,(fmpz_poly_struct*)v);
+  return res;
+}
+
+//*********************
+//* Polynomial factor *
+//*********************
+
+void*
+copyPolyFact(void* v){
+  fmpz_poly_factor_struct* res=new fmpz_poly_factor_struct;
+  fmpz_poly_factor_init(res);
+  fmpz_poly_factor_set(res,(fmpz_poly_factor_struct*)v);
+  return res;
+}
+
+//*************
+//* Rationnal *
+//*************
+
+void*
+copyRat(void* v){
+  fmpz_poly_q_struct* res=new fmpz_poly_q_struct;
+  fmpz_poly_q_init(res);
+  fmpz_poly_q_set(res,(fmpz_poly_q_struct*)v);
+  return res;
+}
+//**********
+//* Matrix *
+//**********
+
+void* copyMatrix(void* v){
+  fmpz_mat_struct* res=new fmpz_mat_struct;
+  fmpz_mat_init_set(res,(fmpz_mat_struct*)v);
+  return res;
+}
+
+
+//*********************
+//* Polynomial Matrix *
+//*********************
+
+void* copyPolyMatrix(void* v){
+  fmpz_poly_mat_struct* res=new fmpz_poly_mat_struct;
+  fmpz_poly_mat_init_set(res,(fmpz_poly_mat_struct*)v);
+  return res;
+}
+
+//***************************
+//* Matrix member functions *
+//***************************
+
+void* charpoly(void* v){
+  fmpz_poly_struct* res=new fmpz_poly_struct;
+  fmpz_poly_init(res);
+  fmpz_mat_charpoly(res,(fmpz_mat_struct*)v);
+  return res;
+}
+
+void* toSage(void* v){
+  ostringstream os;
+  dispSage(os,(fmpz_mat_struct*)v);
+  return new string(os.str());
+}
+
+void* toPolyMatrix(void* v){
+  fmpz_poly_mat_struct* res=new fmpz_poly_mat_struct;
+  fmpz_poly_mat_init_set(res,(fmpz_mat_struct*) v);
+  return res;
+};
+
+
+//*******************************
+//* Polynomial member functions *
+//*******************************
+
+void* factorize(void* v){
+  fmpz_poly_factor_struct* res=new fmpz_poly_factor_struct;
+  fmpz_poly_factor_init(res);
+  fmpz_poly_factor_zassenhaus(res,(fmpz_poly_struct*)v);
+  return res;
+}

+ 93 - 0
ext/zflint/init.hpp

@@ -0,0 +1,93 @@
+/**
+ * This file is part of Gomu.
+ *
+ *  Copyright 2016 by Jean Fromentin <jean.fromentin@math.cnrs.fr>
+ *
+ * Gomu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gomu is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gomu. If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+
+#include "../../module.hpp"
+#include "flint.hpp"
+#include <sstream>
+
+using namespace std;
+
+//******************
+//* Global objects *
+//******************
+
+extern Gomu::Type* type_ZPoly;
+extern Gomu::Type* type_ZPolyFact;
+extern Gomu::Type* type_ZRatFrac;
+extern Gomu::Type* type_ZMatrix;
+extern Gomu::Type* type_ZPolyMat;
+
+
+
+string dispPoly(void*);
+void delPoly(void*);
+void* copyPoly(void*);
+int cmpPoly(void*,void*);
+
+string dispPolyFact(void*);
+void delPolyFact(void*);
+void* copyPolyFact(void*);
+int cmpPolyFact(void*,void*);
+
+string dispRat(void*);
+void delRat(void*);
+void* copyRat(void*);
+int cmpRat(void*,void*);
+
+string dispMatrix(void*);
+void delMatrix(void*);
+void* copyMatrix(void*);
+int cmpMatrix(void*,void*);
+
+string dispPolyMatrix(void*);
+void delPolyMatrix(void*);
+void* copyPolyMatrix(void*);
+int cmpPolyMatrix(void*,void*);
+
+//--- Matrix member functions ---//
+void* charpoly(void*);
+void* toSage(void*);
+void* toPolyMatrix(void*);
+
+//--- Polynomial member functions ---/
+void* factorize(void*);
+
+
+ 
+
+inline string dispPoly(void* P){return display((fmpz_poly_struct*)P);}
+inline void delPoly(void* v){fmpz_poly_clear((fmpz_poly_struct*)v);}
+inline int cmpPoly(void* v1,void* v2){return cmp((fmpz_poly_struct*)v1,(fmpz_poly_struct*)v2);}
+
+inline string dispPolyFact(void* P){return display((fmpz_poly_factor_struct*)P);}
+inline void delPolyFact(void* v){fmpz_poly_factor_clear((fmpz_poly_factor_struct*)v);}
+inline int cmpPolyFact(void* v1,void* v2){return cmp((fmpz_poly_factor_struct*)v1,(fmpz_poly_factor_struct*)v2);}
+
+inline string dispRat(void* R){return display((fmpz_poly_q_struct*)R);}
+inline void delRat(void* v){fmpz_poly_q_clear((fmpz_poly_q_struct*)v);}
+inline int cmpRat(void* v1,void* v2){return cmp((fmpz_poly_q_struct*)v1,(fmpz_poly_q_struct*)v2);}
+
+inline string dispMatrix(void* v){return display((fmpz_mat_struct*)v);}
+inline void delMatrix(void* v){fmpz_mat_clear((fmpz_mat_struct*)v);}
+inline int cmpMatrix(void* v1,void* v2){return cmp((fmpz_mat_struct*)v1,(fmpz_mat_struct*)v2);}
+
+inline string dispPolyMatrix(void* v){return display((fmpz_poly_mat_struct*)v);}
+inline void delPolyMatrix(void* v){fmpz_poly_mat_clear((fmpz_poly_mat_struct*)v);}
+inline int cmpPolyMatrix(void* v1,void* v2){return cmp((fmpz_poly_mat_struct*)v1,(fmpz_poly_mat_struct*)v2);} 

+ 26 - 0
ext/zflint/main.cpp

@@ -0,0 +1,26 @@
+/**
+ * This file is part of Gomu.
+ *
+ *  Copyright 2016 by Jean Fromentin <jean.fromentin@math.cnrs.fr>
+ *
+ * Gomu is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gomu is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Gomu. If not, see <http://www.gnu.org/licenses/>. 
+ */
+
+#include <iostream>
+
+using namespace std;
+
+int main(){
+    cout<<"Zflint module for Gomu"<<endl;
+}