Changeset a527a41 in git


Ignore:
Timestamp:
Jul 9, 2018, 2:39:53 PM (6 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
43fa86cc32c42433e618d6c2978915bf8a580e66
Parents:
ac754db5ea554de8a6115ff7e914fb77dc57c434
Message:
move *Eati/*EatLong to numbers.cc
Location:
libpolys/coeffs
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/ffields.cc

    rac754d ra527a41  
    499499* read an integer (with reduction mod p)
    500500*/
    501 static const char* nfEati(const char *s, int *i, const coeffs r)
    502 {
    503   if (*s >= '0' && *s <= '9')
    504   {
    505     *i = 0;
    506     do
    507     {
    508       *i *= 10;
    509       *i += *s++ - '0';
    510       if (*i > (MAX_INT_VAL / 10)) *i = *i % r->m_nfCharP;
    511     }
    512     while (*s >= '0' && *s <= '9');
    513     if (*i >= r->m_nfCharP) *i = *i % r->m_nfCharP;
    514   }
    515   else *i = 1;
    516   return s;
     501static inline const char* nfEati(const char *s, int *i, const coeffs r)
     502{
     503  return nEati((char *)s,i,r->m_nfCharP);
    517504}
    518505
  • libpolys/coeffs/flintcf_Q.cc

    rac754d ra527a41  
    4444  return s;
    4545}
    46 
    47 static const char* Eati(const char *s, int *i)
    48 {
    49 
    50   if (((*s) >= '0') && ((*s) <= '9'))
    51   {
    52     unsigned long ii=0L;
    53     do
    54     {
    55       ii *= 10;
    56       ii += *s++ - '0';
    57     }
    58     while (((*s) >= '0') && ((*s) <= '9'));
    59     *i=(int)ii;
    60   }
    61   else (*i) = 1;
    62   return s;
    63 }
    64 
    65 
    6646
    6747static void CoeffWrite(const coeffs r, BOOLEAN details)
     
    303283// we only read "monomials" (i.e. [-][digits][parameter]),
    304284// everythings else (+,*,^,()) is left to the singular interpreter
    305   const char *s=st;
     285  char *s=(char *)st;
    306286  *a=(number)omAlloc(sizeof(fmpq_poly_t));
    307287  fmpq_poly_init((fmpq_poly_ptr)(*a));
     
    329309    {
    330310      int i=1;
    331       s=Eati(s,&i);
     311      s=nEati(s,&i,0);
    332312      if (i!=1)
    333313      {
  • libpolys/coeffs/longrat0.cc

    rac754d ra527a41  
    2828
    2929/*2
    30 * extracts a long integer from s, returns the rest
    31 */
    32 const char * nlEatLong(char *s, mpz_ptr i)
    33 {
    34   const char * start=s;
    35 
    36   while (*s >= '0' && *s <= '9') s++;
    37   if (*s=='\0')
    38   {
    39     mpz_set_str(i,start,10);
    40   }
    41   else
    42   {
    43     char c=*s;
    44     *s='\0';
    45     mpz_set_str(i,start,10);
    46     *s=c;
    47   }
    48   return s;
    49 }
    50 
    51 /*2
    5230* extracts the number a from s, returns the rest
    5331*/
     
    6846    mpz_ptr n=(*a)->n;
    6947    mpz_init(z);
    70     s = nlEatLong((char *)s, z);
     48    s = nEatLong((char *)s, z);
    7149    if (*s == '/')
    7250    {
     
    7452      (*a)->s = 0;
    7553      s++;
    76       s = nlEatLong((char *)s, n);
     54      s = nEatLong((char *)s, n);
    7755      if (mpz_cmp_si(n,0L)==0)
    7856      {
  • libpolys/coeffs/modulop.cc

    rac754d ra527a41  
    264264#endif
    265265
    266 static const char* npEati(const char *s, int *i, const coeffs r)
    267 {
    268   if (((*s) >= '0') && ((*s) <= '9'))
    269   {
    270     unsigned long ii=0L;
    271     do
    272     {
    273       ii *= 10;
    274       ii += *s++ - '0';
    275       if (ii >= (MAX_INT_VAL / 10)) ii = ii % r->ch;
    276     }
    277     while (((*s) >= '0') && ((*s) <= '9'));
    278     if (ii >= (unsigned long)r->ch) ii = ii % r->ch;
    279     *i=(int)ii;
    280   }
    281   else (*i) = 1;
    282   return s;
     266static inline const char* npEati(const char *s, int *i, const coeffs r)
     267{
     268  return nEati((char *)s,i,r->ch);
    283269}
    284270
  • libpolys/coeffs/numbers.cc

    rac754d ra527a41  
    598598CanonicalForm n_convSingNFactoryN( number n, BOOLEAN setChar, const coeffs r )
    599599{ STATISTIC(n_convSingNFactoryN); assume(r != NULL); assume(r->convSingNFactoryN != NULL); return r->convSingNFactoryN(n, setChar, r); }
     600
     601
     602char* nEati(char *s, int *i, int m)
     603{
     604
     605  if (((*s) >= '0') && ((*s) <= '9'))
     606  {
     607    unsigned long ii=0L;
     608    do
     609    {
     610      ii *= 10;
     611      ii += *s++ - '0';
     612      if ((m!=0) && (ii>m)) ii=ii%m;
     613    }
     614    while (((*s) >= '0') && ((*s) <= '9'));
     615    if ((m!=0) && (ii>m)) ii=ii%m;
     616    *i=(int)ii;
     617  }
     618  else (*i) = 1;
     619  return s;
     620}
     621
     622/// extracts a long integer from s, returns the rest
     623char * nEatLong(char *s, mpz_ptr i)
     624{
     625  const char * start=s;
     626
     627  while (*s >= '0' && *s <= '9') s++;
     628  if (*s=='\0')
     629  {
     630    mpz_set_str(i,start,10);
     631  }
     632  else
     633  {
     634    char c=*s;
     635    *s='\0';
     636    mpz_set_str(i,start,10);
     637    *s=c;
     638  }
     639  return s;
     640}
     641
  • libpolys/coeffs/numbers.h

    rac754d ra527a41  
    105105// void ndClearDenominators(ICoeffsEnumerator& numberCollectionEnumerator, number& d, const coeffs r);
    106106
     107/// helper routine: read an int from a string (mod m), return a pointer to the rest
     108char* nEati(char *s, int *i, int m);
     109
     110/// extracts a long integer from s, returns the rest
     111char * nEatLong(char *s, mpz_ptr i);
    107112#endif
Note: See TracChangeset for help on using the changeset viewer.