My Project
Data Structures | Functions
gnumpfl.cc File Reference
#include "misc/auxiliary.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/mpr_complex.h"
#include "coeffs/longrat.h"
#include "coeffs/shortfl.h"
#include "coeffs/gnumpfl.h"
#include "coeffs/gnumpc.h"
#include "coeffs/modulop.h"

Go to the source code of this file.

Data Structures

union  nf
 

Functions

const char * ngfRead (const char *s, number *a, const coeffs r)
 
static number ngfInit (long i, const coeffs r)
 
static long ngfInt (number &i, const coeffs r)
 
static BOOLEAN ngfIsZero (number a, const coeffs r)
 
static int ngfSize (number n, const coeffs r)
 
static void ngfDelete (number *a, const coeffs r)
 
static number ngfCopy (number a, const coeffs r)
 
static number ngfNeg (number a, const coeffs r)
 
static number ngfInvers (number a, const coeffs r)
 
static number ngfAdd (number a, number b, const coeffs R)
 
static number ngfSub (number a, number b, const coeffs R)
 
static number ngfMult (number a, number b, const coeffs R)
 
static number ngfDiv (number a, number b, const coeffs r)
 
static number ngfPower (number x, int exp, const coeffs r)
 
static void ngfPower (number x, int exp, number *u, const coeffs r)
 
static BOOLEAN ngfGreaterZero (number a, const coeffs r)
 
static BOOLEAN ngfGreater (number a, number b, const coeffs r)
 
static BOOLEAN ngfEqual (number a, number b, const coeffs r)
 
static BOOLEAN ngfIsOne (number a, const coeffs r)
 
static BOOLEAN ngfIsMOne (number a, const coeffs r)
 
static char * ngfEatFloatNExp (char *s)
 
static void ngfWrite (number a, const coeffs r)
 
static BOOLEAN ngfCoeffIsEqual (const coeffs r, n_coeffType n, void *parameter)
 
static void ngfSetChar (const coeffs r)
 
static char * ngfCoeffName (const coeffs r)
 
static number ngfMapQ (number from, const coeffs src, const coeffs dst)
 
static number ngfMapZ (number from, const coeffs aRing, const coeffs r)
 
static number ngfMapR (number from, const coeffs src, const coeffs dst)
 
static number ngfMapP (number from, const coeffs src, const coeffs dst)
 
static number ngfMapC (number from, const coeffs src, const coeffs dst)
 
static number ngfInitMPZ (mpz_t m, const coeffs)
 
static nMapFunc ngfSetMap (const coeffs src, const coeffs dst)
 
BOOLEAN ngfInitChar (coeffs n, void *parameter)
 Initialize r. More...
 

Function Documentation

◆ ngfAdd()

static number ngfAdd ( number  a,
number  b,
const coeffs  R 
)
static

Definition at line 153 of file gnumpfl.cc.

154 {
155  assume( getCoeffType(R) == n_long_R );
156 
157  gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
158  return (number)r;
159 }
CanonicalForm b
Definition: cfModGcd.cc:4103
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:33
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define assume(x)
Definition: mod2.h:387
#define R
Definition: sirandom.c:27

◆ ngfCoeffIsEqual()

static BOOLEAN ngfCoeffIsEqual ( const coeffs  r,
n_coeffType  n,
void *  parameter 
)
static

Definition at line 389 of file gnumpfl.cc.

