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

95 {
96  assume( getCoeffType(r) == n_R );
97 
98  SI_FLOAT x = nf(a).F();
99  SI_FLOAT y = nf(b).F();
100  SI_FLOAT f = x + y;
101  if (x > 0.0)
102  {
103  if (y < 0.0)
104  {
105  x = f / (x - y);
106  if (x < 0.0)
107  x = -x;
108  if (x < nrEps)
109  f = 0.0;
110  }
111  }
112  else
113  {
114  if (y > 0.0)
115  {
116  x = f / (y - x);
117  if (x < 0.0)
118  x = -x;
119  if (x < nrEps)
120  f = 0.0;
121  }
122  }
123  return nf(f).N();
124 }
Variable x
Definition: cfModGcd.cc:4082
CanonicalForm b
Definition: cfModGcd.cc:4103
FILE * f
Definition: checklibs.c:9
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:31
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:389
static const SI_FLOAT nrEps
Definition: shortfl.cc:30
#define SI_FLOAT
Definition: shortfl.h:15
Definition: gnumpfl.cc:25
SI_FLOAT F() const
Definition: gnumpfl.cc:30
number N() const
Definition: gnumpfl.cc:31

◆ nrCoeffName()

static char* nrCoeffName ( const coeffs  r)
static

Definition at line 653 of file shortfl.cc.

654 {
655  return (char*)"Float()";
656 }

◆ nrCoeffString()

static char* nrCoeffString ( const coeffs  r)
static

Definition at line 648 of file shortfl.cc.

649 {
650  return omStrDup("Float()");
651 }
#define omStrDup(s)
Definition: omAllocDecl.h:263

◆ nrDBTest()

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

Definition at line 370 of file shortfl.cc.

371 {
372  assume( getCoeffType(r) == n_R );
373 
374  return TRUE;
375 }
#define TRUE
Definition: auxiliary.h:100

◆ nrDiv()

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

Definition at line 183 of file shortfl.cc.

184 {
185  assume( getCoeffType(r) == n_R );
186 
187  SI_FLOAT n = nf(b).F();
188  if (n == 0.0)
189  {
190  WerrorS(nDivBy0);
191  return nf((SI_FLOAT)0.0).N();
192  }
193  else
194  return nf(nf(a).F() / n).N();
195 }
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 224 of file shortfl.cc.

225 {
226  assume( getCoeffType(r) == n_R );
227 
228  number x = nrSub(a,b,r);
229  return nf(x).F() == nf((SI_FLOAT)0.0).F();
230 }
static number nrSub(number a, number b, const coeffs r)
Definition: shortfl.cc:126

◆ nrFloat()

SI_FLOAT nrFloat ( number  n)

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

Definition at line 48 of file shortfl.cc.

49 {
50  return nf(n).F();
51 }

◆ nrGreater()

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

Definition at line 217 of file shortfl.cc.

218 {
219  assume( getCoeffType(r) == n_R );
220 
221  return nf(a).F() > nf(b).F();
222 }

◆ nrGreaterZero()

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

Definition at line 53 of file shortfl.cc.

54 {
55  assume( getCoeffType(r) == n_R );
56 
57  return nf(k).F() >= 0.0;
58 }
int k
Definition: cfEzgcd.cc:99

◆ nrInit()

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

Definition at line 70 of file shortfl.cc.

71 {
72  assume( getCoeffType(r) == n_R );
73 
74  SI_FLOAT f = (SI_FLOAT)i;
75  return nf(nf(f).F()).N();
76 }
int i
Definition: cfEzgcd.cc:132

◆ nrInitChar()

BOOLEAN nrInitChar ( coeffs  n,
void *  p 
)

Initialize r.

Definition at line 658 of file shortfl.cc.

