My Project  debian-1:4.1.1-p2+ds-4build4
Data Structures | Macros | Functions | Variables
shortfl.cc File Reference
#include "misc/auxiliary.h"
#include "misc/mylimits.h"
#include "reporter/reporter.h"
#include "omalloc/omalloc.h"
#include "coeffs/numbers.h"
#include "coeffs/coeffs.h"
#include "coeffs/mpr_complex.h"
#include "coeffs/shortfl.h"
#include "coeffs/longrat.h"
#include <cmath>

Go to the source code of this file.

Data Structures

union  nf
 

Macros

#define SR_HDL(A)   ((long)(A))
 
#define IS_INT(A)   ((A)->s==3)
 
#define IS_IMM(A)   (SR_HDL(A) & SR_INT)
 
#define GET_NOM(A)   ((A)->z)
 
#define GET_DENOM(A)   ((A)->n)
 

Functions

static BOOLEAN nrDBTest (number a, const coeffs r, const char *f, const int l)
 
static nMapFunc nrSetMap (const coeffs src, const coeffs dst)
 Get a mapping function from src into the domain of this type: n_R. More...
 
static number nrMapQ (number from, const coeffs r, const coeffs aRing)
 
SI_FLOAT nrFloat (number n)
 Converts a n_R number into a float. Needed by Maps. More...
 
static void nrCoeffWrite (const coeffs r, BOOLEAN)
 
static BOOLEAN nrGreaterZero (number k, const coeffs r)
 
static number nrMult (number a, number b, const coeffs r)
 
static number nrInit (long i, const coeffs r)
 
static long nrInt (number &n, const coeffs r)
 
static number nrAdd (number a, number b, const coeffs r)
 
static number nrSub (number a, number b, const coeffs r)
 
static BOOLEAN nrIsZero (number a, const coeffs r)
 
static BOOLEAN nrIsOne (number a, const coeffs r)
 
static BOOLEAN nrIsMOne (number a, const coeffs r)
 
static number nrDiv (number a, number b, const coeffs r)
 
static number nrInvers (number c, const coeffs r)
 
static number nrNeg (number c, const coeffs r)
 
static BOOLEAN nrGreater (number a, number b, const coeffs r)
 
static BOOLEAN nrEqual (number a, number b, const coeffs r)
 
static void nrWrite (number a, const coeffs r)
 
static const char * nrRead (const char *s, number *a, const coeffs r)
 
static BOOLEAN nrDBTest (number a, const char *f, const int l, const coeffs r)
 
static number nrMapP (number from, const coeffs aRing, const coeffs r)
 
static number nrMapLongR (number from, const coeffs aRing, const coeffs r)
 
static number nrMapC (number from, const coeffs aRing, const coeffs r)
 
static number nrMapZ (number from, const coeffs aRing, const coeffs r)
 
static char * nrCoeffString (const coeffs r)
 
static char * nrCoeffName (const coeffs r)
 
BOOLEAN nrInitChar (coeffs n, void *p)
 Initialize r. More...
 

Variables

static const SI_FLOAT nrEps = 1.0e-3
 

Macro Definition Documentation

◆ GET_DENOM

#define GET_DENOM (   A)    ((A)->n)

◆ GET_NOM

#define GET_NOM (   A)    ((A)->z)

◆ IS_IMM

#define IS_IMM (   A)    (SR_HDL(A) & SR_INT)

◆ IS_INT

#define IS_INT (   A)    ((A)->s==3)

◆ SR_HDL

#define SR_HDL (   A)    ((long)(A))

Function Documentation

◆ nrAdd()

static number nrAdd ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 111 of file shortfl.cc.

112 {
113  assume( getCoeffType(r) == n_R );
114 
115  SI_FLOAT x = nf(a).F();
116  SI_FLOAT y = nf(b).F();
117  SI_FLOAT f = x + y;
118  if (x > 0.0)
119  {
120  if (y < 0.0)
121  {
122  x = f / (x - y);
123  if (x < 0.0)
124  x = -x;
125  if (x < nrEps)
126  f = 0.0;
127  }
128  }
129  else
130  {
131  if (y > 0.0)
132  {
133  x = f / (y - x);
134  if (x < 0.0)
135  x = -x;
136  if (x < nrEps)
137  f = 0.0;
138  }
139  }
140  return nf(f).N();
141 }
Variable x
Definition: cfModGcd.cc:4023
CanonicalForm b
Definition: cfModGcd.cc:4044
FILE * f
Definition: checklibs.c:9
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:32
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
const CanonicalForm int const CFList const Variable & y
Definition: facAbsFact.cc:57
#define assume(x)
Definition: mod2.h:390
static const SI_FLOAT nrEps
Definition: shortfl.cc:39
#define SI_FLOAT
Definition: shortfl.h:15
Definition: gnumpfl.cc:28
SI_FLOAT F() const
Definition: gnumpfl.cc:33
number N() const
Definition: gnumpfl.cc:34

