synaps/mpol/RS.h

00001 #ifndef SYNAPS_MPOL_RS_H
00002 #define SYNAPS_MPOL_RS_H
00003 
00004 #include <synaps/init.h>
00005 
00006 extern "C" {
00007  /*#include "synaps/usp_bz.h"*/
00008 #include "synaps/io_interf_rs.h"
00009 #include "synaps/io_ascii.h"
00010 extern void parse_vars_ascii(void);
00011 extern void reordonne_groebner(void);
00012 extern void bz_bus_out(BUS, bz_const);
00013 extern void send_Groebner(BUS,list_smp_bz_const);
00014 extern void get_Groebner(BUS,list_smp_bz_ref,RS_I32 *,float *);
00015 }
00016 
00017 
00018 __BEGIN_NAMESPACE_SYNAPS
00019 
00020 #define dup_bz_elt(a,i) vect_bz_elt(vect_bz_rep2t(a->rep),i)
00021 
00022 // void POL_MP_INT_2_dup_bz(POL & p,dup_bz_ref rs_p)
00023 // {
00024 //      unsigned int i;
00025 //      dup_bz_init_d(rs_p,p.degree()+1);
00026 
00027 //      for (i=0;i<p.degree()+1;i++){
00028 //        /*      (rs_p->rep).data=p.rep.tab_;*/
00029           
00030 //          mpz_set(&(dup_bz_elt(rs_p,i)[0]),&((p[i]).z)); 
00031 //      } 
00032 // }
00033 
00034 BUS init_bus(char * machine,char *server,char *gbhome)
00035 {
00036   BUS RS=NULL;
00037   bz init_bz;
00038   bz_init_str(init_bz,"21345817372864405881847059188222722561");
00039   RS=(BUS)malloc(sizeof(BUS_REP));
00040   RS->__out=(String)malloc(GB_BUFF_SIZE);
00041   RS->__in=(String)malloc(GB_BUFF_SIZE);
00042   RS->hostName=machine;
00043   RS->algoName=server;
00044   RS->prot=(DYN_PROT)malloc(sizeof(DYN_PROT_REP));
00045   C__initProtocol(RS->prot);
00046   C__initProtocol_BI(RS->prot,(C__int *)(init_bz->_mp_d),abs(init_bz->_mp_size));      
00047   C__open(RS,gbhome,"","");
00048   return(RS);
00049   
00050 }
00051 
00052 void send_vars_u(BUS RS,char *v)
00053 {
00054   int i=1;
00055   send_n(RS,(char*)(&i),4,4);
00056   C__sendString(RS,v);
00057   C__flush(RS);
00058 }
00059 
00060 void send_up(BUS RS,dup_bz_ref p)
00061 {
00062   unsigned int i=1,c=0;
00063   C__sendMessages(RS,FGBRS_INIT);
00064   C__sendMessages(RS,FGBRS_INPUT);
00065   C__sendMessages(RS,FGBRS_VARS);
00066   send_vars_u(RS,"x");
00067   C__sendMessages(RS,FGBRS_INPUT);
00068   C__flush(RS);
00069   C__sendMessages(RS,FGBRS_PROPERTIES);
00070   C__flush(RS);
00071   C__sendMessages(RS,FGBRS_PROP_UP);
00072   C__flush(RS);
00073   C__sendMessages(RS,FGBRS_INPUT);
00074   C__flush(RS);
00075   C__sendMessages(RS,FGBRS_LIST);
00076   C__flush(RS);
00077 
00078   send_n(RS,(char*)(&i),4,4);  
00079   for(i=0;i<(p->rep).dim;i++) {
00080     if (RS_NOT(bz_isNull(dup_bz_elt(p,i)))) c++;
00081   }
00082   fprintf(stderr,"debut liste data\n");
00083   
00084   fflush(stderr);
00085   
00086   send_n(RS,(char*)(&c),4,4);
00087   for(i=0;i<p->rep.dim;i++) {
00088     if (RS_NOT(bz_isNull(dup_bz_elt(p,i)))) {
00089 
00090       fprintf(stderr,"@");
00091       fflush(stderr);
00092 
00093       send_n(RS,(char *)(&i),4,4);
00094 
00095       fprintf(stderr,"#");
00096       fflush(stderr);
00097 
00098       bz_bus_out(RS,dup_bz_elt(p,i));
00099     }
00100   }
00101   C__flush(RS);
00102 }
00103 
00104 // unsigned int cmd_run_isoleuni(BUS RS,int prec,list_rn_bz_ref lresn)
00105 // {
00106 //   unsigned int res=0;
00107 //   C__sendMessages(RS,FGBRS_INPUT);
00108 //   C__sendMessages(RS,RS_PARAM);
00109 //   C__sendMessages(RS,RS_PARAM_PRECISOL);
00110 //   send_n(RS,(char*) (&prec),sizeof(int),sizeof(int));
00111 //   C__flush(RS);  
00112 //   C__sendMessages(RS,FGBRS_INPUT);
00113 //   C__sendMessages(RS,RS_CMD);
00114 //   C__sendMessages(RS,RS_CMD_ISOLEUNI);
00115 //   C__sendMessages(RS,FGBRS_RUN);
00116 //   C__flush(RS);
00117 //   C__sendMessages(RS,FGBRS_DIRECT_OUTPUT);
00118 //   C__sendMessages(RS,FGBRS_PROP_INTERVAL);
00119 //   C__flush(RS);
00120 //   list_rn_bz_init(lresn);
00121 //   list_rn_bz_bus_in(RS,lresn);
00122 //   return(lresn->nb);
00123 // }
00124 
00125 /*
00126 int main(int argc, char** argv) {
00127 
00128   BUS RS=NULL;
00129   list_rn_bz res_usp;
00130   dup_bz rs_up;
00131   int n=10;
00132   POL a(n);
00133   dup_bz_init(rs_up);
00134   
00135   for(int i=0;i<n;i+=2) { a[i] = (long int)i+1;  }
00136   for(int i=1;i<n;i+=2) { a[i] = (long int)-(i+1);  }
00137   
00138   cout <<a <<endl;
00139   
00140   POL_MP_INT_2_dup_bz(a,rs_up);
00141   
00142   RS=init_bus(argv[1],"serveur_rs -server","/u/molotova/0/galaad/mourrain/Fabrice/RSDevelop/Compilation");
00143   
00144   send_up(RS,rs_up);
00145   list_rn_bz_init(res_usp);
00146   cout << " Resultat :" << cmd_run_isoleuni(RS,128,res_usp) << "\n";
00147   list_rn_bz_out(res_usp,stderr);
00148 }
00149 */
00150 
00151 __END_NAMESPACE_SYNAPS
00152 
00153 #endif // SYNAPS_MPOL_RS_H
00154 

SYNAPS DOCUMENTATION
logo