390 {
391  if (n==n_long_R)
392  {
393  LongComplexInfo* p = (LongComplexInfo *)(parameter);
394  if ((p!=NULL)
395  && (p->float_len == r->float_len)
396  && (p->float_len2 == r->float_len2))
397  return TRUE;
398  }
399  return FALSE;
400 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4078
#define NULL
Definition: omList.c:12

◆ ngfCoeffName()

static char* ngfCoeffName ( const coeffs  r)
static

Definition at line 407 of file gnumpfl.cc.

408 {
409  STATIC_VAR char ngfCoeffName_buf[30];
410  snprintf(ngfCoeffName_buf,30,"Float(%d,%d)",r->float_len,r->float_len2);
411  return ngfCoeffName_buf;
412 }
#define STATIC_VAR
Definition: globaldefs.h:7

◆ ngfCopy()

static number ngfCopy ( number  a,
const coeffs  r 
)
static

Definition at line 96 of file gnumpfl.cc.

97 {
98  assume( getCoeffType(r) == n_long_R );
99 
100  gmp_float* b= new gmp_float( *(gmp_float*)a );
101  return (number)b;
102 }

◆ ngfDelete()

static void ngfDelete ( number *  a,
const coeffs  r 
)
static

Definition at line 82 of file gnumpfl.cc.

83 {
84  assume( getCoeffType(r) == n_long_R );
85 
86  if ( *a != NULL )
87  {
88  delete *(gmp_float**)a;
89  *a=NULL;
90  }
91 }

◆ ngfDiv()

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

Definition at line 186 of file gnumpfl.cc.

187 {
188  assume( getCoeffType(r) == n_long_R );
189 
190  gmp_float* f;
191  if ( ((gmp_float*)b)->isZero() )
192  {
193  // a/0 = error
194  WerrorS(nDivBy0);
195  f= new gmp_float( 0 );
196  }
197  else
198  {
199  f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
200  }
201  return (number)f;
202 }
FILE * f
Definition: checklibs.c:9
bool isZero(const CFArray &A)
checks if entries of A are zero
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char *const nDivBy0
Definition: numbers.h:87

◆ ngfEatFloatNExp()

static char* ngfEatFloatNExp ( char *  s)
static

Definition at line 283 of file gnumpfl.cc.

284 {
285  char *start= s;
286 
287  // eat floats (mantissa) like:
288  // 0.394394993, 102.203003008, .300303032, pssibly starting with -
289  if (*s == '-') s++;
290  while ((*s >= '0' && *s <= '9')||(*s == '.')) s++;
291 
292  // eat the exponent, starts with 'e' followed by '+', '-'
293  // and digits, like:
294  // e-202, e+393, accept also E7
295  if ( (s != start) && ((*s == 'e')||(*s=='E')))
296  {
297  if (*s=='E') *s='e';
298  s++; // skip 'e'/'E'
299  if ((*s == '+') || (*s == '-')) s++;
300  while ((*s >= '0' && *s <= '9')) s++;
301  }
302 
303  return s;
304 }
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ ngfEqual()

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

Definition at line 256 of file gnumpfl.cc.

257 {
258  assume( getCoeffType(r) == n_long_R );
259 
260  return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
261 }

◆ ngfGreater()

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

Definition at line 246 of file gnumpfl.cc.

247 {
248  assume( getCoeffType(r) == n_long_R );
249 
250  return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
251 }

◆ ngfGreaterZero()

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

Definition at line 236 of file gnumpfl.cc.

237 {
238  assume( getCoeffType(r) == n_long_R );
239 
240  return (((gmp_float*)a)->sign() > 0);
241 }
static int sign(int x)
Definition: ring.cc:3469

◆ ngfInit()

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

Definition at line 39 of file gnumpfl.cc.

40 {
41  assume( getCoeffType(r) == n_long_R );
42 
43  gmp_float* n= new gmp_float( (double)i );
44  return (number)n;
45 }
int i
Definition: cfEzgcd.cc:132

◆ ngfInitChar()

BOOLEAN ngfInitChar ( coeffs  n,
void *  parameter 
)

Initialize r.

Definition at line 499 of file gnumpfl.cc.

500 {
501  assume( getCoeffType(n) == n_long_R );
502 
503  n->is_field=TRUE;
504  n->is_domain=TRUE;
505  n->rep=n_rep_gmp_float;
506 
507  //n->cfKillChar = ndKillChar; /* dummy */
508 
509  n->cfSetChar = ngfSetChar;
510  n->ch = 0;
511  n->cfCoeffName=ngfCoeffName;
512 
513  n->cfDelete = ngfDelete;
514  //n->cfNormalize=ndNormalize;
515  n->cfInit = ngfInit;
516  n->cfInitMPZ = ngfInitMPZ;
517  n->cfInt = ngfInt;
518  n->cfAdd = ngfAdd;
519  n->cfSub = ngfSub;
520  n->cfMult = ngfMult;
521  n->cfDiv = ngfDiv;
522  n->cfExactDiv= ngfDiv;
523  n->cfInpNeg = ngfNeg;
524  n->cfInvers = ngfInvers;
525  n->cfCopy = ngfCopy;
526  n->cfGreater = ngfGreater;
527  n->cfEqual = ngfEqual;
528  n->cfIsZero = ngfIsZero;
529  n->cfIsOne = ngfIsOne;
530  n->cfIsMOne = ngfIsMOne;
531  n->cfGreaterZero = ngfGreaterZero;
532  n->cfWriteLong = ngfWrite;
533  n->cfRead = ngfRead;
534  n->cfPower = ngfPower;
535  n->cfSetMap = ngfSetMap;
536 #ifdef LDEBUG
537  //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
538 #endif
539 
540  n->nCoeffIsEqual = ngfCoeffIsEqual;
541 
542  if( parameter != NULL)
543  {
544  LongComplexInfo* p = (LongComplexInfo*)parameter;
545 
546  n->float_len = p->float_len;
547  n->float_len2 = p->float_len2;
548  } else // default values, just for testing!
549  {
550  n->float_len = SHORT_REAL_LENGTH;
551  n->float_len2 = SHORT_REAL_LENGTH;
552  }
553 
554  assume( n->float_len2 >= SHORT_REAL_LENGTH );
555 
556  assume( n_NumberOfParameters(n) == 0 );
557  assume( n_ParameterNames(n) == NULL );
558 
559  return FALSE;
560 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:778
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:774
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:117
static number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:39
static number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:96
static BOOLEAN ngfGreater(number a, number b, const coeffs r)
Definition: gnumpfl.cc:246
static void ngfSetChar(const coeffs r)
Definition: gnumpfl.cc:402
static number ngfInvers(number a, const coeffs r)
Definition: gnumpfl.cc:133
static long ngfInt(number &i, const coeffs r)
Definition: gnumpfl.cc:50
static number ngfInitMPZ(mpz_t m, const coeffs)
Definition: gnumpfl.cc:458
static number ngfDiv(number a, number b, const coeffs r)
Definition: gnumpfl.cc:186
static number ngfAdd(number a, number b, const coeffs R)
Definition: gnumpfl.cc:153
static BOOLEAN ngfGreaterZero(number a, const coeffs r)
Definition: gnumpfl.cc:236
static BOOLEAN ngfIsMOne(number a, const coeffs r)
Definition: gnumpfl.cc:276
static BOOLEAN ngfIsZero(number a, const coeffs r)
Definition: gnumpfl.cc:61
static void ngfWrite(number a, const coeffs r)
Definition: gnumpfl.cc:371
static number ngfPower(number x, int exp, const coeffs r)
Definition: gnumpfl.cc:207
static BOOLEAN ngfEqual(number a, number b, const coeffs r)
Definition: gnumpfl.cc:256
static void ngfDelete(number *a, const coeffs r)
Definition: gnumpfl.cc:82
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:312
static BOOLEAN ngfCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpfl.cc:389
static number ngfNeg(number a, const coeffs r)
Definition: gnumpfl.cc:122
static BOOLEAN ngfIsOne(number a, const coeffs r)
Definition: gnumpfl.cc:266
static number ngfMult(number a, number b, const coeffs R)
Definition: gnumpfl.cc:175
static nMapFunc ngfSetMap(const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:464
static number ngfSub(number a, number b, const coeffs R)
Definition: gnumpfl.cc:164
static char * ngfCoeffName(const coeffs r)
Definition: gnumpfl.cc:407
#define SHORT_REAL_LENGTH
Definition: numbers.h:57

◆ ngfInitMPZ()

static number ngfInitMPZ ( mpz_t  m,
const  coeffs 
)
static

Definition at line 458 of file gnumpfl.cc.

459 {
460  gmp_float *res=new gmp_float(m);
461  return (number)res;
462 }
int m
Definition: cfEzgcd.cc:128
CanonicalForm res
Definition: facAbsFact.cc:60

◆ ngfInt()

static long ngfInt ( number &  i,
const coeffs  r 
)
static

Definition at line 50 of file gnumpfl.cc.

51 {
52  assume( getCoeffType(r) == n_long_R );
53 
54  double d=(double)*(gmp_float*)i;
55  if (d<0.0)
56  return (long)(d-0.5);
57  else
58  return (long)(d+0.5);
59 }

◆ ngfInvers()

static number ngfInvers ( number  a,
const coeffs  r 
)
static

Definition at line 133 of file gnumpfl.cc.

134 {
135  assume( getCoeffType(r) == n_long_R );
136 
137  gmp_float* f= NULL;
138  if (((gmp_float*)a)->isZero() )
139  {
140  WerrorS(nDivBy0);
141  f= new gmp_float( 0 );
142  }
143  else
144  {
145  f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) );
146  }
147  return (number)f;
148 }

◆ ngfIsMOne()

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

Definition at line 276 of file gnumpfl.cc.

277 {
278  assume( getCoeffType(r) == n_long_R );
279 
280  return ((gmp_float*)a)->isMOne();
281 }

◆ ngfIsOne()

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

Definition at line 266 of file gnumpfl.cc.

267 {
268  assume( getCoeffType(r) == n_long_R );
269 
270  return ((gmp_float*)a)->isOne();
271 }

◆ ngfIsZero()

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

Definition at line 61 of file gnumpfl.cc.

62 {
63  assume( getCoeffType(r) == n_long_R );
64 
65  return ( ((gmp_float*)a)->isZero() );
66 }

◆ ngfMapC()

static number ngfMapC ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 449 of file gnumpfl.cc.

450 {
451  assume( getCoeffType(dst) == n_long_R );
452  assume( getCoeffType(src) == n_long_C );
453 
454  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
455  return (number)res;
456 }
gmp_complex numbers based on
Definition: mpr_complex.h:179
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:41

◆ ngfMapP()

static number ngfMapP ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 441 of file gnumpfl.cc.

442 {
443  assume( getCoeffType(dst) == n_long_R );
444  assume( getCoeffType(src) == n_Zp );
445 
446  return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
447 }
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
long npInt(number &n, const coeffs r)
Definition: modulop.cc:85

◆ ngfMapQ()

static number ngfMapQ ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 414 of file gnumpfl.cc.

415 {
416  assume( getCoeffType(dst) == n_long_R );
417  assume( src->rep == n_rep_gap_rat );
418 
420  return (number)res;
421 }
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:111
gmp_float numberFieldToFloat(number num, int cf)
Definition: mpr_complex.cc:438
#define QTOF
Definition: mpr_complex.h:19

◆ ngfMapR()

static number ngfMapR ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 432 of file gnumpfl.cc.

433 {
434  assume( getCoeffType(dst) == n_long_R );
435  assume( getCoeffType(src) == n_R );
436 
437  gmp_float *res=new gmp_float((double)nf(from).F());
438  return (number)res;
439 }
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:31
Definition: gnumpfl.cc:27

◆ ngfMapZ()

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

Definition at line 423 of file gnumpfl.cc.

424 {
425  assume( getCoeffType(r) == n_long_R );
426  assume( aRing->rep == n_rep_gmp);
427 
428  gmp_float *res=new gmp_float((mpz_ptr)from);
429  return (number)res;
430 }
@ n_rep_gmp
(mpz_ptr), see rmodulon,h
Definition: coeffs.h:115

◆ ngfMult()

static number ngfMult ( number  a,
number  b,
const coeffs  R 
)
static

Definition at line 175 of file gnumpfl.cc.

176 {
177  assume( getCoeffType(R) == n_long_R );
178 
179  gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
180  return (number)r;
181 }

◆ ngfNeg()

static number ngfNeg ( number  a,
const coeffs  r 
)
static

Definition at line 122 of file gnumpfl.cc.

123 {
124  assume( getCoeffType(r) == n_long_R );
125 
126  *(gmp_float*)a= -(*(gmp_float*)a);
127  return (number)a;
128 }

◆ ngfPower() [1/2]

static number ngfPower ( number  x,
int  exp,
const coeffs  r 
)
static

Definition at line 207 of file gnumpfl.cc.

208 {
209  assume( getCoeffType(r) == n_long_R );
210 
211  if ( exp == 0 )
212  {
213  gmp_float* n = new gmp_float(1);
214  return (number)n;
215  }
216  else if ( ngfIsZero(x, r) ) // 0^e, e>0
217  {
218  return ngfInit(0, r);
219  }
220  else if ( exp == 1 )
221  {
222  return ngfCopy(x,r);
223  }
224  return (number) ( new gmp_float( (*(gmp_float*)x)^exp ) );
225 }
Variable x
Definition: cfModGcd.cc:4082
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357

◆ ngfPower() [2/2]

static void ngfPower ( number  x,
int  exp,
number *  u,
const coeffs  r 
)
static

Definition at line 228 of file gnumpfl.cc.

229 {
230  *u = ngfPower(x, exp, r);
231 }

◆ ngfRead()

const char * ngfRead ( const char *  s,
number *  a,
const coeffs  r 
)

Definition at line 312 of file gnumpfl.cc.

313 {
315 
316  char *s= (char *)start;
317 
318  //Print("%s\n",s);
319 
320  s= ngfEatFloatNExp( s );
321 
322  if (*s=='\0') // 0
323  {
324  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
325  (*(gmp_float**)a)->setFromStr(start);
326  }
327  else if (s==start) // 1
328  {
329  if ( *(gmp_float**)a != NULL ) delete (*(gmp_float**)a);
330  (*(gmp_float**)a)= new gmp_float(1);
331  }
332  else
333  {
334  gmp_float divisor(1.0);
335  char *start2=s;
336  if ( *s == '/' )
337  {
338  s++;
339  s= ngfEatFloatNExp( (char *)s );
340  if (s!= start2+1)
341  {
342  char tmp_c=*s;
343  *s='\0';
344  divisor.setFromStr(start2+1);
345  *s=tmp_c;
346  }
347  else
348  {
349  Werror("wrong long real format: %s",start2);
350  }
351  }
352  char c=*start2;
353  *start2='\0';
354  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
355  (*(gmp_float**)a)->setFromStr(start);
356  *start2=c;
357  if (divisor.isZero())
358  {
359  WerrorS(nDivBy0);
360  }
361  else
362  (**(gmp_float**)a) /= divisor;
363  }
364 
365  return s;
366 }
static char * ngfEatFloatNExp(char *s)
Definition: gnumpfl.cc:283
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ ngfSetChar()

static void ngfSetChar ( const coeffs  r)
static

Definition at line 402 of file gnumpfl.cc.

403 {
404  setGMPFloatDigits(r->float_len, r->float_len2);
405 }
void setGMPFloatDigits(size_t digits, size_t rest)
Set size of mantissa digits - the number of output digits (basis 10) the size of mantissa consists of...
Definition: mpr_complex.cc:60

◆ ngfSetMap()

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

Definition at line 464 of file gnumpfl.cc.

465 {
466  assume( getCoeffType(dst) == n_long_R );
467 
468  if (src->rep==n_rep_gap_rat) /*Q, Z*/
469  {
470  return ngfMapQ;
471  }
472  if (src->rep==n_rep_gap_gmp) /*Q, bigint*/
473  {
474  return ngfMapQ;
475  }
476  if (src->rep==n_rep_gmp) /* Z*/
477  {
478  return ngfMapZ;
479  }
480  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
481  {
482  return ndCopyMap; //ngfCopyMap;
483  }
484  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
485  {
486  return ngfMapR;
487  }
488  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
489  {
490  return ngfMapC;
491  }
492  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
493  {
494  return ngfMapP;
495  }
496  return NULL;
497 }
number ndCopyMap(number a, const coeffs src, const coeffs dst)
Definition: numbers.cc:255
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:891
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:800
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:112
@ n_rep_float
(float), see shortfl.h
Definition: coeffs.h:116
@ n_rep_int
(int), see modulop.h
Definition: coeffs.h:110
@ 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:836
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:894
static number ngfMapC(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:449
static number ngfMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpfl.cc:423
static number ngfMapP(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:441
static number ngfMapQ(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:414
static number ngfMapR(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:432

◆ ngfSize()

static int ngfSize ( number  n,
const coeffs  r 
)
static

Definition at line 68 of file gnumpfl.cc.

69 {
70  long i = ngfInt(n, r);
71  /* basically return the largest integer in n;
72  only if this happens to be zero although n != 0,
73  return 1;
74  (this code ensures that zero has the size zero) */
75  if ((i == 0) && (ngfIsZero(n,r) == FALSE)) i = 1;
76  return ABS(i);
77 }
static int ABS(int v)
Definition: auxiliary.h:112

◆ ngfSub()

static number ngfSub ( number  a,
number  b,
const coeffs  R 
)
static

Definition at line 164 of file gnumpfl.cc.

165 {
166  assume( getCoeffType(R) == n_long_R );
167 
168  gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
169  return (number)r;
170 }

◆ ngfWrite()

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

Definition at line 371 of file gnumpfl.cc.

372 {
373  assume( getCoeffType(r) == n_long_R );
374 
375  char *out;
376  if ( a != NULL )
377  {
378  out= floatToStr(*(gmp_float*)a, r->float_len);
379  StringAppendS(out);
380  //omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
381  omFree( (void *)out );
382  }
383  else
384  {
385  StringAppendS("0");
386  }
387 }
char * floatToStr(const gmp_float &r, const unsigned int oprec)
Definition: mpr_complex.cc:578
#define omFree(addr)
Definition: omAllocDecl.h:261
void StringAppendS(const char *st)
Definition: reporter.cc:107