Data Structures | Functions
gnumpfl.cc File Reference
#include <misc/auxiliary.h>
#include <omalloc/omalloc.h>
#include <reporter/reporter.h>
#include "coeffs.h"
#include "numbers.h"
#include "mpr_complex.h"
#include "longrat.h"
#include "shortfl.h"
#include "gnumpfl.h"
#include "modulop.h"

Go to the source code of this file.

Data Structures

union  nf
 

Functions

nMapFunc ngfSetMap (const coeffs src, const coeffs dst)
 Get a mapping function from src into the domain of this type: More...
 
const char * ngfRead (const char *s, number *a, const coeffs r)
 
BOOLEAN ngfGreaterZero (number za, const coeffs r)
 Note: MAY NOT WORK AS EXPECTED! More...
 
BOOLEAN ngfGreater (number a, number b, const coeffs r)
 
BOOLEAN ngfEqual (number a, number b, const coeffs r)
 
BOOLEAN ngfIsOne (number a, const coeffs r)
 
BOOLEAN ngfIsMOne (number a, const coeffs r)
 
BOOLEAN ngfIsZero (number za, const coeffs r)
 
number ngfInit (long i, const coeffs r)
 
long ngfInt (number &n, const coeffs r)
 
number ngfNeg (number za, const coeffs r)
 
number ngfInvers (number a, const coeffs r)
 
number ngfAdd (number la, number li, const coeffs r)
 
number ngfSub (number la, number li, const coeffs r)
 
number ngfMult (number a, number b, const coeffs r)
 
number ngfDiv (number a, number b, const coeffs r)
 
void ngfPower (number x, int exp, number *lu, const coeffs r)
 
number ngfCopy (number a, const coeffs r)
 
number ngf_Copy (number a, coeffs r)
 
void ngfWrite (number a, const coeffs r)
 
void ngfCoeffWrite (const coeffs r, BOOLEAN details)
 
void ngfDelete (number *a, const coeffs r)
 
number ngfMapQ (number from, const coeffs src, const coeffs r)
 
int ngfSize (number n, const coeffs r)
 
number ngfPower (number x, int exp, const coeffs r)
 
static char * ngfEatFloatNExp (char *s)
 
BOOLEAN ngfCoeffIsEqual (const coeffs r, n_coeffType n, void *parameter)
 
void ngfSetChar (const coeffs r)
 
static char * ngfCoeffString (const coeffs r)
 
static char * ngfCoeffName (const coeffs r)
 
BOOLEAN ngfInitChar (coeffs n, void *parameter)
 Initialize r. More...
 
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)
 

Function Documentation

§ ngf_Copy()

number ngf_Copy ( number  a,
coeffs  r 
)

§ ngfAdd()

number ngfAdd ( number  la,
number  li,
const coeffs  r 
)

Definition at line 176 of file gnumpfl.cc.

