My Project
Data Structures | Macros | Functions | Variables
shortfl.cc File Reference
#include "misc/auxiliary.h"
#include "misc/mylimits.h"
#include "reporter/reporter.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 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 102 of file shortfl.cc.

103 {
104  assume( getCoeffType(r) == n_R );
105 
106  SI_FLOAT x = nf(a).F();
107  SI_FLOAT y = nf(b).F();
108  SI_FLOAT f = x + y;
109  if (x > 0.0)
110  {
111  if (y < 0.0)
112  {
113  x = f / (x - y);
114  if (x < 0.0)
115  x = -x;
116  if (x < nrEps)
117  f = 0.0;
118  }
119  }
120  else
121  {
122  if (y > 0.0)
123  {
124  x = f / (y - x);
125  if (x < 0.0)
126  x = -x;
127  if (x < nrEps)
128  f = 0.0;
129  }
130  }
131  return nf(f).N();
132 }
Variable x
Definition: cfModGcd.cc:4084
CanonicalForm b
Definition: cfModGcd.cc:4105
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:53
#define assume(x)
Definition: mod2.h:387
static const SI_FLOAT nrEps
Definition: shortfl.cc:38
#define SI_FLOAT
Definition: shortfl.h:15
Definition: gnumpfl.cc:27
SI_FLOAT F() const
Definition: gnumpfl.cc:32
number N() const
Definition: gnumpfl.cc:33

◆ nrCoeffName()

static char* nrCoeffName ( const coeffs  r)
static

Definition at line 661 of file shortfl.cc.

662 {
663  return (char*)"Float()";
664 }

◆ nrCoeffString()

static char* nrCoeffString ( const coeffs  r)
static

Definition at line 656 of file shortfl.cc.

657 {
658  return omStrDup("Float()");
659 }
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ nrDBTest() [1/2]

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

Definition at line 378 of file shortfl.cc.

379 {
380  assume( getCoeffType(r) == n_R );
381 
382  return TRUE;
383 }
#define TRUE
Definition: auxiliary.h:100

◆ 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 191 of file shortfl.cc.