659 {
660  assume( getCoeffType(n) == n_R );
661 
662  assume( p == NULL );
663 
664  n->is_field=TRUE;
665  n->is_domain=TRUE;
666  n->rep=n_rep_float;
667 
668  //n->cfKillChar = ndKillChar; /* dummy */
669  n->ch = 0;
670  n->cfCoeffName = nrCoeffName;
671  n->cfCoeffString = nrCoeffString;
672 
673  n->cfInit = nrInit;
674  n->cfInt = nrInt;
675  n->cfAdd = nrAdd;
676  n->cfSub = nrSub;
677  n->cfMult = nrMult;
678  n->cfDiv = nrDiv;
679  n->cfExactDiv= nrDiv;
680  n->cfInpNeg = nrNeg;
681  n->cfInvers= nrInvers;
682  //n->cfCopy = ndCopy;
683  n->cfGreater = nrGreater;
684  n->cfEqual = nrEqual;
685  n->cfIsZero = nrIsZero;
686  n->cfIsOne = nrIsOne;
687  n->cfIsMOne = nrIsMOne;
688  n->cfGreaterZero = nrGreaterZero;
689  n->cfWriteLong = nrWrite;
690  n->cfRead = nrRead;
691  //n->cfPower = nrPower;
692  n->cfSetMap = nrSetMap;
693 
694  /* nName= ndName; */
695  /*nSize = ndSize;*/
696 #ifdef LDEBUG
697  n->cfDBTest=nrDBTest; // not yet implemented: nrDBTest;
698 #endif
699 
700  //n->nCoeffIsEqual = ndCoeffIsEqual;
701 
702  n->float_len = SHORT_REAL_LENGTH;
703  n->float_len2 = SHORT_REAL_LENGTH;
704 
705  // TODO: Any variables?
706  return FALSE;
707 }
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4078
@ n_rep_float
(float), see shortfl.h
Definition: coeffs.h:116
#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:60
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:617
static BOOLEAN nrDBTest(number a, const char *f, const int l, const coeffs r)
Definition: shortfl.cc:370
static number nrInvers(number c, const coeffs r)
Definition: shortfl.cc:197
static number nrDiv(number a, number b, const coeffs r)
Definition: shortfl.cc:183
static number nrAdd(number a, number b, const coeffs r)
Definition: shortfl.cc:94
static number nrNeg(number c, const coeffs r)
Definition: shortfl.cc:210
static BOOLEAN nrEqual(number a, number b, const coeffs r)
Definition: shortfl.cc:224
static void nrWrite(number a, const coeffs r)
Definition: shortfl.cc:232
static char * nrCoeffString(const coeffs r)
Definition: shortfl.cc:648
static BOOLEAN nrIsZero(number a, const coeffs r)
Definition: shortfl.cc:158
static number nrInit(long i, const coeffs r)
Definition: shortfl.cc:70
static BOOLEAN nrGreater(number a, number b, const coeffs r)
Definition: shortfl.cc:217
static BOOLEAN nrIsMOne(number a, const coeffs r)
Definition: shortfl.cc:174
static const char * nrRead(const char *s, number *a, const coeffs r)
Definition: shortfl.cc:299
static BOOLEAN nrIsOne(number a, const coeffs r)
Definition: shortfl.cc:165
static char * nrCoeffName(const coeffs r)
Definition: shortfl.cc:653
static long nrInt(number &n, const coeffs r)
Definition: shortfl.cc:81
static BOOLEAN nrGreaterZero(number k, const coeffs r)
Definition: shortfl.cc:53

◆ nrInt()

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

Definition at line 81 of file shortfl.cc.

82 {
83  assume( getCoeffType(r) == n_R );
84 
85  long i;
86  SI_FLOAT f = nf(n).F();
87  if (((SI_FLOAT)(-MAX_INT_VAL-1) <= f) || ((SI_FLOAT)MAX_INT_VAL >= f))
88  i = (long)f;
89  else
90  i = 0;
91  return i;
92 }
const int MAX_INT_VAL
Definition: mylimits.h:12

◆ nrInvers()

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

Definition at line 197 of file shortfl.cc.

198 {
199  assume( getCoeffType(r) == n_R );
200 
201  SI_FLOAT n = nf(c).F();
202  if (n == 0.0)
203  {
204  WerrorS(nDivBy0);
205  return nf((SI_FLOAT)0.0).N();
206  }
207  return nf(1.0 / n).N();
208 }

◆ nrIsMOne()

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

Definition at line 174 of file shortfl.cc.

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

◆ nrIsOne()

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

Definition at line 165 of file shortfl.cc.

166 {
167  assume( getCoeffType(r) == n_R );
168 
169  SI_FLOAT aa=nf(a).F()-1.0;
170  if (aa<0.0) aa=-aa;
171  return (aa<nrEps);
172 }

