My Project
Loading...
Searching...
No Matches
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

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 void ngfInpAdd (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 void ngfInpMult (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)
 
const char * ngfRead (const char *start, number *a, const coeffs r)
 
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 151 of file gnumpfl.cc.

152{
154
155 gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
156 return (number)r;
157}
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:422
#define assume(x)
Definition: mod2.h:389
#define R
Definition: sirandom.c:27

◆ ngfCoeffIsEqual()

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

Definition at line 401 of file gnumpfl.cc.

402{
403 if (n==n_long_R)
404 {
405 LongComplexInfo* p = (LongComplexInfo *)(parameter);
406 if ((p!=NULL)
407 && (p->float_len == r->float_len)
408 && (p->float_len2 == r->float_len2))
409 return TRUE;
410 }
411 return FALSE;
412}
#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 419 of file gnumpfl.cc.

420{
421 STATIC_VAR char ngfCoeffName_buf[30];
422 snprintf(ngfCoeffName_buf,30,"Float(%d,%d)",r->float_len,r->float_len2);
423 return ngfCoeffName_buf;
424}
#define STATIC_VAR
Definition: globaldefs.h:7

◆ ngfCopy()

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

Definition at line 94 of file gnumpfl.cc.

95{
97
98 gmp_float* b= new gmp_float( *(gmp_float*)a );
99 return (number)b;
100}

◆ ngfDelete()

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

Definition at line 80 of file gnumpfl.cc.

81{
83
84 if ( *a != NULL )
85 {
86 delete *(gmp_float**)a;
87 *a=NULL;
88 }
89}

◆ ngfDiv()

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

Definition at line 198 of file gnumpfl.cc.

199{
201
202 gmp_float* f;
203 if ( ((gmp_float*)b)->isZero() )
204 {
205 // a/0 = error
207 f= new gmp_float( 0 );
208 }
209 else
210 {
211 f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
212 }
213 return (number)f;
214}
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:89

◆ ngfEatFloatNExp()

static char * ngfEatFloatNExp ( char *  s)
static

Definition at line 295 of file gnumpfl.cc.

296{
297 char *start= s;
298
299 // eat floats (mantissa) like:
300 // 0.394394993, 102.203003008, .300303032, pssibly starting with -
301 if (*s == '-') s++;
302 while ((*s >= '0' && *s <= '9')||(*s == '.')) s++;
303
304 // eat the exponent, starts with 'e' followed by '+', '-'
305 // and digits, like:
306 // e-202, e+393, accept also E7
307 if ( (s != start) && ((*s == 'e')||(*s=='E')))
308 {
309 if (*s=='E') *s='e';
310 s++; // skip 'e'/'E'
311 if ((*s == '+') || (*s == '-')) s++;
312 while ((*s >= '0' && *s <= '9')) s++;
313 }
314
315 return s;
316}
const CanonicalForm int s
Definition: facAbsFact.cc:51

◆ ngfEqual()

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

Definition at line 268 of file gnumpfl.cc.

269{
271
272 return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
273}

◆ ngfGreater()

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

Definition at line 258 of file gnumpfl.cc.

259{
261
262 return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
263}

◆ ngfGreaterZero()

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

Definition at line 248 of file gnumpfl.cc.

249{
251
252 return (((gmp_float*)a)->sign() > 0);
253}
static int sign(int x)
Definition: ring.cc:3427

◆ ngfInit()

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

Definition at line 37 of file gnumpfl.cc.

38{
40
41 gmp_float* n= new gmp_float( (double)i );
42 return (number)n;
43}
int i
Definition: cfEzgcd.cc:132

◆ ngfInitChar()

BOOLEAN ngfInitChar ( coeffs  n,
void *  parameter 
)

Initialize r.

Definition at line 511 of file gnumpfl.cc.

512{
514
515 n->is_field=TRUE;
516 n->is_domain=TRUE;
517 n->rep=n_rep_gmp_float;
518
519 //n->cfKillChar = ndKillChar; /* dummy */
520
521 n->cfSetChar = ngfSetChar;
522 n->ch = 0;
523 n->cfCoeffName=ngfCoeffName;
524
525 n->cfDelete = ngfDelete;
526 //n->cfNormalize=ndNormalize;
527 n->cfInit = ngfInit;
528 n->cfInitMPZ = ngfInitMPZ;
529 n->cfInt = ngfInt;
530 n->cfAdd = ngfAdd;
531 n->cfInpAdd = ngfInpAdd;
532 n->cfSub = ngfSub;
533 n->cfMult = ngfMult;
534 n->cfInpMult = ngfInpMult;
535 n->cfDiv = ngfDiv;
536 n->cfExactDiv= ngfDiv;
537 n->cfInpNeg = ngfNeg;
538 n->cfInvers = ngfInvers;
539 n->cfCopy = ngfCopy;
540 n->cfGreater = ngfGreater;
541 n->cfEqual = ngfEqual;
542 n->cfIsZero = ngfIsZero;
543 n->cfIsOne = ngfIsOne;
544 n->cfIsMOne = ngfIsMOne;
545 n->cfGreaterZero = ngfGreaterZero;
546 n->cfWriteLong = ngfWrite;
547 n->cfRead = ngfRead;
548 n->cfPower = ngfPower;
549 n->cfSetMap = ngfSetMap;
550 n->cfSize = ngfSize;
551#ifdef LDEBUG
552 //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
553#endif
554
555 n->nCoeffIsEqual = ngfCoeffIsEqual;
556
557 if( parameter != NULL)
558 {
559 LongComplexInfo* p = (LongComplexInfo*)parameter;
560
561 n->float_len = p->float_len;
562 n->float_len2 = p->float_len2;
563 } else // default values, just for testing!
564 {
565 n->float_len = SHORT_REAL_LENGTH;
566 n->float_len2 = SHORT_REAL_LENGTH;
567 }
568
569 assume( n->float_len2 >= SHORT_REAL_LENGTH );
570
571 assume( n_NumberOfParameters(n) == 0 );
573
574 return FALSE;
575}
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:775
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:771
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:117
static number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:37
static number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:94
static BOOLEAN ngfGreater(number a, number b, const coeffs r)
Definition: gnumpfl.cc:258
static void ngfSetChar(const coeffs r)
Definition: gnumpfl.cc:414
static void ngfInpAdd(number &a, number b, const coeffs R)
Definition: gnumpfl.cc:159
static number ngfInvers(number a, const coeffs r)
Definition: gnumpfl.cc:131
static long ngfInt(number &i, const coeffs r)
Definition: gnumpfl.cc:48
static number ngfInitMPZ(mpz_t m, const coeffs)
Definition: gnumpfl.cc:470
static number ngfDiv(number a, number b, const coeffs r)
Definition: gnumpfl.cc:198
static number ngfAdd(number a, number b, const coeffs R)
Definition: gnumpfl.cc:151
const char * ngfRead(const char *start, number *a, const coeffs r)
Definition: gnumpfl.cc:324
static BOOLEAN ngfGreaterZero(number a, const coeffs r)
Definition: gnumpfl.cc:248
static BOOLEAN ngfIsMOne(number a, const coeffs r)
Definition: gnumpfl.cc:288
static BOOLEAN ngfIsZero(number a, const coeffs r)
Definition: gnumpfl.cc:59
static void ngfWrite(number a, const coeffs r)
Definition: gnumpfl.cc:383
static number ngfPower(number x, int exp, const coeffs r)
Definition: gnumpfl.cc:219
static BOOLEAN ngfEqual(number a, number b, const coeffs r)
Definition: gnumpfl.cc:268
static int ngfSize(number n, const coeffs r)
Definition: gnumpfl.cc:66
static void ngfDelete(number *a, const coeffs r)
Definition: gnumpfl.cc:80
static BOOLEAN ngfCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpfl.cc:401
static number ngfNeg(number a, const coeffs r)
Definition: gnumpfl.cc:120
static void ngfInpMult(number &a, number b, const coeffs R)
Definition: gnumpfl.cc:188
static BOOLEAN ngfIsOne(number a, const coeffs r)
Definition: gnumpfl.cc:278
static number ngfMult(number a, number b, const coeffs R)
Definition: gnumpfl.cc:180
static nMapFunc ngfSetMap(const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:476
static char * ngfCoeffName(const coeffs r)
Definition: gnumpfl.cc:419
static number ngfSub(number a, number b, const coeffs R)
Definition: gnumpfl.cc:169
#define SHORT_REAL_LENGTH
Definition: numbers.h:57

◆ ngfInitMPZ()

static number ngfInitMPZ ( mpz_t  m,
const  coeffs 
)
static

Definition at line 470 of file gnumpfl.cc.

471{
472 gmp_float *res=new gmp_float(m);
473 return (number)res;
474}
int m
Definition: cfEzgcd.cc:128
CanonicalForm res
Definition: facAbsFact.cc:60

◆ ngfInpAdd()

static void ngfInpAdd ( number &  a,
number  b,
const coeffs  R 
)
static

Definition at line 159 of file gnumpfl.cc.

160{
162
163 (*(gmp_float*)a) += (*(gmp_float*)b);
164}

◆ ngfInpMult()

static void ngfInpMult ( number &  a,
number  b,
const coeffs  R 
)
static

Definition at line 188 of file gnumpfl.cc.

189{
191
192 (*(gmp_float*)a) *= (*(gmp_float*)b);
193}

◆ ngfInt()

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

Definition at line 48 of file gnumpfl.cc.

49{
51
52 double d=(double)*(gmp_float*)i;
53 if (d<0.0)
54 return (long)(d-0.5);
55 else
56 return (long)(d+0.5);
57}

◆ ngfInvers()

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

Definition at line 131 of file gnumpfl.cc.

132{
134
135 gmp_float* f= NULL;
136 if (((gmp_float*)a)->isZero() )
137 {
139 f= new gmp_float( 0 );
140 }
141 else
142 {
143 f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) );
144 }
145 return (number)f;
146}