192 {
193  assume( getCoeffType(r) == n_R );
194 
195  SI_FLOAT n = nf(b).F();
196  if (n == 0.0)
197  {
198  WerrorS(nDivBy0);
199  return nf((SI_FLOAT)0.0).N();
200  }
201  else
202  return nf(nf(a).F() / n).N();
203 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char *const nDivBy0
Definition: numbers.h:87

◆ nrEqual()

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

Definition at line 232 of file shortfl.cc.

233 {
234  assume( getCoeffType(r) == n_R );
235 
236  number x = nrSub(a,b,r);
237  return nf(x).F() == nf((SI_FLOAT)0.0).F();
238 }
static number nrSub(number a, number b, const coeffs r)
Definition: shortfl.cc:134

◆ nrFloat()

SI_FLOAT nrFloat ( number  n)

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

Definition at line 56 of file shortfl.cc.

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

◆ nrGreater()

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

Definition at line 225 of file shortfl.cc.

226 {
227  assume( getCoeffType(r) == n_R );
228 
229  return nf(a).F() > nf(b).F();
230 }

◆ nrGreaterZero()

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

Definition at line 61 of file shortfl.cc.

62 {
63  assume( getCoeffType(r) == n_R );
64 
65  return nf(k).F() >= 0.0;
66 }
int k
Definition: cfEzgcd.cc:99

◆ nrInit()

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

Definition at line 78 of file shortfl.cc.

79 {
80  assume( getCoeffType(r) == n_R );
81 
82  SI_FLOAT f = (SI_FLOAT)i;
83  return nf(nf(f).F()).N();
84 }
int i
Definition: cfEzgcd.cc:132

◆ nrInitChar()

BOOLEAN nrInitChar ( coeffs  n,
void *  p 
)

Initialize r.

Definition at line 666 of file shortfl.cc.

667 {
668  assume( getCoeffType(n) == n_R );
669 
670  assume( p == NULL );
671 
672  n->is_field=TRUE;
673  n->is_domain=TRUE;
674  n->rep=n_rep_float;
675 
676  //n->cfKillChar = ndKillChar; /* dummy */
677  n->ch = 0;
678  n->cfCoeffName = nrCoeffName;
679 
680  n->cfInit = nrInit;
681  n->cfInt = nrInt;
682  n->cfAdd = nrAdd;
683  n->cfSub = nrSub;
684  n->cfMult = nrMult;
685  n->cfDiv = nrDiv;
686  n->cfExactDiv= nrDiv;
687  n->cfInpNeg = nrNeg;
688  n->cfInvers= nrInvers;
689  //n->cfCopy = ndCopy;
690  n->cfGreater = nrGreater;
691  n->cfEqual = nrEqual;
692  n->cfIsZero = nrIsZero;
693  n->cfIsOne = nrIsOne;
694  n->cfIsMOne = nrIsMOne;
695  n->cfGreaterZero = nrGreaterZero;
696  n->cfWriteLong = nrWrite;
697  n->cfRead = nrRead;
698  //n->cfPower = nrPower;
699  n->cfSetMap = nrSetMap;
700 
701  /* nName= ndName; */
702  /*nSize = ndSize;*/
703 #ifdef LDEBUG
704  n->cfDBTest=nrDBTest; // not yet implemented: nrDBTest;
705 #endif
706 
707  //n->nCoeffIsEqual = ndCoeffIsEqual;
708 
709  n->float_len = SHORT_REAL_LENGTH;
710  n->float_len2 = SHORT_REAL_LENGTH;
711 
712  // TODO: Any variables?
713  return FALSE;
714 }
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4080
@ n_rep_float
(float), see shortfl.h
Definition: coeffs.h:117
#define SHORT_REAL_LENGTH
Definition: numbers.h:57
#define NULL
Definition: omList.c:12
static number nrMult(number a, number b, const coeffs r)
Definition: shortfl.cc:68
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:625
static number nrInvers(number c, const coeffs r)
Definition: shortfl.cc:205
static number nrDiv(number a, number b, const coeffs r)
Definition: shortfl.cc:191
static number nrAdd(number a, number b, const coeffs r)
Definition: shortfl.cc:102
static number nrNeg(number c, const coeffs r)
Definition: shortfl.cc:218
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:232
static void nrWrite(number a, const coeffs r)
Definition: shortfl.cc:240
static BOOLEAN nrIsZero(number a, const coeffs r)
Definition: shortfl.cc:166
static number nrInit(long i, const coeffs r)
Definition: shortfl.cc:78
static BOOLEAN nrGreater(number a, number b, const coeffs r)
Definition: shortfl.cc:225
static BOOLEAN nrIsMOne(number a, const coeffs r)
Definition: shortfl.cc:182
static const char * nrRead(const char *s, number *a, const coeffs r)
Definition: shortfl.cc:307
static BOOLEAN nrIsOne(number a, const coeffs r)
Definition: shortfl.cc:173
static char * nrCoeffName(const coeffs r)
Definition: shortfl.cc:661
static long nrInt(number &n, const coeffs r)
Definition: shortfl.cc:89
static BOOLEAN nrGreaterZero(number k, const coeffs r)
Definition: shortfl.cc:61

◆ nrInt()

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

Definition at line 89 of file shortfl.cc.

90 {
91  assume( getCoeffType(r) == n_R );
92 
93  long i;
94  SI_FLOAT f = nf(n).F();
95  if (((SI_FLOAT)(-MAX_INT_VAL-1) <= f) || ((SI_FLOAT)MAX_INT_VAL >= f))
96  i = (long)f;
97  else
98  i = 0;
99  return i;
100 }
const int MAX_INT_VAL
Definition: mylimits.h:12

◆ nrInvers()

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

Definition at line 205 of file shortfl.cc.

206 {
207  assume( getCoeffType(r) == n_R );
208 
209  SI_FLOAT n = nf(c).F();
210  if (n == 0.0)
211  {
212  WerrorS(nDivBy0);
213  return nf((SI_FLOAT)0.0).N();
214  }
215  return nf(1.0 / n).N();
216 }

◆ nrIsMOne()

static BOOLEAN nrIsMOne ( 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 }

◆ nrIsOne()

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

Definition at line 173 of file shortfl.cc.

174 {
175  assume( getCoeffType(r) == n_R );
176 
177  SI_FLOAT aa=nf(a).F()-1.0;
178  if (aa<0.0) aa=-aa;
179  return (aa<nrEps);
180 }

◆ nrIsZero()

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

Definition at line 166 of file shortfl.cc.

167 {
168  assume( getCoeffType(r) == n_R );
169 
170  return (0.0 == nf(a).F());
171 }

◆ nrMapC()

static number nrMapC ( 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_C );
409 
410  gmp_float h = ((gmp_complex*)from)->real();
411  SI_FLOAT t =(SI_FLOAT)mpf_get_d((mpf_srcptr)&h);
412  return nf(t).N();
413 }
gmp_complex numbers based on
Definition: mpr_complex.h:179
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:42
STATIC_VAR Poly * h
Definition: janet.cc:971

