include/borderbasix/io.cc File Reference

#include "borderbasix/mpoly/lex.yy.c"
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <complex>

Go to the source code of this file.

Defines

Functions


Define Documentation

#define _COMPLEX_

Definition at line 57 of file io.cc.


Function Documentation

void affdebug ( const typmat &  m  )  [inline]

Definition at line 27 of file io.cc.

Referenced by newPkMkMatrixof().

00028 {
00029   int i;
00030   cout<<setprecision(6);
00031   cout<<"nrow "<<m.nrow<<" ncol "<<m.ncol<<endl;
00032   cout<<"[";
00033   for(i=0;i<m.nrow-1;i++)
00034     {
00035       int j;
00036       cout<<"[";
00037       for(j=0;j<m.ncol-1;j++)
00038         {
00039           //      cout<<" i "<<i<<" j "<<j<<endl;
00040           cout<<m(i,j)<<",";
00041         }
00042       cout<<m(i,j)<<"],"<<endl;
00043     }
00044   {
00045     int j;
00046     cout<<"[";
00047     for(j=0;j<m.ncol-1;j++)
00048       cout<<m(i,j)<<",";
00049     cout<<m(i,j)<<"]"<<endl;
00050   }
00051   cout<<"]"<<endl<<setprecision(16);
00052 }  

void affdebug2 ( const typmat &  m  )  [inline]

Definition at line 10 of file io.cc.

00011 {
00012   cout<<"[";
00013   for(int i=0;i<m.nrow;i++)
00014     {
00015       cout<<"[";
00016       for(int j=0;j<m.ncol-1;j++)
00017         {
00018         if (m(i,j)!=0) {printf("*");} 
00019         else {printf(" ");} 
00020         }
00021       
00022       printf("]\n");
00023     }
00024   cout<<"]"<<endl;
00025 }  

void printcoeff ( FILE *  fic,
mpf_class  c 
)

Definition at line 465 of file io.cc.

00466 {
00467   mpf_out_str(fic,10,30,c.get_mpf_t());
00468 }

void printcoeff ( FILE *  fic,
Scl< MPF >  c 
)

Definition at line 460 of file io.cc.

00461 {
00462   mpf_out_str(fic,10,30,c.data);
00463 }

void printcoeff ( FILE *  fic,
Scl< MPQ >  c 
)

Definition at line 455 of file io.cc.

00456 {
00457   mpq_out_str(fic,10,&c.data);
00458 }

void printcoeff ( FILE *  fic,
long double  c 
)

Definition at line 450 of file io.cc.

00451 {
00452   fprintf(fic,"%Lf",c);
00453 }

void printcoeff ( FILE *  fic,
double  c 
)

Definition at line 445 of file io.cc.

Referenced by printdump(), and printmon().

00446 {
00447   fprintf(fic,"%f",c);
00448 }

void printdump ( FILE *  fic,
const typdump &  dump 
) [inline]

Definition at line 493 of file io.cc.

References monofindex(), printcoeff(), and printmon().

00494 {
00495   fprintf(fic,"#begin: dump\n");   
00496   for(typename typdump::const_iterator iter=dump.begin();
00497       iter!=dump.end();iter++)
00498     {
00499       fprintf(fic,"k: %d\n",iter->k);
00500       fprintf(fic,"size: %d",iter->size);
00501       for(int i=0;i<iter->size;i++)
00502         {
00503           printmon(fic,iter->nf[i].ind);
00504           fprintf(fic,"\n");
00505           for(int j=0;j<iter->nf[i].size;j++)
00506             {
00507               if(j>0)
00508                 fprintf(fic,"+");
00509               fprintf(fic,"(");
00510               printcoeff(fic,iter->nf[i].nf[j]);
00511               fprintf(fic,")*");
00512               printmon(fic,monofindex(j,iter->nf[i]));
00513 
00514             }
00515           fprintf(fic,"\n");
00516         }
00517     }
00518   fprintf(fic,"#end: dump\n");   
00519 }