◆ ngfIsMOne()

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

Definition at line 288 of file gnumpfl.cc.

289{
291
292 return ((gmp_float*)a)->isMOne();
293}

◆ ngfIsOne()

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

Definition at line 278 of file gnumpfl.cc.

279{
281
282 return ((gmp_float*)a)->isOne();
283}

◆ ngfIsZero()

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

Definition at line 59 of file gnumpfl.cc.

60{
62
63 return ( ((gmp_float*)a)->isZero() );
64}

◆ ngfMapC()

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

Definition at line 461 of file gnumpfl.cc.

462{
463 assume( getCoeffType(dst) == n_long_R );
464 assume( getCoeffType(src) == n_long_C );
465
466 gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
467 return (number)res;
468}
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 453 of file gnumpfl.cc.

454{
455 assume( getCoeffType(dst) == n_long_R );
456 assume( getCoeffType(src) == n_Zp );
457
458 return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
459}
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
long npInt(number &n, const coeffs r)
Definition: modulop.cc:83

◆ ngfMapQ()

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

Definition at line 426 of file gnumpfl.cc.

427{
428 assume( getCoeffType(dst) == n_long_R );
429 assume( src->rep == n_rep_gap_rat );
430
432 return (number)res;
433}
@ 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 444 of file gnumpfl.cc.