◆ nrMapLongR()

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

Definition at line 396 of file shortfl.cc.

397 {
398  assume( getCoeffType(r) == n_R );
399  assume( getCoeffType(aRing) == n_long_R );
400 
401  SI_FLOAT t =(SI_FLOAT)mpf_get_d((mpf_srcptr)from);
402  return nf(t).N();
403 }
@ 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 386 of file shortfl.cc.

387 {
388  assume( getCoeffType(r) == n_R );
389  assume( getCoeffType(aRing) == n_Zp );
390 
391  int i = (int)((long)from);
392  SI_FLOAT f = (SI_FLOAT)i;
393  return nf(f).N();
394 }
@ 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 416 of file shortfl.cc.

417 {
418 /* in longrat.h
419 #define SR_INT 1
420 #define mpz_size1(A) (ABS((A)->_mp_size))
421 */
422 #define SR_HDL(A) ((long)(A))
423 #define IS_INT(A) ((A)->s==3)
424 #define IS_IMM(A) (SR_HDL(A) & SR_INT)
425 #define GET_NOM(A) ((A)->z)
426 #define GET_DENOM(A) ((A)->n)
427 
428  assume( getCoeffType(r) == n_R );
429  assume( aRing->rep == n_rep_gap_rat );
430 
431  if (IS_IMM(from))
432  {
433  SI_FLOAT f = (SI_FLOAT)SR_TO_INT(from);
434  return nf(nf(f).F()).N();
435  }
436  else
437  {
438  /* read out the enumerator */
439  if (IS_INT(from))
440  {
441  mpf_t e;
442  mpf_init(e);
443  mpf_set_z(e,GET_NOM(from));
444  SI_FLOAT f = mpf_get_d(e);
445  mpf_clear(e);
446  return nf(nf(f).F()).N();
447  }
448  else /*quotient*/
449  {
450  mpf_t z,n,q;
451  mpf_init(z);
452  mpf_init(n);
453  mpf_init(q);
454  mpf_set_z(z,GET_NOM(from));
455  mpf_set_z(n,GET_DENOM(from));
456  mpf_div(q,z,n);
457  mpf_clear(z);
458  mpf_clear(n);
459  SI_FLOAT f = mpf_get_d(q);
460  mpf_clear(q);
461  return nf(nf(f).F()).N();
462  }
463  }
464 }
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:112
#define SR_TO_INT(SR)
Definition: longrat.h:69
#define IS_INT(A)
#define IS_IMM(A)
#define GET_DENOM(A)
#define GET_NOM(A)

◆ nrMapZ()

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

Definition at line 466 of file shortfl.cc.