void printmatfile ( const typmat< Scl< MPF > > &  m,
char *  name,
FILE *  fic 
) [inline]

Definition at line 388 of file io.cc.

References NBDIGITS.

00389 {
00390   int i;
00391   fprintf(fic,"%s:=[",name);
00392   for(i=0;i<m.nrow-1;i++)
00393     {
00394       int j;
00395       fprintf(fic,"[");
00396       for(j=0;j<m.ncol-1;j++)
00397         {
00398           mpf_out_str(fic,10,NBDIGITS,(m(i,j).rep()));
00399           fprintf(fic,",");
00400         }
00401      mpf_out_str(fic,10,NBDIGITS,(m(i,j).rep()));
00402      fprintf(fic,"],\n");
00403     }
00404   {
00405     int j;
00406     fprintf(fic,"[");
00407     for(j=0;j<m.ncol-1;j++)
00408       {
00409         mpf_out_str(fic,10,NBDIGITS,(m(i,j).rep()));
00410           fprintf(fic,",");
00411       }
00412     mpf_out_str(fic,10,NBDIGITS,(m(i,j).rep()));
00413     fprintf(fic,"]\n];\n");
00414   }
00415 }

void printmatfile ( const typmat< Scl< MPAI > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 342 of file io.cc.

00343 {
00344   int i;
00345   fprintf(fic,"%s:=[",name);
00346   for(i=0;i<m.nrow-1;i++)
00347     {
00348       int j;
00349       fprintf(fic,"[");
00350       for(j=0;j<m.ncol-1;j++)
00351         {
00352           mpai_out_str(fic,&(m(i,j).rep()));
00353           fprintf(fic,",");
00354         }
00355      mpai_out_str(fic,&(m(i,j).rep()));
00356      fprintf(fic,"],\n");
00357     }
00358   {
00359     int j;
00360     fprintf(fic,"[");
00361     for(j=0;j<m.ncol-1;j++)
00362       {
00363         mpai_out_str(fic,&(m(i,j).rep()));
00364           fprintf(fic,",");
00365       }
00366     mpai_out_str(fic,&(m(i,j).rep()));
00367     fprintf(fic,"]\n];\n");
00368   }
00369 }

void printmatfile ( const typmat< Scl< MPQ > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 312 of file io.cc.

00313 {
00314   int i;
00315   fprintf(fic,"%s:=[",name);
00316   for(i=0;i<m.nrow-1;i++)
00317     {
00318       int j;
00319       fprintf(fic,"[");
00320       for(j=0;j<m.ncol-1;j++)
00321         {
00322           mpq_out_str(fic,10,&(m(i,j).rep()));
00323           fprintf(fic,",");
00324         }
00325      mpq_out_str(fic,10,&(m(i,j).rep()));
00326      fprintf(fic,"],\n");
00327     }
00328   {
00329     int j;
00330     fprintf(fic,"[");
00331     for(j=0;j<m.ncol-1;j++)
00332       {
00333         mpq_out_str(fic,10,&(m(i,j).rep()));
00334           fprintf(fic,",");
00335       }
00336     mpq_out_str(fic,10,&(m(i,j).rep()));
00337     fprintf(fic,"]\n];\n");
00338   }
00339 }

void printmatfile ( const typmat< long double > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 252 of file io.cc.

00253 {
00254  int i;
00255   fprintf(fic,"%s:=[",name);
00256   for(i=0;i<m.nrow-1;i++)
00257     {
00258       int j;
00259       fprintf(fic,"[");
00260       for(j=0;j<m.ncol-1;j++)
00261         {
00262           fprintf(fic,"%.16Lf,",m(i,j));
00263         }
00264       //mpq_out_str(fic,10,&(m(i,j).rep()));
00265       fprintf(fic,"%.16Lf],\n",m(i,j));
00266     }
00267   {
00268     int j;
00269     fprintf(fic,"[");
00270     for(j=0;j<m.ncol-1;j++)
00271       {
00272         //mpq_out_str(fic,10,&(m(i,j).rep()));
00273           fprintf(fic,"%.16Lf,",m(i,j));
00274       }
00275     //mpq_out_str(fic,10,&(m(i,j).rep()));
00276     fprintf(fic,"%.16Lf]\n];\n",m(i,j));
00277   }
00278 }

void printmatfile ( const typmat< double > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 223 of file io.cc.

00224 {
00225  int i;
00226   fprintf(fic,"%s:=[",name);
00227   for(i=0;i<m.nrow-1;i++)
00228     {
00229       int j;
00230       fprintf(fic,"[");
00231       for(j=0;j<m.ncol-1;j++)
00232         {
00233           fprintf(fic,"%.16f,",m(i,j));
00234         }
00235       //mpq_out_str(fic,10,&(m(i,j).rep()));
00236       fprintf(fic,"%.16f],\n",m(i,j));
00237     }
00238   {
00239     int j;
00240     fprintf(fic,"[");
00241     for(j=0;j<m.ncol-1;j++)
00242       {
00243         //mpq_out_str(fic,10,&(m(i,j).rep()));
00244           fprintf(fic,"%.16f,",m(i,j));
00245       }
00246     //mpq_out_str(fic,10,&(m(i,j).rep()));
00247     fprintf(fic,"%.16f]\n];\n",m(i,j));
00248   }
00249 }

void printmatfile ( const typmat< complex< RR > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 119 of file io.cc.

References NBDIGITS.

00120 {
00121   int i;
00122   fprintf(fic,"%s:=[",name);
00123   for(i=0;i<m.nrow-1;i++)
00124     {
00125       int j;
00126       fprintf(fic,"[");
00127       for(j=0;j<m.ncol-1;j++)
00128         {
00129           mpf_out_str(fic,10,NBDIGITS,m(i,j).real().rep());
00130           fprintf(fic,"+I*(");
00131           mpf_out_str(fic,10,NBDIGITS,m(i,j).imag().rep());
00132           fprintf(fic,"),");
00133         }
00134       //mpq_out_str(fic,10,&(m(i,j).rep()));
00135       mpf_out_str(fic,10,NBDIGITS,(m(i,j).real().rep()));
00136       fprintf(fic,"+I*(");
00137       mpf_out_str(fic,10,NBDIGITS,m(i,j).imag().rep());
00138       fprintf(fic,")],");
00139     
00140   //fprintf(fic,"%.16f+(%.16f)*I],\n",m(i,j).real(),m(i,j).imag());
00141     }
00142   {
00143     int j;
00144     fprintf(fic,"[");
00145     for(j=0;j<m.ncol-1;j++)
00146       {
00147         //mpq_out_str(fic,10,&(m(i,j).rep()));
00148         mpf_out_str(fic,10,NBDIGITS,(m(i,j).real().rep()));
00149         fprintf(fic,"+I*(");
00150         mpf_out_str(fic,10,NBDIGITS,m(i,j).imag().rep());
00151         fprintf(fic,"),");
00152       
00153     //fprintf(fic,"%.16f+(%.16f)*I,",m(i,j).real(),m(i,j).imag());
00154       }
00155     //mpq_out_str(fic,10,&(m(i,j).rep()));
00156     //fprintf(fic,"%.16f+(%.16f)*I]\n];\n",m(i,j).real(),m(i,j).imag());
00157     mpf_out_str(fic,10,NBDIGITS,(m(i,j).real().rep()));
00158     fprintf(fic,"+I*(");
00159     mpf_out_str(fic,10,NBDIGITS,m(i,j).imag().rep());
00160     fprintf(fic,")]\n];\n");
00161         
00162   }
00163 }

void printmatfile ( const typmat< complex< long double > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 89 of file io.cc.

00091 {int i;
00092   if(m.nrow==0) return;
00093   fprintf(fic,"%s:=[",name);
00094   for(i=0;i<m.nrow-1;i++)
00095     {
00096       int j;
00097       fprintf(fic,"[");
00098       for(j=0;j<m.ncol-1;j++)
00099         {
00100           fprintf(fic,"%.16Lf+(%.16Lf)*I,",m(i,j).real(),m(i,j).imag());
00101         }
00102       //mpq_out_str(fic,10,&(m(i,j).rep()));
00103       fprintf(fic,"%.16Lf+(%.16Lf)*I],\n",m(i,j).real(),m(i,j).imag());
00104     }
00105   {
00106     int j;
00107     fprintf(fic,"[");
00108     for(j=0;j<m.ncol-1;j++)
00109       {
00110         //mpq_out_str(fic,10,&(m(i,j).rep()));
00111           fprintf(fic,"%.16Lf+(%.16Lf)*I,",m(i,j).real(),m(i,j).imag());
00112       }
00113     //mpq_out_str(fic,10,&(m(i,j).rep()));
00114     fprintf(fic,"%.16Lf+(%.16Lf)*I]\n];\n",m(i,j).real(),m(i,j).imag());
00115   }
00116 }

void printmatfile ( const typmat< complex< double > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 61 of file io.cc.

00062 {int i;
00063   fprintf(fic,"%s:=[",name);
00064   for(i=0;i<m.nrow-1;i++)
00065     {
00066       int j;
00067       fprintf(fic,"[");
00068       for(j=0;j<m.ncol-1;j++)
00069         {
00070           fprintf(fic,"%.16f+(%.16f)*I,",m(i,j).real(),m(i,j).imag());
00071         }
00072       //mpq_out_str(fic,10,&(m(i,j).rep()));
00073       fprintf(fic,"%.16f+(%.16f)*I],\n",m(i,j).real(),m(i,j).imag());
00074     }
00075   {
00076     int j;
00077     fprintf(fic,"[");
00078     for(j=0;j<m.ncol-1;j++)
00079       {
00080         //mpq_out_str(fic,10,&(m(i,j).rep()));
00081           fprintf(fic,"%.16f+(%.16f)*I,",m(i,j).real(),m(i,j).imag());
00082       }
00083     //mpq_out_str(fic,10,&(m(i,j).rep()));
00084     fprintf(fic,"%.16f+(%.16f)*I]\n];\n",m(i,j).real(),m(i,j).imag());
00085   }
00086 }

void printmatfile ( const typmat< toto > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 55 of file io.cc.

Referenced by main().

00056 {}

void printmatfile_pequan ( const typmat< Scl< MPF > > &  m,
FILE *  fic 
) [inline]

Definition at line 372 of file io.cc.

References NBDIGITS.

00373 {
00374   int i,j;
00375   fprintf(fic,"%d %d\n",m.nrow,m.ncol);
00376   for(i=0;i<m.nrow;i++)
00377     {
00378       for(j=0;j<m.ncol;j++)
00379         {
00380           fprintf(fic,"%d %d ",i,j);
00381           mpf_out_str(fic,10,NBDIGITS,(m(i,j).rep()));
00382           fprintf(fic,"\n");
00383         }
00384     }
00385 }

void printmatfilescilab ( const typmat< complex< long double > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 194 of file io.cc.

00195 {int i;
00196   fprintf(fic,"%s=[",name);
00197   for(i=0;i<m.nrow-1;i++)
00198     {
00199       int j;
00200       fprintf(fic,"");
00201       for(j=0;j<m.ncol-1;j++)
00202         {
00203           fprintf(fic,"%.32Le+(%.32Le)*I,",m(i,j).real(),m(i,j).imag());
00204         }
00205       //mpq_out_str(fic,10,&(m(i,j).rep()));
00206       fprintf(fic,"%.32Le+(%.32Le)*I;\n",m(i,j).real(),m(i,j).imag());
00207     }
00208   {
00209     int j;
00210     fprintf(fic,"");
00211     for(j=0;j<m.ncol-1;j++)
00212       {
00213         //mpq_out_str(fic,10,&(m(i,j).rep()));
00214           fprintf(fic,"%.32Le+(%.32Le)*I,",m(i,j).real(),m(i,j).imag());
00215       }
00216     //mpq_out_str(fic,10,&(m(i,j).rep()));
00217     fprintf(fic,"%.32Le+(%.32Le)*I\n];\n",m(i,j).real(),m(i,j).imag());
00218   }
00219 }

void printmatfilescilab ( const typmat< complex< double > > &  m,
const char *  name,
FILE *  fic 
) [inline]

Definition at line 166 of file io.cc.

00167 {int i;
00168   fprintf(fic,"%s=[",name);
00169   for(i=0;i<m.nrow-1;i++)
00170     {
00171       int j;
00172       fprintf(fic,"");
00173       for(j=0;j<m.ncol-1;j++)
00174         {
00175           fprintf(fic,"%.16e+(%.16e)*I,",m(i,j).real(),m(i,j).imag());
00176         }
00177       //mpq_out_str(fic,10,&(m(i,j).rep()));
00178       fprintf(fic,"%.16e+(%.16e)*I;\n",m(i,j).real(),m(i,j).imag());
00179     }
00180   {
00181     int j;
00182     fprintf(fic,"");
00183     for(j=0;j<m.ncol-1;j++)
00184       {
00185         //mpq_out_str(fic,10,&(m(i,j).rep()));
00186           fprintf(fic,"%.16e+(%.16e)*I,",m(i,j).real(),m(i,j).imag());
00187       }
00188     //mpq_out_str(fic,10,&(m(i,j).rep()));
00189     fprintf(fic,"%.16e+(%.16e)*I\n];\n",m(i,j).real(),m(i,j).imag());
00190   }
00191 }

void printmon ( FILE *  fic,
mon  m 
)

Definition at line 478 of file io.cc.

References printcoeff().

Referenced by printdump().

00479 {
00480   printcoeff(fic,m.GetCoeff());
00481   for(int i=0;i<=lvar(m.rep);i++)
00482      {
00483        if (m.GetDegree(i)>=1)
00484          {
00485            fprintf(fic,"*x%d",i);
00486            if (m.GetDegree(i)>1)
00487              fprintf(fic,"^%d",(int)m.GetDegree(i));
00488          }
00489      }
00490 }

void readdump ( FILE *  fic,
typdump &  toto 
) [inline]

cin.eof();)

Definition at line 522 of file io.cc.

00523 {
00524   typedef typename typdump::value_type pol;
00525   pol p;
00526   char * chaine=(char*)malloc(10000001);
00527   for (;fgets(chaine,10000000,fic)!=NULL;)
00528     {
00529       printf("chainelue %s\n",chaine);fflush(stdout);
00530       toto.push_back(p=pol(chaine));
00531       cout<<"g pushe "<<p<<endl; 
00532     }
00533   free(chaine);
00534 }

void readfile ( typP &  toto,
char *  name 
) [inline]

cin.eof();)

Definition at line 424 of file io.cc.

Referenced by main().

00425 {
00426 
00427   typedef typename typP::value_type pol;
00428   pol p;
00429   FILE *fic=fopen(name,"r");
00430   char * chaine=(char*)malloc(10000001);
00431   for (;fgets(chaine,10000000,fic)!=NULL;)
00432     {
00433       printf("chainelue %s\n",chaine);
00434       cout<<"flush"<<endl;
00435       fflush(stdout);
00436       cout<<"despuesfflush"<<endl;
00437       cout<<pol(chaine)<<endl;
00438       toto.push_back(p=pol(chaine));
00439       cout<<"g pushe "<<p<<endl; 
00440     }
00441   fclose(fic);
00442   free(chaine);
00443 }


Generated on 6 Dec 2012 for borderbasix by  doxygen 1.6.1