Changeset 125f52 in git


Ignore:
Timestamp:
Jun 22, 2021, 2:38:53 PM (3 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '5b153614cbc72bfa198d75b1e9e33dab2645d9fe')
Children:
2f2b5f27210262b4fd98f73ae2256916f77e8eff
Parents:
5a6c9c9f73563e1e976f2d14b37862e4c77cd9e3
Message:
fix: convert R, longR -> bigint
Location:
libpolys/coeffs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/longrat.cc

    r5a6c9c r125f52  
    423423}
    424424
     425static number nlMapR_BI(number from, const coeffs src, const coeffs dst)
     426{
     427  assume( getCoeffType(src) == n_R );
     428
     429  double f=nrFloat(from); // FIXME? TODO? // extern float   nrFloat(number n);
     430  if (f==0.0) return INT_TO_SR(0);
     431  long l=long(f);
     432  return nlInit(l,dst);
     433}
     434
    425435static number nlMapLongR(number from, const coeffs src, const coeffs dst)
    426436{
     
    503513}
    504514
     515static number nlMapLongR_BI(number from, const coeffs src, const coeffs dst)
     516{
     517  assume( getCoeffType(src) == n_long_R );
     518
     519  gmp_float *ff=(gmp_float*)from;
     520  if (mpf_fits_slong_p(ff->t))
     521  {
     522    long l=mpf_get_si(ff->t);
     523    return nlInit(l,dst);
     524  }
     525  return nlInit(0,dst);
     526}
    505527
    506528static number nlMapC(number from, const coeffs src, const coeffs dst)
     
    24592481  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
    24602482  {
    2461     return nlMapR;
     2483    if (dst->is_field) /* R -> Q */
     2484      return nlMapR;
     2485    else
     2486      return nlMapR_BI; /* R -> bigint */
    24622487  }
    24632488  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
    24642489  {
    2465     return nlMapLongR; /* long R -> Q */
     2490    if (dst->is_field)
     2491      return nlMapLongR; /* long R -> Q */
     2492    else
     2493      return nlMapLongR_BI;
    24662494  }
    24672495  if (nCoeff_is_long_C(src))
  • libpolys/coeffs/mpr_complex.h

    r5a6c9c r125f52  
    148148#endif
    149149
    150 private:
     150public:
    151151  mpf_t t;
    152152};
Note: See TracChangeset for help on using the changeset viewer.