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)
 
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:403
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:97
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:101
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

§ 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 590 of file gnumpfl.cc.

591 {
592  Print("// characteristic : 0 (real:%d digits, additional %d digits)\n",
593  r->float_len,r->float_len2); /* long R */
594 }
#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:403
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:403
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
void WerrorS(const char *s)
Definition: feFopen.cc:24
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:403
const char *const nDivBy0
Definition: numbers.h:83
FILE * f
Definition: checklibs.c:7
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:403
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:403
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:403
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:3412

§ 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:403
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 440 of file gnumpfl.cc.

441 {
442  assume( getCoeffType(n) == n_long_R );
443 
444  n->is_field=TRUE;
445  n->is_domain=TRUE;
446  n->rep=n_rep_gmp_float;
447 
448  //n->cfKillChar = ndKillChar; /* dummy */
449 
450  n->cfSetChar = ngfSetChar;
451  n->ch = 0;
452  n->cfCoeffString=ngfCoeffString;
453 
454  n->cfDelete = ngfDelete;
455  //n->cfNormalize=ndNormalize;
456  n->cfInit = ngfInit;
457  n->cfInt = ngfInt;
458  n->cfAdd = ngfAdd;
459  n->cfSub = ngfSub;
460  n->cfMult = ngfMult;
461  n->cfDiv = ngfDiv;
462  n->cfExactDiv= ngfDiv;
463  n->cfInpNeg = ngfNeg;
464  n->cfInvers = ngfInvers;
465  n->cfCopy = ngfCopy;
466  n->cfGreater = ngfGreater;
467  n->cfEqual = ngfEqual;
468  n->cfIsZero = ngfIsZero;
469  n->cfIsOne = ngfIsOne;
470  n->cfIsMOne = ngfIsMOne;
471  n->cfGreaterZero = ngfGreaterZero;
472  n->cfWriteLong = ngfWrite;
473  n->cfRead = ngfRead;
474  n->cfPower = ngfPower;
475  n->cfSetMap = ngfSetMap;
476  n->cfCoeffWrite = ngfCoeffWrite;
477 #ifdef LDEBUG
478  //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
479 #endif
480 
481  n->nCoeffIsEqual = ngfCoeffIsEqual;
482 
483  if( parameter != NULL)
484  {
485  LongComplexInfo* p = (LongComplexInfo*)parameter;
486 
487  n->float_len = p->float_len;
488  n->float_len2 = p->float_len2;
489  } else // default values, just for testing!
490  {
491  n->float_len = SHORT_REAL_LENGTH;
492  n->float_len2 = SHORT_REAL_LENGTH;
493  }
494 
495  assume( n->float_len2 >= SHORT_REAL_LENGTH );
496 
497  assume( n_NumberOfParameters(n) == 0 );
498  assume( n_ParameterNames(n) == NULL );
499 
500  return FALSE;
501 }
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:97
return P p
Definition: myNF.cc:203
void ngfCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpfl.cc:590
#define TRUE
Definition: auxiliary.h:101
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:403
nMapFunc ngfSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type:
Definition: gnumpfl.cc:559
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
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:403
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
void WerrorS(const char *s)
Definition: feFopen.cc:24
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:403
const char *const nDivBy0
Definition: numbers.h:83
FILE * f
Definition: checklibs.c:7
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:403
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:403
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:403
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 550 of file gnumpfl.cc.

551 {
552  assume( getCoeffType(dst) == n_long_R );
553  assume( getCoeffType(src) == n_long_C );
554 
555  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
556  return (number)res;
557 }
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:403
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 542 of file gnumpfl.cc.

543 {
544  assume( getCoeffType(dst) == n_long_R );
545  assume( getCoeffType(src) == n_Zp );
546 
547  return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
548 }
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:403
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 503 of file gnumpfl.cc.

504 {
505  assume( getCoeffType(dst) == n_long_R );
506  assume( src->rep == n_rep_gap_rat );
507 
509  return (number)res;
510 }
real floating point (GMP) numbers
Definition: coeffs.h:34
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:403
#define QTOF
Definition: mpr_complex.h:19
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
gmp_float numberFieldToFloat(number num, int k, const coeffs src)
Definition: mpr_complex.cc:440

§ ngfMapR()

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

Definition at line 533 of file gnumpfl.cc.

534 {
535  assume( getCoeffType(dst) == n_long_R );
536  assume( getCoeffType(src) == n_R );
537 
538  gmp_float *res=new gmp_float((double)nf(from).F());
539  return (number)res;
540 }
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:403
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 511 of file gnumpfl.cc.

512 {
513  assume( getCoeffType(r) == n_long_R );
514  assume( aRing->rep == n_rep_gap_gmp);
515 
516  if ( from != NULL )
517  {
518  if (SR_HDL(from) & SR_INT)
519  {
520  gmp_float f_i= gmp_float(SR_TO_INT(from));
521  gmp_float *res=new gmp_float(f_i);
522  return (number)res;
523  }
524  gmp_float f_i=(mpz_ptr)from;
525  gmp_float *res=new gmp_float(f_i);
526  return (number)res;
527  }
528  else
529  return NULL;
530 }
(), 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:403
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:403
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:403
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:403
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:403
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 559 of file gnumpfl.cc.

560 {
561  assume( getCoeffType(dst) == n_long_R );
562 
563  if (src->rep==n_rep_gap_rat) /*Q, Z*/
564  {
565  return ngfMapQ;
566  }
567  if (src->rep==n_rep_gap_gmp) /*Q, Z*/
568  {
569  return ngfMapZ;
570  }
571  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
572  {
573  return ndCopyMap; //ngfCopyMap;
574  }
575  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
576  {
577  return ngfMapR;
578  }
579  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
580  {
581  return ngfMapC;
582  }
583  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
584  {
585  return ngfMapP;
586  }
587  return NULL;
588 }
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:511
number ndCopyMap(number a, const coeffs aRing, const coeffs r)
Definition: numbers.cc:239
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:905
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:850
(), see rinteger.h, new impl.
Definition: coeffs.h:112
number ngfMapQ(number from, const coeffs src, const coeffs r)
Definition: gnumpfl.cc:503
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
static number ngfMapC(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:550
real floating point (GMP) numbers
Definition: coeffs.h:34
#define assume(x)
Definition: mod2.h:403
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static number ngfMapR(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:533
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:542
(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:97
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:403
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:403
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:591