Changeset 850277 in git


Ignore:
Timestamp:
Mar 20, 2014, 3:27:31 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
82393119769dfceb9f02d05dfaae6504348f93a4
Parents:
fb036e76ce9df79bac9d8b045ed2dee38b69a463
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2014-03-20 15:27:31+01:00
git-committer:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2014-03-20 15:28:38+01:00
Message:
chg: moved reading/writing numbers via ssi to coeffs (p.1)
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • Singular/Makefile.am

    rfb036e r850277  
    8686   scanner.cc\
    8787   sdb.cc\
    88    links/s_buff.cc\
    8988   links/silink.cc\
    9089   links/sing_dbm.cc\
     
    141140   sdb.h \
    142141   links/silink.h \
    143    links/s_buff.h \
    144142   links/sing_dbm.h \
    145143   sing_win.h \
     
    147145   links/ssiLink.h \
    148146   links/simpleipc.h \
    149    si_signals.h \
    150147   stype.h \
    151148   subexpr.h \
  • Singular/cntrlc.cc

    rfb036e r850277  
    3131#include <Singular/feOpt.h>
    3232#include <Singular/misc_ip.h>
    33 #include <Singular/si_signals.h>
     33#include <reporter/si_signals.h>
    3434#include <Singular/links/silink.h>
    3535#include <Singular/links/ssiLink.h>
  • Singular/fehelp.cc

    rfb036e r850277  
    2626#include <resources/omFindExec.h>
    2727
    28 #include <Singular/si_signals.h>
     28#include <reporter/si_signals.h>
    2929
    3030#include "ipid.h"
  • Singular/iparith.cc

    rfb036e r850277  
    8080//#include <kernel/mpr_inout.h>
    8181
    82 #include <Singular/si_signals.h>
     82#include <reporter/si_signals.h>
    8383
    8484
  • Singular/links/ndbm.cc

    rfb036e r850277  
    1717#include "singularconfig.h"
    1818#endif /* HAVE_CONFIG_H */
    19 #include <Singular/si_signals.h>
     19#include <reporter/si_signals.h>
    2020#include <kernel/mod2.h>
    2121#ifdef HAVE_DBM
  • Singular/links/pipeLink.cc

    rfb036e r850277  
    2929#include "lists.h"
    3030#include "pipeLink.h"
    31 #include <Singular/si_signals.h>
     31#include <reporter/si_signals.h>
    3232
    3333typedef struct
  • Singular/links/semaphore.c

    rfb036e r850277  
    1010
    1111#include <Singular/cntrlc.h>
    12 #include <Singular/si_signals.h>
     12#include <reporter/si_signals.h>
    1313
    1414#include <semaphore.h>
  • Singular/links/silink.cc

    rfb036e r850277  
    3434#include <Singular/links/ssiLink.h>
    3535#include <Singular/links/pipeLink.h>
    36 #include <Singular/si_signals.h>
     36#include <reporter/si_signals.h>
    3737#include "feOpt.h"
    3838
  • Singular/links/ssiLink.cc

    rfb036e r850277  
    2222
    2323#include <kernel/mod2.h>
    24 #include <Singular/si_signals.h>
     24#include <reporter/si_signals.h>
    2525// #include "mod2.h"
    2626
     
    4646#include <Singular/lists.h>
    4747#include <Singular/blackbox.h>
    48 #include <Singular/links/s_buff.h>
     48#include <libpolys/reporter/s_buff.h>
    4949#include <Singular/links/ssiLink.h>
    5050
     
    5252#include <Singular/links/simpleipc.h>
    5353#endif
    54 
    55 #include <Singular/si_signals.h>
    5654
    5755#define SSI_VERSION 6
     
    151149  //        or     3 6 <mpz_t raw nom.> <mpz_t raw denom.>
    152150  //        or     3 7 <mpz_t raw nom.>
    153   if(getCoeffType(cf)==n_Zp)
    154   {
    155     fprintf(d->f_write,"%d ",(int)(long)n);
    156     //if (d->f_debug!=NULL) fprintf(d->f_debug,"number: \"%ld\" ",(int)(long)n);
    157   }
    158   else if (getCoeffType(cf)==n_Q)
    159   {
    160     if(SR_HDL(n) & SR_INT)
    161     {
    162       #if SIZEOF_LONG == 4
    163       fprintf(d->f_write,"4 %ld ",SR_TO_INT(n));
    164       #else
    165       long nn=SR_TO_INT(n);
    166       if ((nn<POW_2_28)||(nn>= -POW_2_28))
    167         fprintf(d->f_write,"4 %ld ",nn);
    168       else
    169       {
    170         mpz_t tmp;
    171         mpz_init_set_si(tmp,nn);
    172         fputs("8 ",d->f_write);
    173         mpz_out_str (d->f_write,SSI_BASE, tmp);
    174         fputc(' ',d->f_write);
    175         mpz_clear(tmp);
    176       }
    177       #endif
    178       //if (d->f_debug!=NULL) fprintf(d->f_debug,"number: short \"%ld\" ",SR_TO_INT(n));
    179     }
    180     else if (n->s<2)
    181     {
    182       //gmp_fprintf(d->f_write,"%d %Zd %Zd ",n->s,n->z,n->n);
    183       fprintf(d->f_write,"%d ",n->s+5);
    184       mpz_out_str (d->f_write,SSI_BASE, n->z);
    185       fputc(' ',d->f_write);
    186       mpz_out_str (d->f_write,SSI_BASE, n->n);
    187       fputc(' ',d->f_write);
    188 
    189       //if (d->f_debug!=NULL) gmp_fprintf(d->f_debug,"number: s=%d gmp/gmp \"%Zd %Zd\" ",n->s,n->z,n->n);
    190     }
    191     else /*n->s==3*/
    192     {
    193       //gmp_fprintf(d->f_write,"3 %Zd ",n->z);
    194       fputs("8 ",d->f_write);
    195       mpz_out_str (d->f_write,SSI_BASE, n->z);
    196       fputc(' ',d->f_write);
    197 
    198       //if (d->f_debug!=NULL) gmp_fprintf(d->f_debug,"number: gmp \"%Zd\" ",n->z);
    199     }
    200   }
    201   else if (getCoeffType(cf)==n_transExt)
     151  if (getCoeffType(cf)==n_transExt)
    202152  {
    203153    fraction f=(fraction)n;
     
    209159    ssiWritePoly_R(d,POLY_CMD,(poly)n,cf->extRing);
    210160  }
     161  else if (cf->cfWriteFd!=NULL)
     162  {
     163    cf->cfWriteFd(n,d->f_write,cf);
     164  }
    211165  else WerrorS("coeff field not implemented");
    212166}
     
    214168void ssiWriteNumber(const ssiInfo *d, const number n)
    215169{
    216   // syntax is as follows:
    217   // case 1 Z/p:   3 <int>
    218   // case 2 Q:     3 4 <int>
    219   //        or     3 0 <mpz_t nominator> <mpz_t denominator>
    220   //        or     3 1  dto.
    221   //        or     3 3 <mpz_t nominator>
    222   //        or     3 5 <mpz_t raw nom.> <mpz_t raw denom.>
    223   //        or     3 6 <mpz_t raw nom.> <mpz_t raw denom.>
    224   //        or     3 7 <mpz_t raw nom.>
    225   if(rField_is_Zp(d->r))
    226   {
    227     fprintf(d->f_write,"%d ",(int)(long)n);
    228     //if (d->f_debug!=NULL) fprintf(d->f_debug,"number: \"%ld\" ",(int)(long)n);
    229   }
    230   else if (rField_is_Q(d->r))
    231   {
    232     if(SR_HDL(n) & SR_INT)
    233     {
    234       #if SIZEOF_LONG == 4
    235       fprintf(d->f_write,"4 %ld ",SR_TO_INT(n));
    236       #else
    237       long nn=SR_TO_INT(n);
    238       if ((nn<POW_2_28)||(nn>= -POW_2_28))
    239         fprintf(d->f_write,"4 %ld ",nn);
    240       else
    241       {
    242         mpz_t tmp;
    243         mpz_init_set_si(tmp,nn);
    244         fputs("8 ",d->f_write);
    245         mpz_out_str (d->f_write,SSI_BASE, tmp);
    246         fputc(' ',d->f_write);
    247         mpz_clear(tmp);
    248       }
    249       #endif
    250       //if (d->f_debug!=NULL) fprintf(d->f_debug,"number: short \"%ld\" ",SR_TO_INT(n));
    251     }
    252     else if (n->s<2)
    253     {
    254       //gmp_fprintf(d->f_write,"%d %Zd %Zd ",n->s,n->z,n->n);
    255       fprintf(d->f_write,"%d ",n->s+5);
    256       mpz_out_str (d->f_write,SSI_BASE, n->z);
    257       fputc(' ',d->f_write);
    258       mpz_out_str (d->f_write,SSI_BASE, n->n);
    259       fputc(' ',d->f_write);
    260 
    261       //if (d->f_debug!=NULL) gmp_fprintf(d->f_debug,"number: s=%d gmp/gmp \"%Zd %Zd\" ",n->s,n->z,n->n);
    262     }
    263     else /*n->s==3*/
    264     {
    265       //gmp_fprintf(d->f_write,"3 %Zd ",n->z);
    266       fputs("8 ",d->f_write);
    267       mpz_out_str (d->f_write,SSI_BASE, n->z);
    268       fputc(' ',d->f_write);
    269 
    270       //if (d->f_debug!=NULL) gmp_fprintf(d->f_debug,"number: gmp \"%Zd\" ",n->z);
    271     }
    272   }
    273   else WerrorS("coeff field not implemented");
     170  ssiWriteNumber_CF(d,n,d->r->cf);
    274171}
    275172
     
    571468number ssiReadNumber_CF(ssiInfo *d, const coeffs cf)
    572469{
    573   if (getCoeffType(cf) == n_Q)
    574   {
    575      return ssiReadQNumber(d);
    576   }
    577   else if (getCoeffType(cf) == n_Zp)
    578   {
    579     // read int
    580     int dd;
    581     dd=s_readint(d->f_read);
    582     return (number)(long)dd;
     470  if (cf->cfReadFd!=NULL)
     471  {
     472     return cf->cfReadFd(d->f_read,cf);
    583473  }
    584474  else if (getCoeffType(cf) == n_transExt)
     
    602492number ssiReadNumber(ssiInfo *d)
    603493{
    604   if (rField_is_Q(d->r))
    605   {
    606      return ssiReadQNumber(d);
    607   }
    608   else if (rField_is_Zp(d->r))
    609   {
    610     // read int
    611     int dd;
    612     dd=s_readint(d->f_read);
    613     return (number)(long)dd;
    614   }
    615   else Werror("coeffs not implemented");
    616   return NULL;
     494  return ssiReadNumber_CF(d,d->r->cf);
    617495}
    618496
  • Singular/misc_ip.cc

    rfb036e r850277  
    1818#include <misc/auxiliary.h>
    1919#include <kernel/mod2.h>
    20 #include <Singular/si_signals.h>
     20#include <reporter/si_signals.h>
    2121
    2222#include <factory/factory.h>
  • Singular/sdb.cc

    rfb036e r850277  
    1919#include <Singular/ipid.h>
    2020#include <Singular/sdb.h>
    21 #include <Singular/si_signals.h>
     21#include <reporter/si_signals.h>
    2222
    2323#ifdef HAVE_SDB
  • libpolys/coeffs/coeffs.h

    rfb036e r850277  
    1111/* for assume: */
    1212#include <reporter/reporter.h>
     13#include <reporter/s_buff.h>
    1314
    1415#include <coeffs/si_gmp.h>
     
    179180   void    (*cfDelete)(number * a, const coeffs r);
    180181   nMapFunc (*cfSetMap)(const coeffs src, const coeffs dst);
     182
     183   /// io via ssi:
     184   void    (*cfWriteFd)(number a, FILE *f, const coeffs r);
     185   number  (*cfReadFd)( s_buff f, const coeffs r);
    181186
    182187   /// For extensions (writes into global string buffer)
  • libpolys/coeffs/longrat.cc

    rfb036e r850277  
    26512651    return;
    26522652  }
    2653  
     2653
    26542654  // all coeffs are given by integers!!!
    26552655
     
    26672667    nlNormalize(n, cf); ++normalcount;
    26682668    cand1 = n;
    2669    
     2669
    26702670    if (SR_HDL(cand1)&SR_INT) { cand=cand1; break; }
    2671     assume(cand1->s==3); // all coeffs should be integers // ==0?!! after printing 
     2671    assume(cand1->s==3); // all coeffs should be integers // ==0?!! after printing
    26722672    s1=mpz_size1(cand1->z);
    26732673    if (s>s1)
     
    26842684
    26852685  numberCollectionEnumerator.Reset();
    2686  
     2686
    26872687  while (numberCollectionEnumerator.MoveNext() )
    26882688  {
     
    26952695
    26962696    assume( nlGreaterZero(cand,cf) );
    2697    
     2697
    26982698    if(nlIsOne(cand,cf))
    26992699    {
     
    27052705        c = nlNeg(c, cf);
    27062706        numberCollectionEnumerator.Reset();
    2707        
     2707
    27082708        while (numberCollectionEnumerator.MoveNext() )
    27092709        {
     
    27142714      return;
    27152715    }
    2716   } 
     2716  }
    27172717
    27182718  // part3: all coeffs = all coeffs / cand
    27192719  if (!lc_is_pos)
    27202720    cand = nlNeg(cand,cf);
    2721  
     2721
    27222722  c = cand;
    27232723  numberCollectionEnumerator.Reset();
     
    27382738
    27392739  numberCollectionEnumerator.Reset();
    2740  
     2740
    27412741  if( !numberCollectionEnumerator.MoveNext() ) // empty zero polynomial?
    27422742  {
     
    27572757
    27582758  int s=0;
    2759  
     2759
    27602760  const BOOLEAN lc_is_pos=nlGreaterZero(numberCollectionEnumerator.Current(),cf);
    27612761
     
    27832783  }
    27842784  while (numberCollectionEnumerator.MoveNext() );
    2785  
     2785
    27862786
    27872787  if (s==0) // nothing to do, all coeffs are already integers
     
    28022802        number& n = numberCollectionEnumerator.Current();
    28032803        n = nlNeg(n, cf);
    2804       } 
     2804      }
    28052805    }
    28062806//    assume( n_GreaterZero(c, cf) );
     
    28132813  // make the lead coeff positive
    28142814  numberCollectionEnumerator.Reset();
    2815  
     2815
    28162816  if (!lc_is_pos)
    28172817    cand = nlNeg(cand, cf);
    2818  
     2818
    28192819  c = cand;
    2820  
     2820
    28212821  while (numberCollectionEnumerator.MoveNext() )
    28222822  {
     
    28302830{
    28312831  return omStrDup("0");
     2832}
     2833
     2834#define SSI_BASE 16
     2835
     2836static void nlWriteFd(number n,FILE* f, const coeffs)
     2837{
     2838  if(SR_HDL(n) & SR_INT)
     2839  {
     2840    #if SIZEOF_LONG == 4
     2841    fprintf(f,"4 %ld ",SR_TO_INT(n));
     2842    #else
     2843    long nn=SR_TO_INT(n);
     2844    if ((nn<POW_2_28)||(nn>= -POW_2_28))
     2845      fprintf(f,"4 %ld ",nn);
     2846    else
     2847    {
     2848      mpz_t tmp;
     2849      mpz_init_set_si(tmp,nn);
     2850      fputs("8 ",f);
     2851      mpz_out_str (f,SSI_BASE, tmp);
     2852      fputc(' ',f);
     2853      mpz_clear(tmp);
     2854    }
     2855    #endif
     2856  }
     2857  else if (n->s<2)
     2858  {
     2859    //gmp_fprintf(f,"%d %Zd %Zd ",n->s,n->z,n->n);
     2860    fprintf(f,"%d ",n->s+5);
     2861    mpz_out_str (f,SSI_BASE, n->z);
     2862    fputc(' ',f);
     2863    mpz_out_str (f,SSI_BASE, n->n);
     2864    fputc(' ',f);
     2865
     2866    //if (d->f_debug!=NULL) gmp_fprintf(d->f_debug,"number: s=%d gmp/gmp \"%Zd %Zd\" ",n->s,n->z,n->n);
     2867  }
     2868  else /*n->s==3*/
     2869  {
     2870    //gmp_fprintf(d->f_write,"3 %Zd ",n->z);
     2871    fputs("8 ",f);
     2872    mpz_out_str (f,SSI_BASE, n->z);
     2873    fputc(' ',f);
     2874
     2875    //if (d->f_debug!=NULL) gmp_fprintf(d->f_debug,"number: gmp \"%Zd\" ",n->z);
     2876  }
     2877}
     2878
     2879static number nlReadFd(s_buff f, const coeffs)
     2880{
     2881  int sub_type=-1;
     2882  sub_type=s_readint(f);
     2883  switch(sub_type)
     2884  {
     2885     case 0:
     2886     case 1:
     2887       {// read mpz_t, mpz_t
     2888         number n=nlRInit(0);
     2889         mpz_init(n->n);
     2890         s_readmpz(f,n->z);
     2891         s_readmpz(f,n->n);
     2892         n->s=sub_type;
     2893         return n;
     2894       }
     2895
     2896     case 3:
     2897       {// read mpz_t
     2898         number n=nlRInit(0);
     2899         s_readmpz(f,n->z);
     2900         n->s=3; /*sub_type*/
     2901         return n;
     2902       }
     2903     case 4:
     2904       {
     2905         LONG dd=s_readlong(f);
     2906         //#if SIZEOF_LONG == 8
     2907         return INT_TO_SR(dd);
     2908         //#else
     2909         //return nlInit(dd,NULL);
     2910         //#endif
     2911       }
     2912     case 5:
     2913     case 6:
     2914       {// read raw mpz_t, mpz_t
     2915         number n=nlRInit(0);
     2916         mpz_init(n->n);
     2917         s_readmpz_base (f,n->z, SSI_BASE);
     2918         s_readmpz_base (f,n->n, SSI_BASE);
     2919         n->s=sub_type-5;
     2920         return n;
     2921       }
     2922     case 8:
     2923       {// read raw mpz_t
     2924         number n=nlRInit(0);
     2925         s_readmpz_base (f,n->z, SSI_BASE);
     2926         n->s=sub_type=3; /*subtype-5*/
     2927         return n;
     2928       }
     2929
     2930     default: Werror("error in reading number: invalid subtype %d",sub_type);
     2931              return NULL;
     2932  }
     2933  return NULL;
    28322934}
    28332935
     
    29013003  r->convFactoryNSingN=nlConvFactoryNSingN;
    29023004
     3005  // io via ssi
     3006  r->cfWriteFd=nlWriteFd;
     3007  r->cfReadFd=nlReadFd;
     3008
    29033009  // the variables: general stuff (required)
    29043010  r->nNULL = INT_TO_SR(0);
  • libpolys/coeffs/modulop.cc

    rfb036e r850277  
    430430  snprintf(s,11,"%d",r->ch);
    431431  return s;
     432}
     433
     434static void npWriteFd(number n, FILE* f, const coeffs r)
     435{
     436  fprintf(f,"%d ",(int)(long)n);
     437}
     438
     439static number npReadFd(s_buff f, const coeffs r)
     440{
     441  // read int
     442  int dd;
     443  dd=s_readint(f);
     444  return (number)(long)dd;
    432445}
    433446
     
    509522  r->convFactoryNSingN=npConvFactoryNSingN;
    510523
     524  // io via ssi
     525  r->cfWriteFd=npWriteFd;
     526  r->cfReadFd=npReadFd;
     527
    511528  // the variables:
    512529  r->nNULL = (number)0;
  • libpolys/reporter/Makefile.am

    rfb036e r850277  
    66#### libreporterdir = $(libdir)/singular
    77
    8 libreporter_la_SOURCES  = dError.cc reporter.cc
     8libreporter_la_SOURCES  = dError.cc reporter.cc s_buff.cc
    99## libreporter_la_LDFLAGS  = -release ${PACKAGE_VERSION}
    1010## libreporter_la_LIBADD   = ${top_builddir}/misc/libmisc.la
    1111
    1212libreporter_la_includedir  =$(includedir)/singular/reporter
    13 libreporter_la_include_HEADERS   = reporter.h
     13libreporter_la_include_HEADERS   = reporter.h s_buff.h si_signals.h
    1414
    1515
  • libpolys/reporter/s_buff.cc

    rfb036e r850277  
    88
    99#include <kernel/mod2.h>
    10 #include <coeffs/si_gmp.h>
     10#include <gmp.h>
    1111
    1212#include <omalloc/omalloc.h>
    13 #include <Singular/links/s_buff.h>
    14 #include <Singular/si_signals.h>
     13#include <reporter/s_buff.h>
     14#include <reporter/si_signals.h>
    1515
    1616//struct s_buff_s
  • libpolys/reporter/s_buff.h

    rfb036e r850277  
    33
    44#include<signal.h>
     5#include<gmp.h>
    56
    67struct s_buff_s
Note: See TracChangeset for help on using the changeset viewer.