◆ nrIsZero()

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

Definition at line 158 of file shortfl.cc.

159 {
160  assume( getCoeffType(r) == n_R );
161 
162  return (0.0 == nf(a).F());
163 }

◆ nrMapC()

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

Definition at line 397 of file shortfl.cc.

398 {
399  assume( getCoeffType(r) == n_R );
400  assume( getCoeffType(aRing) == n_long_C );
401 
402  gmp_float h = ((gmp_complex*)from)->real();
403  SI_FLOAT t =(SI_FLOAT)mpf_get_d((mpf_srcptr)&h);
404  return nf(t).N();
405 }
gmp_complex numbers based on
Definition: mpr_complex.h:179
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:41
STATIC_VAR Poly * h
Definition: janet.cc:971

◆ nrMapLongR()

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

Definition at line 388 of file shortfl.cc.

389 {
390  assume( getCoeffType(r) == n_R );
391  assume( getCoeffType(aRing) == n_long_R );
392 
393  SI_FLOAT t =(SI_FLOAT)mpf_get_d((mpf_srcptr)from);
394  return nf(t).N();
395 }
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:33

◆ nrMapP()

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

Definition at line 378 of file shortfl.cc.

379 {
380  assume( getCoeffType(r) == n_R );
381  assume( getCoeffType(aRing) == n_Zp );
382 
383  int i = (int)((long)from);
384  SI_FLOAT f = (SI_FLOAT)i;
385  return nf(f).N();
386 }
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29

◆ nrMapQ()

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

Definition at line 408 of file shortfl.cc.

409 {
410 /* in longrat.h
411 #define SR_INT 1
412 #define mpz_size1(A) (ABS((A)->_mp_size))
413 */
414 #define SR_HDL(A) ((long)(A))
415 #define IS_INT(A) ((A)->s==3)
416 #define IS_IMM(A) (SR_HDL(A) & SR_INT)
417 #define GET_NOM(A) ((A)->z)
418 #define GET_DENOM(A) ((A)->n)
419 
420  assume( getCoeffType(r) == n_R );
421  assume( aRing->rep == n_rep_gap_rat );
422 
423  if (IS_IMM(from))
424  {
425  SI_FLOAT f = (SI_FLOAT)SR_TO_INT(from);
426  return nf(nf(f).F()).N();
427  }
428  else
429  {
430  /* read out the enumerator */
431  if (IS_INT(from))
432  {
433  mpf_t e;
434  mpf_init(e);
435  mpf_set_z(e,GET_NOM(from));
436  SI_FLOAT f = mpf_get_d(e);
437  mpf_clear(e);
438  return nf(nf(f).F()).N();
439  }
440  else /*quotient*/
441  {
442  mpf_t z,n,q;
443  mpf_init(z);
444  mpf_init(n);
445  mpf_init(q);
446  mpf_set_z(z,GET_NOM(from));
447  mpf_set_z(n,GET_DENOM(from));
448  mpf_div(q,z,n);
449  mpf_clear(z);
450  mpf_clear(n);
451  SI_FLOAT f = mpf_get_d(q);
452  mpf_clear(q);
453  return nf(nf(f).F()).N();
454  }
455  }
456 }
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:111
#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 458 of file shortfl.cc.

459 {
460  assume( getCoeffType(r) == n_R );
461  assume( aRing->rep == n_rep_gap_gmp );
462 
463  mpz_ptr z;
464  mpz_ptr zz=NULL;
465  if (IS_IMM(from))
466  {
467  zz=(mpz_ptr)omAlloc(sizeof(mpz_t));
468  mpz_init_set_si(zz,SR_TO_INT(from));
469  z=zz;
470  }
471  else
472  {
473  /* read out the enumerator */
474  z=(mpz_ptr)from;
475  }
476 
477  int i = mpz_size1(z);
478  mpf_t e;
479  mpf_init(e);
480  mpf_set_z(e,z);
481  int sign= mpf_sgn(e);
482  mpf_abs (e, e);
483 
484  if (zz!=NULL)
485  {
486  mpz_clear(zz);
487  omFreeSize(zz,sizeof(mpz_t));
488  }
489  if(i>4)
490  {
491  WerrorS("float overflow");
492  return nf(0.0).N();
493  }
494  double basis;
495  signed long int exp;
496  basis = mpf_get_d_2exp(&exp, e);
497  SI_FLOAT f= sign*ldexp(basis,exp);
498  mpf_clear(e);
499  return nf(f).N();
500 }
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:112
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:3427
#define mpz_size1(A)
Definition: si_gmp.h:17