467 {
468  assume( getCoeffType(r) == n_R );
469  assume( aRing->rep == n_rep_gap_gmp );
470 
471  mpz_ptr z;
472  mpz_ptr zz=NULL;
473  if (IS_IMM(from))
474  {
475  zz=(mpz_ptr)omAlloc(sizeof(mpz_t));
476  mpz_init_set_si(zz,SR_TO_INT(from));
477  z=zz;
478  }
479  else
480  {
481  /* read out the enumerator */
482  z=(mpz_ptr)from;
483  }
484 
485  int i = mpz_size1(z);
486  mpf_t e;
487  mpf_init(e);
488  mpf_set_z(e,z);
489  int sign= mpf_sgn(e);
490  mpf_abs (e, e);
491 
492  if (zz!=NULL)
493  {
494  mpz_clear(zz);
495  omFreeSize(zz,sizeof(mpz_t));
496  }
497  if(i>4)
498  {
499  WerrorS("float overflow");
500  return nf(0.0).N();
501  }
502  double basis;
503  signed long int exp;
504  basis = mpf_get_d_2exp(&exp, e);
505  SI_FLOAT f= sign*ldexp(basis,exp);
506  mpf_clear(e);
507  return nf(f).N();
508 }
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:113
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omAlloc(size)
Definition: omAllocDecl.h:210
static int sign(int x)
Definition: ring.cc:3377
#define mpz_size1(A)
Definition: si_gmp.h:12

◆ nrMult()

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

Definition at line 68 of file shortfl.cc.

69 {
70  assume( getCoeffType(r) == n_R );
71 
72  return nf(nf(a).F() * nf(b).F()).N();
73 }

◆ nrNeg()

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

Definition at line 218 of file shortfl.cc.

219 {
220  assume( getCoeffType(r) == n_R );
221 
222  return nf(-nf(c).F()).N();
223 }

◆ nrRead()

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

Definition at line 307 of file shortfl.cc.

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

◆ 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 625 of file shortfl.cc.

626 {
627  assume( getCoeffType(dst) == n_R );
628 
629  if (src->rep==n_rep_gap_rat) /*Q, Z */
630  {
631  return nrMapQ;
632  }
633  if (src->rep==n_rep_gap_gmp) /*Q, Z */
634  {
635  return nrMapZ;
636  }
637  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
638  {
639  return nrMapLongR;
640  }
641  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
642  {
643  return ndCopyMap;
644  }
645  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
646  {
647  return nrMapP;
648  }
649  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
650  {
651  return nrMapC;
652  }
653  return NULL;
654 }
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition: numbers.cc:259
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:915
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:824
@ 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:860
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:918
static number nrMapQ(number from, const coeffs r, const coeffs aRing)
Definition: shortfl.cc:416
static number nrMapC(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:405
static number nrMapZ(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:466
static number nrMapP(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:386
static number nrMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:396

◆ nrSub()

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

Definition at line 134 of file shortfl.cc.

135 {
136  assume( getCoeffType(r) == n_R );
137 
138  SI_FLOAT x = nf(a).F();
139  SI_FLOAT y = nf(b).F();
140  SI_FLOAT f = x - y;
141  if (x > 0.0)
142  {
143  if (y > 0.0)
144  {
145  x = f / (x + y);
146  if (x < 0.0)
147  x = -x;
148  if (x < nrEps)
149  f = 0.0;
150  }
151  }
152  else
153  {
154  if (y < 0.0)
155  {
156  x = f / (x + y);
157  if (x < 0.0)
158  x = -x;
159  if (x < nrEps)
160  f = 0.0;
161  }
162  }
163  return nf(f).N();
164 }

◆ nrWrite()

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

Definition at line 240 of file shortfl.cc.

241 {
242  assume( getCoeffType(r) == n_R );
243 
244  //#if SIZEOF_DOUBLE == SIZEOF_LONG
245  //char ch[16];
246  //int n = sprintf(ch,"%12.6e", nf(a).F());
247  //#else
248  char ch[11];
249  int n = sprintf(ch,"%9.3e", nf(a).F());
250  //#endif
251  if (ch[0] == '-')
252  {
253  char* chbr = new char[n+3];
254  memcpy(&chbr[2],&ch[1],n-1);
255  chbr[0] = '-';
256  chbr[1] = '(';
257  chbr[n+1] = ')';
258  chbr[n+2] = '\0';
259  StringAppendS(chbr);
260  delete[] chbr;
261  }
262  else
263  StringAppend("(%s)",ch);
264 }
#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 38 of file shortfl.cc.