177 {
178  assume( getCoeffType(R) == n_long_R );
179 
180  gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
181  return (number)r;
182 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
const ring R
Definition: DebugPrint.cc:36
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

§ ngfCoeffIsEqual()

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

Definition at line 415 of file gnumpfl.cc.

416 {
417  if (n==n_long_R)
418  {
419  LongComplexInfo* p = (LongComplexInfo *)(parameter);
420  if ((p!=NULL)
421  && (p->float_len == r->float_len)
422  && (p->float_len2 == r->float_len2))
423  return TRUE;
424  }
425  return FALSE;
426 }
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:98
real floating point (GMP) numbers
Definition: coeffs.h:34
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
#define NULL
Definition: omList.c:10

§ ngfCoeffName()

static char* ngfCoeffName ( const coeffs  r)
static

Definition at line 440 of file gnumpfl.cc.

441 {
442  static char ngfCoeffName_buf[27];
443  snprintf(ngfCoeffName_buf,27,"RR(%d,%d)",r->float_len,r->float_len2);
444  return ngfCoeffName_buf;
445 }

§ ngfCoeffString()

static char* ngfCoeffString ( const coeffs  r)
static

Definition at line 433 of file gnumpfl.cc.

434 {
435  char *s=(char*)omAlloc(27);
436  snprintf(s,27,"real,%d,%d",r->float_len,r->float_len2);
437  return s;
438 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210

§ ngfCoeffWrite()

void ngfCoeffWrite ( const coeffs  r,
BOOLEAN  details 
)

Definition at line 598 of file gnumpfl.cc.

599 {
600  Print("// characteristic : 0 (real:%d digits, additional %d digits)\n",
601  r->float_len,r->float_len2); /* long R */
602 }
#define Print
Definition: emacs.cc:83

§ ngfCopy()

number ngfCopy ( number  a,
const coeffs  r 
)

Definition at line 120 of file gnumpfl.cc.

121 {
122  assume( getCoeffType(r) == n_long_R );
123 
124  gmp_float* b= new gmp_float( *(gmp_float*)a );
125  return (number)b;
126 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

§ ngfDelete()

void ngfDelete ( number *  a,
const coeffs  r 
)

Definition at line 106 of file gnumpfl.cc.

107 {
108  assume( getCoeffType(r) == n_long_R );
109 
110  if ( *a != NULL )
111  {
112  delete *(gmp_float**)a;
113  *a=NULL;
114  }
115 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10

§ ngfDiv()

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

Definition at line 209 of file gnumpfl.cc.

210 {
211  assume( getCoeffType(r) == n_long_R );
212 
213  if ( ((gmp_float*)b)->isZero() )
214  {
215  // a/0 = error
216  WerrorS(nDivBy0);
217  return NULL;
218  }
219  gmp_float* f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
220  return (number)f;
221 }
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
void WerrorS(const char *s)
Definition: feFopen.cc:24
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
const char *const nDivBy0
Definition: numbers.h:83
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10
bool isZero(const CFArray &A)
checks if entries of A are zero
const poly b
Definition: syzextra.cc:213

§ ngfEatFloatNExp()

static char* ngfEatFloatNExp ( char *  s)
static

Definition at line 309 of file gnumpfl.cc.

310 {
311  char *start= s;
312 
313  // eat floats (mantissa) like:
314  // 0.394394993, 102.203003008, .300303032, pssibly starting with -
315  if (*s == '-') s++;
316  while ((*s >= '0' && *s <= '9')||(*s == '.')) s++;
317 
318  // eat the exponent, starts with 'e' followed by '+', '-'
319  // and digits, like:
320  // e-202, e+393, accept also E7
321  if ( (s != start) && ((*s == 'e')||(*s=='E')))
322  {
323  if (*s=='E') *s='e';
324  s++; // skip 'e'/'E'
325  if ((*s == '+') || (*s == '-')) s++;
326  while ((*s >= '0' && *s <= '9')) s++;
327  }
328 
329  return s;
330 }
const CanonicalForm int s
Definition: facAbsFact.cc:55

§ ngfEqual()

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

Definition at line 282 of file gnumpfl.cc.

283 {
284  assume( getCoeffType(r) == n_long_R );
285 
286  return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
287 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

§ ngfGreater()

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

Definition at line 272 of file gnumpfl.cc.

273 {
274  assume( getCoeffType(r) == n_long_R );
275 
276  return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
277 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

§ ngfGreaterZero()

BOOLEAN ngfGreaterZero ( number  za,
const coeffs  r 
)

Note: MAY NOT WORK AS EXPECTED!

Definition at line 262 of file gnumpfl.cc.

263 {
264  assume( getCoeffType(r) == n_long_R );
265 
266  return (((gmp_float*)a)->sign() > 0);
267 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static int sign(int x)
Definition: ring.cc:3328

§ ngfInit()

number ngfInit ( long  i,
const coeffs  r 
)

Definition at line 70 of file gnumpfl.cc.

71 {
72  assume( getCoeffType(r) == n_long_R );
73 
74  gmp_float* n= new gmp_float( (double)i );
75  return (number)n;
76 }
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfInitChar()

BOOLEAN ngfInitChar ( coeffs  n,
void *  parameter 
)

Initialize r.

Definition at line 447 of file gnumpfl.cc.

448 {
449  assume( getCoeffType(n) == n_long_R );
450 
451  n->is_field=TRUE;
452  n->is_domain=TRUE;
453  n->rep=n_rep_gmp_float;
454 
455  //n->cfKillChar = ndKillChar; /* dummy */
456 
457  n->cfSetChar = ngfSetChar;
458  n->ch = 0;
459  n->cfCoeffString=ngfCoeffString;
460  n->cfCoeffName=ngfCoeffName;
461 
462  n->cfDelete = ngfDelete;
463  //n->cfNormalize=ndNormalize;
464  n->cfInit = ngfInit;
465  n->cfInt = ngfInt;
466  n->cfAdd = ngfAdd;
467  n->cfSub = ngfSub;
468  n->cfMult = ngfMult;
469  n->cfDiv = ngfDiv;
470  n->cfExactDiv= ngfDiv;
471  n->cfInpNeg = ngfNeg;
472  n->cfInvers = ngfInvers;
473  n->cfCopy = ngfCopy;
474  n->cfGreater = ngfGreater;
475  n->cfEqual = ngfEqual;
476  n->cfIsZero = ngfIsZero;
477  n->cfIsOne = ngfIsOne;
478  n->cfIsMOne = ngfIsMOne;
479  n->cfGreaterZero = ngfGreaterZero;
480  n->cfWriteLong = ngfWrite;
481  n->cfRead = ngfRead;
482  n->cfPower = ngfPower;
483  n->cfSetMap = ngfSetMap;
484  n->cfCoeffWrite = ngfCoeffWrite;
485 #ifdef LDEBUG
486  //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
487 #endif
488 
489  n->nCoeffIsEqual = ngfCoeffIsEqual;
490 
491  if( parameter != NULL)
492  {
493  LongComplexInfo* p = (LongComplexInfo*)parameter;
494 
495  n->float_len = p->float_len;
496  n->float_len2 = p->float_len2;
497  } else // default values, just for testing!
498  {
499  n->float_len = SHORT_REAL_LENGTH;
500  n->float_len2 = SHORT_REAL_LENGTH;
501  }
502 
503  assume( n->float_len2 >= SHORT_REAL_LENGTH );
504 
505  assume( n_NumberOfParameters(n) == 0 );
506  assume( n_ParameterNames(n) == NULL );
507 
508  return FALSE;
509 }
BOOLEAN ngfCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpfl.cc:415
static char * ngfCoeffString(const coeffs r)
Definition: gnumpfl.cc:433
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
number ngfAdd(number la, number li, const coeffs r)
Definition: gnumpfl.cc:176
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
BOOLEAN ngfEqual(number a, number b, const coeffs r)
Definition: gnumpfl.cc:282
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
void ngfCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpfl.cc:598
#define TRUE
Definition: auxiliary.h:98
number ngfInvers(number a, const coeffs r)
Definition: gnumpfl.cc:157
number ngfDiv(number a, number b, const coeffs r)
Definition: gnumpfl.cc:209
void ngfDelete(number *a, const coeffs r)
Definition: gnumpfl.cc:106
real floating point (GMP) numbers
Definition: coeffs.h:34
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:808
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
BOOLEAN ngfIsMOne(number a, const coeffs r)
Definition: gnumpfl.cc:302
#define assume(x)
Definition: mod2.h:394
nMapFunc ngfSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type:
Definition: gnumpfl.cc:567
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:338
void ngfWrite(number a, const coeffs r)
Definition: gnumpfl.cc:397
BOOLEAN ngfGreater(number a, number b, const coeffs r)
Definition: gnumpfl.cc:272
BOOLEAN ngfGreaterZero(number za, const coeffs r)
Note: MAY NOT WORK AS EXPECTED!
Definition: gnumpfl.cc:262
BOOLEAN ngfIsOne(number a, const coeffs r)
Definition: gnumpfl.cc:292
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:120
number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:70
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:117
static char * ngfCoeffName(const coeffs r)
Definition: gnumpfl.cc:440
void ngfSetChar(const coeffs r)
Definition: gnumpfl.cc:428
number ngfMult(number a, number b, const coeffs r)
Definition: gnumpfl.cc:198
number ngfSub(number la, number li, const coeffs r)
Definition: gnumpfl.cc:187
void ngfPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpfl.cc:247
BOOLEAN ngfIsZero(number za, const coeffs r)
Definition: gnumpfl.cc:252
long ngfInt(number &n, const coeffs r)
Definition: gnumpfl.cc:81
number ngfNeg(number za, const coeffs r)
Definition: gnumpfl.cc:146

§ ngfInt()

long ngfInt ( number &  n,
const coeffs  r 
)

Definition at line 81 of file gnumpfl.cc.

82 {
83  assume( getCoeffType(r) == n_long_R );
84 
85  double d=(double)*(gmp_float*)i;
86  if (d<0.0)
87  return (long)(d-0.5);
88  else
89  return (long)(d+0.5);
90 }
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfInvers()

number ngfInvers ( number  a,
const coeffs  r 
)

Definition at line 157 of file gnumpfl.cc.

158 {
159  assume( getCoeffType(r) == n_long_R );
160 
161  gmp_float* f= NULL;
162  if (((gmp_float*)a)->isZero() )
163  {
164  WerrorS(nDivBy0);
165  }
166  else
167  {
168  f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) );
169  }
170  return (number)f;
171 }
const poly a
Definition: syzextra.cc:212
f
Definition: cfModGcd.cc:4022
void WerrorS(const char *s)
Definition: feFopen.cc:24
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
const char *const nDivBy0
Definition: numbers.h:83
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10
bool isZero(const CFArray &A)
checks if entries of A are zero

§ ngfIsMOne()

BOOLEAN ngfIsMOne ( number  a,
const coeffs  r 
)

Definition at line 302 of file gnumpfl.cc.

303 {
304  assume( getCoeffType(r) == n_long_R );
305 
306  return ((gmp_float*)a)->isMOne();
307 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfIsOne()

BOOLEAN ngfIsOne ( number  a,
const coeffs  r 
)

Definition at line 292 of file gnumpfl.cc.

293 {
294  assume( getCoeffType(r) == n_long_R );
295 
296  return ((gmp_float*)a)->isOne();
297 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfIsZero()

BOOLEAN ngfIsZero ( number  za,
const coeffs  r 
)

Definition at line 252 of file gnumpfl.cc.

253 {
254  assume( getCoeffType(r) == n_long_R );
255 
256  return ( ((gmp_float*)a)->isZero() );
257 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
bool isZero(const CFArray &A)
checks if entries of A are zero

§ ngfMapC()

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

Definition at line 558 of file gnumpfl.cc.

559 {
560  assume( getCoeffType(dst) == n_long_R );
561  assume( getCoeffType(src) == n_long_C );
562 
563  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
564  return (number)res;
565 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
real floating point (GMP) numbers
Definition: coeffs.h:34
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfMapP()

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

Definition at line 550 of file gnumpfl.cc.

551 {
552  assume( getCoeffType(dst) == n_long_R );
553  assume( getCoeffType(src) == n_Zp );
554 
555  return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
556 }
long npInt(number &n, const coeffs r)
Definition: modulop.cc:140
{p < 2^31}
Definition: coeffs.h:30
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:70

§ ngfMapQ()

number ngfMapQ ( number  from,
const coeffs  src,
const coeffs  r 
)

Definition at line 511 of file gnumpfl.cc.

512 {
513  assume( getCoeffType(dst) == n_long_R );
514  assume( src->rep == n_rep_gap_rat );
515 
517  return (number)res;
518 }
real floating point (GMP) numbers
Definition: coeffs.h:34
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:394
#define QTOF
Definition: mpr_complex.h:19
gmp_float numberFieldToFloat(number num, int cf)
Definition: mpr_complex.cc:440
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
(number), see longrat.h
Definition: coeffs.h:111

§ ngfMapR()

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

Definition at line 541 of file gnumpfl.cc.

542 {
543  assume( getCoeffType(dst) == n_long_R );
544  assume( getCoeffType(src) == n_R );
545 
546  gmp_float *res=new gmp_float((double)nf(from).F());
547  return (number)res;
548 }
real floating point (GMP) numbers
Definition: coeffs.h:34
Definition: gnumpfl.cc:57
poly res
Definition: myNF.cc:322
single prescision (6,6) real numbers
Definition: coeffs.h:32
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfMapZ()

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

Definition at line 519 of file gnumpfl.cc.

520 {
521  assume( getCoeffType(r) == n_long_R );
522  assume( aRing->rep == n_rep_gap_gmp);
523 
524  if ( from != NULL )
525  {
526  if (SR_HDL(from) & SR_INT)
527  {
528  gmp_float f_i= gmp_float(SR_TO_INT(from));
529  gmp_float *res=new gmp_float(f_i);
530  return (number)res;
531  }
532  gmp_float f_i=(mpz_ptr)from;
533  gmp_float *res=new gmp_float(f_i);
534  return (number)res;
535  }
536  else
537  return NULL;
538 }
(), see rinteger.h, new impl.
Definition: coeffs.h:112
real floating point (GMP) numbers
Definition: coeffs.h:34
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define SR_TO_INT(SR)
Definition: longrat.h:70
#define NULL
Definition: omList.c:10
#define SR_INT
Definition: longrat.h:68
#define SR_HDL(A)
Definition: tgb.cc:35

§ ngfMult()

number ngfMult ( number  a,
number  b,
const coeffs  r 
)

Definition at line 198 of file gnumpfl.cc.

199 {
200  assume( getCoeffType(R) == n_long_R );
201 
202  gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
203  return (number)r;
204 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
const ring R
Definition: DebugPrint.cc:36
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

§ ngfNeg()

number ngfNeg ( number  za,
const coeffs  r 
)

Definition at line 146 of file gnumpfl.cc.

147 {
148  assume( getCoeffType(r) == n_long_R );
149 
150  *(gmp_float*)a= -(*(gmp_float*)a);
151  return (number)a;
152 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

§ ngfPower() [1/2]

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

Definition at line 247 of file gnumpfl.cc.

248 {
249  *u = ngfPower(x, exp, r);
250 }
Variable x
Definition: cfModGcd.cc:4023
void ngfPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpfl.cc:247
p exp[i]
Definition: DebugPrint.cc:39

§ ngfPower() [2/2]

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

Definition at line 226 of file gnumpfl.cc.

227 {
228  assume( getCoeffType(r) == n_long_R );
229 
230  if ( exp == 0 )
231  {
232  gmp_float* n = new gmp_float(1);
233  return (number)n;
234  }
235  else if ( ngfIsZero(x, r) ) // 0^e, e>0
236  {
237  return ngfInit(0, r);
238  }
239  else if ( exp == 1 )
240  {
241  return ngfCopy(x,r);
242  }
243  return (number) ( new gmp_float( (*(gmp_float*)x)^exp ) );
244 }
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:120
number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:70
Variable x
Definition: cfModGcd.cc:4023
p exp[i]
Definition: DebugPrint.cc:39
BOOLEAN ngfIsZero(number za, const coeffs r)
Definition: gnumpfl.cc:252

§ ngfRead()

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

Definition at line 338 of file gnumpfl.cc.

339 {
341 
342  char *s= (char *)start;
343 
344  //Print("%s\n",s);
345 
346  s= ngfEatFloatNExp( s );
347 
348  if (*s=='\0') // 0
349  {
350  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
351  (*(gmp_float**)a)->setFromStr(start);
352  }
353  else if (s==start) // 1
354  {
355  if ( *(gmp_float**)a != NULL ) delete (*(gmp_float**)a);
356  (*(gmp_float**)a)= new gmp_float(1);
357  }
358  else
359  {
360  gmp_float divisor(1.0);
361  char *start2=s;
362  if ( *s == '/' )
363  {
364  s++;
365  s= ngfEatFloatNExp( (char *)s );
366  if (s!= start2+1)
367  {
368  char tmp_c=*s;
369  *s='\0';
370  divisor.setFromStr(start2+1);
371  *s=tmp_c;
372  }
373  else
374  {
375  Werror("wrong long real format: %s",start2);
376  }
377  }
378  char c=*start2;
379  *start2='\0';
380  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
381  (*(gmp_float**)a)->setFromStr(start);
382  *start2=c;
383  if (divisor.isZero())
384  {
385  WerrorS(nDivBy0);
386  }
387  else
388  (**(gmp_float**)a) /= divisor;
389  }
390 
391  return s;
392 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:24
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static char * ngfEatFloatNExp(char *s)
Definition: gnumpfl.cc:309
const char *const nDivBy0
Definition: numbers.h:83
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10
void Werror(const char *fmt,...)
Definition: reporter.cc:189

§ ngfSetChar()

void ngfSetChar ( const coeffs  r)

Definition at line 428 of file gnumpfl.cc.

429 {
430  setGMPFloatDigits(r->float_len, r->float_len2);
431 }
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:62

§ ngfSetMap()

nMapFunc ngfSetMap ( const coeffs  src,
const coeffs  dst 
)

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

Definition at line 567 of file gnumpfl.cc.

568 {
569  assume( getCoeffType(dst) == n_long_R );
570 
571  if (src->rep==n_rep_gap_rat) /*Q, Z*/
572  {
573  return ngfMapQ;
574  }
575  if (src->rep==n_rep_gap_gmp) /*Q, Z*/
576  {
577  return ngfMapZ;
578  }
579  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
580  {
581  return ndCopyMap; //ngfCopyMap;
582  }
583  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
584  {
585  return ngfMapR;
586  }
587  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
588  {
589  return ngfMapC;
590  }
591  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
592  {
593  return ngfMapP;
594  }
595  return NULL;
596 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
number ngfMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpfl.cc:519
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:244
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:908
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:853
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number ngfMapQ(number from, const coeffs src, const coeffs r)
Definition: gnumpfl.cc:511
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:911
static number ngfMapC(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:558
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:394
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static number ngfMapR(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:541
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static number ngfMapP(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:550
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:117
(int), see modulop.h
Definition: coeffs.h:110
(float), see shortfl.h
Definition: coeffs.h:116

§ ngfSize()

int ngfSize ( number  n,
const coeffs  r 
)

Definition at line 92 of file gnumpfl.cc.

93 {
94  long i = ngfInt(n, r);
95  /* basically return the largest integer in n;
96  only if this happens to be zero although n != 0,
97  return 1;
98  (this code ensures that zero has the size zero) */
99  if ((i == 0) && (ngfIsZero(n,r) == FALSE)) i = 1;
100  return i;
101 }
#define FALSE
Definition: auxiliary.h:94
int i
Definition: cfEzgcd.cc:123
BOOLEAN ngfIsZero(number za, const coeffs r)
Definition: gnumpfl.cc:252
long ngfInt(number &n, const coeffs r)
Definition: gnumpfl.cc:81

§ ngfSub()

number ngfSub ( number  la,
number  li,
const coeffs  r 
)

Definition at line 187 of file gnumpfl.cc.

188 {
189  assume( getCoeffType(R) == n_long_R );
190 
191  gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
192  return (number)r;
193 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
const ring R
Definition: DebugPrint.cc:36
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

§ ngfWrite()

void ngfWrite ( number  a,
const coeffs  r 
)

Definition at line 397 of file gnumpfl.cc.

398 {
399  assume( getCoeffType(r) == n_long_R );
400 
401  char *out;
402  if ( a != NULL )
403  {
404  out= floatToStr(*(gmp_float*)a, r->float_len);
405  StringAppendS(out);
406  //omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
407  omFree( (void *)out );
408  }
409  else
410  {
411  StringAppendS("0");
412  }
413 }
const poly a
Definition: syzextra.cc:212
real floating point (GMP) numbers
Definition: coeffs.h:34
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:394
void StringAppendS(const char *st)
Definition: reporter.cc:107
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10
char * floatToStr(const gmp_float &r, const unsigned int oprec)
Definition: mpr_complex.cc:580