◆ nrMult()

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

Definition at line 60 of file shortfl.cc.

61 {
62  assume( getCoeffType(r) == n_R );
63 
64  return nf(nf(a).F() * nf(b).F()).N();
65 }

◆ nrNeg()

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

Definition at line 210 of file shortfl.cc.

211 {
212  assume( getCoeffType(r) == n_R );
213 
214  return nf(-nf(c).F()).N();
215 }

◆ nrRead()

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

Definition at line 299 of file shortfl.cc.

300 {
301 
302  assume( getCoeffType(r) == n_R );
303 
304  static const char *nIllegalChar="illegal character in number";
305 
306  const char *t;
307  const char *start=s;
308  SI_FLOAT z1,z2;
309  SI_FLOAT n=1.0;
310 
311  s = nrEatr(s, &z1);
312  if (*s == '/')
313  {
314  if (s==start) { WerrorS(nIllegalChar);return s; }
315  s++;
316  s = nrEatr(s, &z2);
317  if (z2==0.0)
318  WerrorS(nDivBy0);
319  else
320  z1 /= z2;
321  }
322  else if (*s =='.')
323  {
324  if (s==start) { WerrorS(nIllegalChar);return s; }
325  s++;
326  t = s;
327  while (*t >= '0' && *t <= '9')
328  {
329  t++;
330  n *= 10.0;
331  }
332  s = nrEatr(s, &z2);
333  z1 = (z1*n + z2) / n;
334  if (*s=='e')
335  {
336  int e=0; /* exponent */
337  int si=1;/* sign of exponent */
338  s++;
339  if (*s=='+') s++;
340  else if (*s=='-') {s++; si=-1; }
341  while (*s >= '0' && *s <= '9')
342  {
343  e=e*10+(*s)-'0';
344  s++;
345  }
346  if (si==1)
347  {
348  while (e>0) {z1*=10.0; e--; }
349  }
350  else
351  {
352  while (e>0) {z1/=10.0; e--; }
353  }
354  }
355  }
356  *a = nf(z1).N();
357  return s;
358 }
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 617 of file shortfl.cc.

618 {
619  assume( getCoeffType(dst) == n_R );
620 
621  if (src->rep==n_rep_gap_rat) /*Q, Z */
622  {
623  return nrMapQ;
624  }
625  if (src->rep==n_rep_gap_gmp) /*Q, Z */
626  {
627  return nrMapZ;
628  }
629  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
630  {
631  return nrMapLongR;
632  }
633  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
634  {
635  return ndCopyMap;
636  }
637  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
638  {
639  return nrMapP;
640  }
641  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
642  {
643  return nrMapC;
644  }
645  return NULL;
646 }
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition: numbers.cc:291
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:888
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:797
@ n_rep_int
(int), see modulop.h
Definition: coeffs.h:110
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:117
@ n_rep_gmp_complex
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:833
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:891
static number nrMapQ(number from, const coeffs r, const coeffs aRing)
Definition: shortfl.cc:408
static number nrMapC(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:397
static number nrMapZ(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:458
static number nrMapP(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:378
static number nrMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: shortfl.cc:388

◆ nrSub()

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

Definition at line 126 of file shortfl.cc.

127 {
128  assume( getCoeffType(r) == n_R );
129 
130  SI_FLOAT x = nf(a).F();
131  SI_FLOAT y = nf(b).F();
132  SI_FLOAT f = x - y;
133  if (x > 0.0)
134  {
135  if (y > 0.0)
136  {
137  x = f / (x + y);
138  if (x < 0.0)
139  x = -x;
140  if (x < nrEps)
141  f = 0.0;
142  }
143  }
144  else
145  {
146  if (y < 0.0)
147  {
148  x = f / (x + y);
149  if (x < 0.0)
150  x = -x;
151  if (x < nrEps)
152  f = 0.0;
153  }
154  }
155  return nf(f).N();
156 }

◆ nrWrite()

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

Definition at line 232 of file shortfl.cc.

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