445{
446 assume( getCoeffType(dst) == n_long_R );
447 assume( getCoeffType(src) == n_R );
448
449 gmp_float *res=new gmp_float((double)nf(from).F());
450 return (number)res;
451}
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:31
Definition: gnumpfl.cc:25

◆ ngfMapZ()

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

Definition at line 435 of file gnumpfl.cc.

436{
438 assume( aRing->rep == n_rep_gmp);
439
440 gmp_float *res=new gmp_float((mpz_ptr)from);
441 return (number)res;
442}
@ 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 180 of file gnumpfl.cc.

181{
183
184 gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
185 return (number)r;
186}

◆ ngfNeg()

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

Definition at line 120 of file gnumpfl.cc.

121{
123
124 *(gmp_float*)a= -(*(gmp_float*)a);
125 return (number)a;
126}

◆ ngfPower() [1/2]

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

Definition at line 219 of file gnumpfl.cc.

220{
222
223 if ( exp == 0 )
224 {
225 gmp_float* n = new gmp_float(1);
226 return (number)n;
227 }
228 else if ( ngfIsZero(x, r) ) // 0^e, e>0
229 {
230 return ngfInit(0, r);
231 }
232 else if ( exp == 1 )
233 {
234 return ngfCopy(x,r);
235 }
236 return (number) ( new gmp_float( (*(gmp_float*)x)^exp ) );
237}
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 240 of file gnumpfl.cc.

