Changeset 850277 in git for libpolys


Ignore:
Timestamp:
Mar 20, 2014, 3:27:31 PM (10 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '2a584933abf2a2d3082034c7586d38bb6de1a30a')
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)
Location:
libpolys
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 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.