◆ nrCoeffName()

static char* nrCoeffName ( const coeffs  r)
static

Definition at line 705 of file shortfl.cc.

706 {
707  return (char*)"Float()";
708 }

◆ nrCoeffString()

static char* nrCoeffString ( const coeffs  r)
static

Definition at line 700 of file shortfl.cc.

701 {
702  return omStrDup("Float()");
703 }
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ nrCoeffWrite()

static void nrCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 63 of file shortfl.cc.

64 {
65  assume( getCoeffType(r) == n_R );
66  PrintS("Float()"); /* R */
67 }
void PrintS(const char *s)
Definition: reporter.cc:284

◆ nrDBTest() [1/2]

static BOOLEAN nrDBTest ( number  a,
const char *  f,
const int  l,
const coeffs  r 
)
static

Definition at line 387 of file shortfl.cc.

388 {
389  assume( getCoeffType(r) == n_R );
390 
391  return TRUE;
392 }
#define TRUE
Definition: auxiliary.h:98

◆ nrDBTest() [2/2]

static BOOLEAN nrDBTest ( number  a,
const coeffs  r,
const char *  f,
const int  l 
)
static

◆ nrDiv()

static number nrDiv ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 200 of file shortfl.cc.

201 {
202  assume( getCoeffType(r) == n_R );
203 
204  SI_FLOAT n = nf(b).F();
205  if (n == 0.0)
206  {
207  WerrorS(nDivBy0);
208  return nf((SI_FLOAT)0.0).N();
209  }
210  else
211  return nf(nf(a).F() / n).N();
212 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char *const nDivBy0
Definition: numbers.h:89

◆ nrEqual()

static BOOLEAN nrEqual ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 241 of file shortfl.cc.

242 {
243  assume( getCoeffType(r) == n_R );
244 
245  number x = nrSub(a,b,r);
246  return nf(x).F() == nf((SI_FLOAT)0.0).F();
247 }
static number nrSub(number a, number b, const coeffs r)
Definition: shortfl.cc:143

◆ nrFloat()

SI_FLOAT nrFloat ( number  n)

Converts a n_R number into a float. Needed by Maps.

Definition at line 57 of file shortfl.cc.

58 {
59  return nf(n).F();
60 }

◆ nrGreater()

static BOOLEAN nrGreater ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 234 of file shortfl.cc.

235 {
236  assume( getCoeffType(r) == n_R );
237 
238  return nf(a).F() > nf(b).F();
239 }

◆ nrGreaterZero()

static BOOLEAN nrGreaterZero ( number  k,
const coeffs  r 
)
static

Definition at line 70 of file shortfl.cc.

71 {
72  assume( getCoeffType(r) == n_R );
73 
74  return nf(k).F() >= 0.0;
75 }
int k
Definition: cfEzgcd.cc:92

◆ nrInit()

static number nrInit ( long  i,
const coeffs  r 
)
static

Definition at line 87 of file shortfl.cc.

88 {
89  assume( getCoeffType(r) == n_R );
90 
91  SI_FLOAT f = (SI_FLOAT)i;
92  return nf(nf(f).F()).N();
93 }
int i
Definition: cfEzgcd.cc:125

◆ nrInitChar()

BOOLEAN nrInitChar ( coeffs  n,
void *  p 
)

Initialize r.

Definition at line 710 of file shortfl.cc.

711 {
712  assume( getCoeffType(n) == n_R );
713 
714  assume( p == NULL );
715 
716  n->is_field=TRUE;
717  n->is_domain=TRUE;
718  n->rep=n_rep_float;
719 
720  //n->cfKillChar = ndKillChar; /* dummy */
721  n->ch = 0;
722  n->cfCoeffString = nrCoeffString;
723  n->cfCoeffName = nrCoeffName;
724 
725  n->cfInit = nrInit;
726  n->cfInt = nrInt;
727  n->cfAdd = nrAdd;
728  n->cfSub = nrSub;
729  n->cfMult = nrMult;
730  n->cfDiv = nrDiv;
731  n->cfExactDiv= nrDiv;
732  n->cfInpNeg = nrNeg;
733  n->cfInvers= nrInvers;
734  //n->cfCopy = ndCopy;
735  n->cfGreater = nrGreater;
736  n->cfEqual = nrEqual;
737  n->cfIsZero = nrIsZero;
738  n->cfIsOne = nrIsOne;
739  n->cfIsMOne = nrIsMOne;
740  n->cfGreaterZero = nrGreaterZero;
741  n->cfWriteLong = nrWrite;
742  n->cfRead = nrRead;
743  //n->cfPower = nrPower;
744  n->cfSetMap = nrSetMap;
745  n->cfCoeffWrite = nrCoeffWrite;
746 
747  /* nName= ndName; */
748  /*nSize = ndSize;*/
749 #ifdef LDEBUG
750  n->cfDBTest=nrDBTest; // not yet implemented: nrDBTest;
751 #endif
752 
753  //n->nCoeffIsEqual = ndCoeffIsEqual;
754 
755  n->float_len = SHORT_REAL_LENGTH;
756  n->float_len2 = SHORT_REAL_LENGTH;
757 
758  // TODO: Any variables?
759  return FALSE;
760 }
#define FALSE
Definition: auxiliary.h:94
int p
Definition: cfModGcd.cc:4019
@ n_rep_float
(float), see shortfl.h
Definition: coeffs.h:117
#define SHORT_REAL_LENGTH
Definition: numbers.h:58
#define NULL
Definition: omList.c:10
static void nrCoeffWrite(const coeffs r, BOOLEAN)
Definition: shortfl.cc:63
static number nrMult(number a, number b, const coeffs r)
Definition: shortfl.cc:77
static nMapFunc nrSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type: n_R.
Definition: shortfl.cc:669
static number nrInvers(number c, const coeffs r)
Definition: shortfl.cc:214
static number nrDiv(number a, number b, const coeffs r)
Definition: shortfl.cc:200
static number nrAdd(number a, number b, const coeffs r)
Definition: shortfl.cc:111
static number nrNeg(number c, const coeffs r)
Definition: shortfl.cc:227
static BOOLEAN nrDBTest(number a, const coeffs r, const char *f, const int l)
static BOOLEAN nrEqual(number a, number b, const coeffs r)
Definition: shortfl.cc:241
static void nrWrite(number a, const coeffs r)
Definition: shortfl.cc:249
static char * nrCoeffString(const coeffs r)
Definition: shortfl.cc:700
static BOOLEAN nrIsZero(number a, const coeffs r)
Definition: shortfl.cc:175
static number nrInit(long i, const coeffs r)
Definition: shortfl.cc:87
static BOOLEAN nrGreater(number a, number b, const coeffs r)
Definition: shortfl.cc:234
static BOOLEAN nrIsMOne(number a, const coeffs r)
Definition: shortfl.cc:191
static const char * nrRead(const char *s, number *a, const coeffs r)
Definition: shortfl.cc:316
static BOOLEAN nrIsOne(number a, const coeffs r)
Definition: shortfl.cc:182
static char * nrCoeffName(const coeffs r)
Definition: shortfl.cc:705
static long nrInt(number &n, const coeffs r)
Definition: shortfl.cc:98
static BOOLEAN nrGreaterZero(number k, const coeffs r)
Definition: shortfl.cc:70

◆ nrInt()

static long nrInt ( number &  n,
const coeffs  r 
)
static

Definition at line 98 of file shortfl.cc.

99 {
100  assume( getCoeffType(r) == n_R );
101 
102  long i;
103  SI_FLOAT f = nf(n).F();
104  if (((SI_FLOAT)(-MAX_INT_VAL-1) <= f) || ((SI_FLOAT)MAX_INT_VAL >= f))
105  i = (long)f;
106  else
107  i = 0;
108  return i;
109 }
const int MAX_INT_VAL
Definition: mylimits.h:12

◆ nrInvers()

static number nrInvers ( number  c,
const coeffs  r 
)
static

Definition at line 214 of file shortfl.cc.

215 {
216  assume( getCoeffType(r) == n_R );
217 
218  SI_FLOAT n = nf(c).F();
219  if (n == 0.0)
220  {
221  WerrorS(nDivBy0);
222  return nf((SI_FLOAT)0.0).N();
223  }
224  return nf(1.0 / n).N();
225 }

◆ nrIsMOne()

static BOOLEAN nrIsMOne ( number  a,
const coeffs  r 
)
static

Definition at line 191 of file shortfl.cc.

192 {
193  assume( getCoeffType(r) == n_R );
194 
195  SI_FLOAT aa=nf(a).F()+1.0;
196  if (aa<0.0) aa=-aa;
197  return (aa<nrEps);
198 }

◆ nrIsOne()

static BOOLEAN nrIsOne ( number  a,
const coeffs  r 
)
static

Definition at line 182 of file shortfl.cc.

183 {
184  assume( getCoeffType(r) == n_R );
185 
186  SI_FLOAT aa=nf(a).F()-1.0;
187  if (aa<0.0) aa=-aa;
188  return (aa<nrEps);
189 }

◆ nrIsZero()

static BOOLEAN nrIsZero ( number  a,
const coeffs  r 
)
static

Definition at line 175 of file shortfl.cc.

176 {
177  assume( getCoeffType(r) == n_R );
178 
179  return (0.0 == nf(a).F());
180 }

◆ nrMapC()

static number nrMapC ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 414 of file shortfl.cc.

415 {
416  assume( getCoeffType(r) == n_R );
417  assume( getCoeffType(aRing) == n_long_C );
418 
419  gmp_float h = ((gmp_complex*)from)->real();
420  SI_FLOAT t =(SI_FLOAT)mpf_get_d((mpf_srcptr)&h);
421  return nf(t).N();
422 }
gmp_complex numbers based on
Definition: mpr_complex.h:179
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:42
static Poly * h
Definition: janet.cc:972

◆ nrMapLongR()

static number nrMapLongR ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 405 of file shortfl.cc.

406 {
407  assume( getCoeffType(r) == n_R );
408  assume( getCoeffType(aRing) == n_long_R );
409 
410  SI_FLOAT t =(SI_FLOAT)mpf_get_d((mpf_srcptr)from);
411  return nf(t).N();
412 }
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:34

◆ nrMapP()

static number nrMapP ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 395 of file shortfl.cc.

396 {
397  assume( getCoeffType(r) == n_R );
398  assume( getCoeffType(aRing) == n_Zp );
399 
400  int i = (int)((long)from);
401  SI_FLOAT f = (SI_FLOAT)i;
402  return nf(f).N();
403 }
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30

◆ nrMapQ()

static number nrMapQ ( number  from,
const coeffs  r,
const coeffs  aRing 
)
static

Definition at line 425 of file shortfl.cc.

426 {
427 /* in longrat.h
428 #define SR_INT 1
429 #define mpz_size1(A) (ABS((A)->_mp_size))
430 */
431 #define SR_HDL(A) ((long)(A))
432 #define IS_INT(A) ((A)->s==3)
433 #define IS_IMM(A) (SR_HDL(A) & SR_INT)
434 #define GET_NOM(A) ((A)->z)
435 #define GET_DENOM(A) ((A)->n)
436 
437  assume( getCoeffType(r) == n_R );
438  assume( aRing->rep == n_rep_gap_rat );
439 
440  mpz_ptr z;
441  mpz_ptr zz=NULL;
442  if (IS_IMM(from))
443  {
444  zz=(mpz_ptr)omAlloc(sizeof(mpz_t));
445  mpz_init_set_si(zz,SR_TO_INT(from));
446  z=zz;
447  }
448  else
449  {
450  /* read out the enumerator */
451  z=GET_NOM(from);
452  }
453 
454  int i = mpz_size1(z);
455  mpf_t e;
456  mpf_init(e);
457  mpf_set_z(e,z);
458  int sign= mpf_sgn(e);
459  mpf_abs (e, e);
460 
461  if (zz!=NULL)
462  {
463  mpz_clear(zz);
464  omFreeSize(zz,sizeof(mpz_t));
465  }
466  /* if number was an integer, we are done*/
467  if(IS_IMM(from)|| IS_INT(from))
468  {
469  if(i>4)
470  {
471  WerrorS("SI_FLOAT overflow");
472  return nf(0.0).N();
473  }
474  double basis;
475  signed long int exp;
476  basis = mpf_get_d_2exp(&exp, e);
477  SI_FLOAT f= sign*ldexp(basis,exp);
478  mpf_clear(e);
479  return nf(f).N();
480  }
481 
482  /* else read out the denominator */
483  mpz_ptr n = GET_DENOM(from);
484  int j = mpz_size1(n);
485  if(j-i>4)
486  {
487  WerrorS("SI_FLOAT overflow");
488  mpf_clear(e);
489  return nf(0.0).N();
490  }
491  mpf_t d;
492  mpf_init(d);
493  mpf_set_z(d,n);
494 
495  /* and compute the quotient */
496  mpf_t q;
497  mpf_init(q);
498  mpf_div(q,e,d);
499 
500  double basis;
501  signed long int exp;
502  basis = mpf_get_d_2exp(&exp, q);
503  SI_FLOAT f = sign*ldexp(basis,exp);
504  mpf_clear(e);
505  mpf_clear(d);
506  mpf_clear(q);
507  return nf(f).N();
508 }
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:112
int j
Definition: facHensel.cc:105
#define SR_TO_INT(SR)
Definition: longrat.h:70
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
static int sign(int x)
Definition: ring.cc:3328
#define IS_INT(A)
#define IS_IMM(A)
#define GET_DENOM(A)
#define GET_NOM(A)
#define mpz_size1(A)
Definition: si_gmp.h:12

◆ nrMapZ()

static number nrMapZ ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 510 of file shortfl.cc.

511 {
512  assume( getCoeffType(r) == n_R );
513  assume( aRing->rep == n_rep_gap_gmp );
514 
515  mpz_ptr z;
516  mpz_ptr zz=NULL;
517  if (IS_IMM(from))
518  {
519  zz=(mpz_ptr)omAlloc(sizeof(mpz_t));
520  mpz_init_set_si(zz,SR_TO_INT(from));
521  z=zz;
522  }
523  else
524  {
525  /* read out the enumerator */
526  z=(mpz_ptr)from;
527  }
528 
529  int i = mpz_size1(z);
530  mpf_t e;
531  mpf_init(e);
532  mpf_set_z(e,z);
533  int sign= mpf_sgn(e);
534  mpf_abs (e, e);
535 
536  if (zz!=NULL)
537  {
538  mpz_clear(zz);
539  omFreeSize(zz,sizeof(mpz_t));
540  }
541  if(i>4)
542  {
543  WerrorS("float overflow");
544  return nf(0.0).N();
545  }
546  double basis;
547  signed long int exp;
548  basis = mpf_get_d_2exp(&exp, e);
549  SI_FLOAT f= sign*ldexp(basis,exp);
550  mpf_clear(e);
551  return nf(f).N();
552 }
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:113

◆ nrMult()

static number nrMult ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 77 of file shortfl.cc.

78 {
79  assume( getCoeffType(r) == n_R );
80 
81  return nf(nf(a).F() * nf(b).F()).N();
82 }

◆ nrNeg()

static number nrNeg ( number  c,
const coeffs  r 
)
static

Definition at line 227 of file shortfl.cc.

228 {
229  assume( getCoeffType(r) == n_R );
230 
231  return nf(-nf(c).F()).N();
232 }

◆ nrRead()

static const char* nrRead ( const char *  s,
number *  a,
const coeffs  r 
)
static

Definition at line 316 of file shortfl.cc.

317 {
318 
319  assume( getCoeffType(r) == n_R );
320 
321  static const char *nIllegalChar="illegal character in number";
322 
323  const char *t;
324  const char *start=s;
325  SI_FLOAT z1,z2;
326  SI_FLOAT n=1.0;
327 
328  s = nrEatr(s, &z1);
329  if (*s == '/')
330  {
331  if (s==start) { WerrorS(nIllegalChar);return s; }
332  s++;
333  s = nrEatr(s, &z2);
334  if (z2==0.0)
335  WerrorS(nDivBy0);
336  else
337  z1 /= z2;
338  }
339  else if (*s =='.')
340  {
341  if (s==start) { WerrorS(nIllegalChar);return s; }
342  s++;
343  t = s;
344  while (*t >= '0' && *t <= '9')
345  {
346  t++;
347  n *= 10.0;
348  }
349  s = nrEatr(s, &z2);
350  z1 = (z1*n + z2) / n;
351  if (*s=='e')
352  {
353  int e=0; /* exponent */
354  int si=1;/* sign of exponent */
355  s++;
356  if (*s=='+') s++;
357  else if (*s=='-') {s++; si=-1; }
358  while (*s >= '0' && *s <= '9')
359  {
360  e=e*10+(*s)-'0';
361  s++;
362  }
363  if (si==1)
364  {
365  while (e>0) {z1*=10.0; e--; }
366  }
367  else
368  {
369  while (e>0) {z1/=10.0; e--; }
370  }
371  }
372  }
373  *a = nf(z1).N();
374  return s;
375 }
const CanonicalForm int s
Definition: facAbsFact.cc:55

◆ nrSetMap()

static nMapFunc nrSetMap ( const coeffs  src,
const coeffs  dst 
)
static

Get a mapping function from src into the domain of this type: n_R.

Definition at line 669 of file shortfl.cc.

670 {
671  assume( getCoeffType(dst) == n_R );
672 
673  if (src->rep==n_rep_gap_rat) /*Q, Z */
674  {
675  return nrMapQ;
676  }
677  if (src->rep==n_rep_gap_gmp) /*Q, Z */
678  {
679  return nrMapZ;
680  }
681  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
682  {
683  return nrMapLongR;
684  }
685  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
686  {
687  return ndCopyMap;
688  }
689  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
690  {
691  return nrMapP;
692  }
693  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
694  {
695  return nrMapC;
696  }
697  return NULL;
698 }
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:905
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:831
@ n_rep_int
(int), see modulop.h
Definition: coeffs.h:111
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:118
@ n_rep_gmp_complex
(gmp_complex), see gnumpc.h
Definition: coeffs.h:119
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:850
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:251
static number nrMapQ(number from, const coeffs r, const coeffs aRing)
Definition: shortfl.cc:425
static number nrMapC(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:414
static number nrMapZ(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:510
static number nrMapP(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:395
static number nrMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:405

◆ nrSub()

static number nrSub ( number  a,
number  b,
const coeffs  r 
)
static

Definition at line 143 of file shortfl.cc.

144 {
145  assume( getCoeffType(r) == n_R );
146 
147  SI_FLOAT x = nf(a).F();
148  SI_FLOAT y = nf(b).F();
149  SI_FLOAT f = x - y;
150  if (x > 0.0)
151  {
152  if (y > 0.0)
153  {
154  x = f / (x + y);
155  if (x < 0.0)
156  x = -x;
157  if (x < nrEps)
158  f = 0.0;
159  }
160  }
161  else
162  {
163  if (y < 0.0)
164  {
165  x = f / (x + y);
166  if (x < 0.0)
167  x = -x;
168  if (x < nrEps)
169  f = 0.0;
170  }
171  }
172  return nf(f).N();
173 }

◆ nrWrite()

static void nrWrite ( number  a,
const coeffs  r 
)
static

Definition at line 249 of file shortfl.cc.

250 {
251  assume( getCoeffType(r) == n_R );
252 
253  //#if SIZEOF_DOUBLE == SIZEOF_LONG
254  //char ch[16];
255  //int n = sprintf(ch,"%12.6e", nf(a).F());
256  //#else
257  char ch[11];
258  int n = sprintf(ch,"%9.3e", nf(a).F());
259  //#endif
260  if (ch[0] == '-')
261  {
262  char* chbr = new char[n+3];
263  memcpy(&chbr[2],&ch[1],n-1);
264  chbr[0] = '-';
265  chbr[1] = '(';
266  chbr[n+1] = ')';
267  chbr[n+2] = '\0';
268  StringAppendS(chbr);
269  delete[] chbr;
270  }
271  else
272  StringAppend("(%s)",ch);
273 }
#define StringAppend
Definition: emacs.cc:79
void StringAppendS(const char *st)
Definition: reporter.cc:107

Variable Documentation

◆ nrEps

const SI_FLOAT nrEps = 1.0e-3
static

Definition at line 39 of file shortfl.cc.