241{
242 *u = ngfPower(x, exp, r);
243}

◆ ngfRead()

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

Definition at line 324 of file gnumpfl.cc.

325{
327
328 char *s= (char *)start;
329
330 //Print("%s\n",s);
331
332 s= ngfEatFloatNExp( s );
333
334 if (*s=='\0') // 0
335 {
336 if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
337 (*(gmp_float**)a)->setFromStr(start);
338 }
339 else if (s==start) // 1
340 {
341 if ( *(gmp_float**)a != NULL ) delete (*(gmp_float**)a);
342 (*(gmp_float**)a)= new gmp_float(1);
343 }
344 else
345 {
346 gmp_float divisor(1.0);
347 char *start2=s;
348 if ( *s == '/' )
349 {
350 s++;
351 s= ngfEatFloatNExp( (char *)s );
352 if (s!= start2+1)
353 {
354 char tmp_c=*s;
355 *s='\0';
356 divisor.setFromStr(start2+1);
357 *s=tmp_c;
358 }
359 else
360 {
361 Werror("wrong long real format: %s",start2);
362 }
363 }
364 char c=*start2;
365 *start2='\0';
366 if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
367 (*(gmp_float**)a)->setFromStr(start);
368 *start2=c;
369 if (divisor.isZero())
370 {
372 }
373 else
374 (**(gmp_float**)a) /= divisor;
375 }
376
377 return s;
378}
static char * ngfEatFloatNExp(char *s)
Definition: gnumpfl.cc:295
void Werror(const char *fmt,...)
Definition: reporter.cc:189

◆ ngfSetChar()

static void ngfSetChar ( const coeffs  r)
static

Definition at line 414 of file gnumpfl.cc.

415{
416 setGMPFloatDigits(r->float_len, r->float_len2);
417}
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 476 of file gnumpfl.cc.

477{
478 assume( getCoeffType(dst) == n_long_R );
479
480 if (src->rep==n_rep_gap_rat) /*Q, Z*/
481 {
482 return ngfMapQ;
483 }
484 if (src->rep==n_rep_gap_gmp) /*Q, bigint*/
485 {
486 return ngfMapQ;
487 }
488 if (src->rep==n_rep_gmp) /* Z*/
489 {
490 return ngfMapZ;
491 }
492 if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
493 {
494 return ndCopyMap; //ngfCopyMap;
495 }
496 if ((src->rep==n_rep_float) && nCoeff_is_R(src))
497 {
498 return ngfMapR;
499 }
500 if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
501 {
502 return ngfMapC;
503 }
504 if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
505 {
506 return ngfMapP;
507 }
508 return NULL;
509}
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_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:833
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:891
static number ngfMapC(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:461
static number ngfMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpfl.cc:435
static number ngfMapP(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:453
static number ngfMapQ(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:426
static number ngfMapR(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:444

◆ ngfSize()

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

Definition at line 66 of file gnumpfl.cc.

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

◆ ngfSub()

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

Definition at line 169 of file gnumpfl.cc.

170{
172
173 gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
174 return (number)r;
175}

◆ ngfWrite()

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

Definition at line 383 of file gnumpfl.cc.

384{
386
387 char *out;
388 if ( a != NULL )
389 {
390 out= floatToStr(*(gmp_float*)a, r->float_len);
391 StringAppendS(out);
392 //omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
393 omFree( (void *)out );
394 }
395 else
396 {
397 StringAppendS("0");
398 }
399}
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