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 "gnumpc.h"
#include "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 * ngfCoeffString (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 nMapFunc ngfSetMap (const coeffs src, const coeffs dst)
 
static void ngfCoeffWrite (const coeffs r, BOOLEAN)
 
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 }
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
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()

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

Definition at line 385 of file gnumpfl.cc.

386 {
387  if (n==n_long_R)
388  {
389  LongComplexInfo* p = (LongComplexInfo *)(parameter);
390  if ((p!=NULL)
391  && (p->float_len == r->float_len)
392  && (p->float_len2 == r->float_len2))
393  return TRUE;
394  }
395  return FALSE;
396 }
#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 410 of file gnumpfl.cc.

411 {
412  static char ngfCoeffName_buf[27];
413  snprintf(ngfCoeffName_buf,27,"RR(%d,%d)",r->float_len,r->float_len2);
414  return ngfCoeffName_buf;
415 }

◆ ngfCoeffString()

static char* ngfCoeffString ( const coeffs  r)
static

Definition at line 403 of file gnumpfl.cc.

404 {
405  char *s=(char*)omAlloc(27);
406  snprintf(s,27,"real,%d,%d",r->float_len,r->float_len2);
407  return s;
408 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210

◆ ngfCoeffWrite()

static void ngfCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 503 of file gnumpfl.cc.

504 {
505  Print("float(real:%d digits, additional %d digits)",
506  r->float_len,r->float_len2); /* long R */
507 }
#define Print
Definition: emacs.cc:83

◆ ngfCopy()

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

Definition at line 97 of file gnumpfl.cc.

98 {
99  assume( getCoeffType(r) == n_long_R );
100 
101  gmp_float* b= new gmp_float( *(gmp_float*)a );
102  return (number)b;
103 }
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()

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

Definition at line 83 of file gnumpfl.cc.

84 {
85  assume( getCoeffType(r) == n_long_R );
86 
87  if ( *a != NULL )
88  {
89  delete *(gmp_float**)a;
90  *a=NULL;
91  }
92 }
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()

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  if ( ((gmp_float*)b)->isZero() )
191  {
192  // a/0 = error
193  WerrorS(nDivBy0);
194  return NULL;
195  }
196  gmp_float* f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
197  return (number)f;
198 }
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
const char *const nDivBy0
Definition: numbers.h:83
FILE * f
Definition: checklibs.c:9
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 279 of file gnumpfl.cc.

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

◆ ngfEqual()

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

Definition at line 252 of file gnumpfl.cc.

253 {
254  assume( getCoeffType(r) == n_long_R );
255 
256  return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
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
const poly b
Definition: syzextra.cc:213

◆ ngfGreater()

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

Definition at line 242 of file gnumpfl.cc.

243 {
244  assume( getCoeffType(r) == n_long_R );
245 
246  return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
247 }
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()

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

Definition at line 232 of file gnumpfl.cc.

233 {
234  assume( getCoeffType(r) == n_long_R );
235 
236  return (((gmp_float*)a)->sign() > 0);
237 }
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:3342

◆ ngfInit()

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

Definition at line 40 of file gnumpfl.cc.

41 {
42  assume( getCoeffType(r) == n_long_R );
43 
44  gmp_float* n= new gmp_float( (double)i );
45  return (number)n;
46 }
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 509 of file gnumpfl.cc.

510 {
511  assume( getCoeffType(n) == n_long_R );
512 
513  n->is_field=TRUE;
514  n->is_domain=TRUE;
515  n->rep=n_rep_gmp_float;
516 
517  //n->cfKillChar = ndKillChar; /* dummy */
518 
519  n->cfSetChar = ngfSetChar;
520  n->ch = 0;
521  n->cfCoeffString=ngfCoeffString;
522  n->cfCoeffName=ngfCoeffName;
523 
524  n->cfDelete = ngfDelete;
525  //n->cfNormalize=ndNormalize;
526  n->cfInit = ngfInit;
527  n->cfInt = ngfInt;
528  n->cfAdd = ngfAdd;
529  n->cfSub = ngfSub;
530  n->cfMult = ngfMult;
531  n->cfDiv = ngfDiv;
532  n->cfExactDiv= ngfDiv;
533  n->cfInpNeg = ngfNeg;
534  n->cfInvers = ngfInvers;
535  n->cfCopy = ngfCopy;
536  n->cfGreater = ngfGreater;
537  n->cfEqual = ngfEqual;
538  n->cfIsZero = ngfIsZero;
539  n->cfIsOne = ngfIsOne;
540  n->cfIsMOne = ngfIsMOne;
541  n->cfGreaterZero = ngfGreaterZero;
542  n->cfWriteLong = ngfWrite;
543  n->cfRead = ngfRead;
544  n->cfPower = ngfPower;
545  n->cfSetMap = ngfSetMap;
546  n->cfCoeffWrite = ngfCoeffWrite;
547 #ifdef LDEBUG
548  //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
549 #endif
550 
551  n->nCoeffIsEqual = ngfCoeffIsEqual;
552 
553  if( parameter != NULL)
554  {
555  LongComplexInfo* p = (LongComplexInfo*)parameter;
556 
557  n->float_len = p->float_len;
558  n->float_len2 = p->float_len2;
559  } else // default values, just for testing!
560  {
561  n->float_len = SHORT_REAL_LENGTH;
562  n->float_len2 = SHORT_REAL_LENGTH;
563  }
564 
565  assume( n->float_len2 >= SHORT_REAL_LENGTH );
566 
567  assume( n_NumberOfParameters(n) == 0 );
568  assume( n_ParameterNames(n) == NULL );
569 
570  return FALSE;
571 }
static BOOLEAN ngfEqual(number a, number b, const coeffs r)
Definition: gnumpfl.cc:252
static char * ngfCoeffString(const coeffs r)
Definition: gnumpfl.cc:403
static void ngfSetChar(const coeffs r)
Definition: gnumpfl.cc:398
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
static BOOLEAN ngfCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpfl.cc:385
static number ngfInvers(number a, const coeffs r)
Definition: gnumpfl.cc:134
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
static number ngfPower(number x, int exp, const coeffs r)
Definition: gnumpfl.cc:203
static BOOLEAN ngfIsZero(number a, const coeffs r)
Definition: gnumpfl.cc:62
static long ngfInt(number &i, const coeffs r)
Definition: gnumpfl.cc:51
#define TRUE
Definition: auxiliary.h:98
static number ngfNeg(number a, const coeffs r)
Definition: gnumpfl.cc:123
static void ngfCoeffWrite(const coeffs r, BOOLEAN)
Definition: gnumpfl.cc:503
static BOOLEAN ngfGreater(number a, number b, const coeffs r)
Definition: gnumpfl.cc:242
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
static number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:40
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
#define assume(x)
Definition: mod2.h:394
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:308
static void ngfWrite(number a, const coeffs r)
Definition: gnumpfl.cc:367
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static number ngfDiv(number a, number b, const coeffs r)
Definition: gnumpfl.cc:186
static BOOLEAN ngfIsMOne(number a, const coeffs r)
Definition: gnumpfl.cc:272
static BOOLEAN ngfGreaterZero(number a, const coeffs r)
Definition: gnumpfl.cc:232
#define NULL
Definition: omList.c:10
static number ngfMult(number a, number b, const coeffs R)
Definition: gnumpfl.cc:175
static number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:97
(gmp_float), see
Definition: coeffs.h:117
static char * ngfCoeffName(const coeffs r)
Definition: gnumpfl.cc:410
static void ngfDelete(number *a, const coeffs r)
Definition: gnumpfl.cc:83
static number ngfAdd(number a, number b, const coeffs R)
Definition: gnumpfl.cc:153
static BOOLEAN ngfIsOne(number a, const coeffs r)
Definition: gnumpfl.cc:262
static number ngfSub(number a, number b, const coeffs R)
Definition: gnumpfl.cc:164
static nMapFunc ngfSetMap(const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:472

◆ ngfInt()

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

Definition at line 51 of file gnumpfl.cc.

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

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

Definition at line 134 of file gnumpfl.cc.

135 {
136  assume( getCoeffType(r) == n_long_R );
137 
138  gmp_float* f= NULL;
139  if (((gmp_float*)a)->isZero() )
140  {
141  WerrorS(nDivBy0);
142  }
143  else
144  {
145  f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) );
146  }
147  return (number)f;
148 }
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
const char *const nDivBy0
Definition: numbers.h:83
FILE * f
Definition: checklibs.c:9
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()

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

Definition at line 272 of file gnumpfl.cc.

273 {
274  assume( getCoeffType(r) == n_long_R );
275 
276  return ((gmp_float*)a)->isMOne();
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

◆ ngfIsOne()

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

Definition at line 262 of file gnumpfl.cc.

263 {
264  assume( getCoeffType(r) == n_long_R );
265 
266  return ((gmp_float*)a)->isOne();
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

◆ ngfIsZero()

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

Definition at line 62 of file gnumpfl.cc.

63 {
64  assume( getCoeffType(r) == n_long_R );
65 
66  return ( ((gmp_float*)a)->isZero() );
67 }
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 463 of file gnumpfl.cc.

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

456 {
457  assume( getCoeffType(dst) == n_long_R );
458  assume( getCoeffType(src) == n_Zp );
459 
460  return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
461 }
long npInt(number &n, const coeffs r)
Definition: modulop.cc:117
{p < 2^31}
Definition: coeffs.h:30
real floating point (GMP) numbers
Definition: coeffs.h:34
static number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:40
#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

◆ ngfMapQ()

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

Definition at line 417 of file gnumpfl.cc.

418 {
419  assume( getCoeffType(dst) == n_long_R );
420  assume( src->rep == n_rep_gap_rat );
421 
423  return (number)res;
424 }
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 446 of file gnumpfl.cc.

447 {
448  assume( getCoeffType(dst) == n_long_R );
449  assume( getCoeffType(src) == n_R );
450 
451  gmp_float *res=new gmp_float((double)nf(from).F());
452  return (number)res;
453 }
real floating point (GMP) numbers
Definition: coeffs.h:34
Definition: gnumpfl.cc:27
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()

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

Definition at line 425 of file gnumpfl.cc.

426 {
427  assume( getCoeffType(r) == n_long_R );
428  assume( aRing->rep == n_rep_gap_gmp);
429 
430  if ( from != NULL )
431  {
432  if (SR_HDL(from) & SR_INT)
433  {
434  gmp_float f_i= gmp_float(SR_TO_INT(from));
435  gmp_float *res=new gmp_float(f_i);
436  return (number)res;
437  }
438  gmp_float f_i=(mpz_ptr)from;
439  gmp_float *res=new gmp_float(f_i);
440  return (number)res;
441  }
442  else
443  return NULL;
444 }
(), 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()

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 }
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
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()

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

Definition at line 123 of file gnumpfl.cc.

124 {
125  assume( getCoeffType(r) == n_long_R );
126 
127  *(gmp_float*)a= -(*(gmp_float*)a);
128  return (number)a;
129 }
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]

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

Definition at line 203 of file gnumpfl.cc.

204 {
205  assume( getCoeffType(r) == n_long_R );
206 
207  if ( exp == 0 )
208  {
209  gmp_float* n = new gmp_float(1);
210  return (number)n;
211  }
212  else if ( ngfIsZero(x, r) ) // 0^e, e>0
213  {
214  return ngfInit(0, r);
215  }
216  else if ( exp == 1 )
217  {
218  return ngfCopy(x,r);
219  }
220  return (number) ( new gmp_float( (*(gmp_float*)x)^exp ) );
221 }
static BOOLEAN ngfIsZero(number a, const coeffs r)
Definition: gnumpfl.cc:62
real floating point (GMP) numbers
Definition: coeffs.h:34
static number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:40
#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 number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:97
Variable x
Definition: cfModGcd.cc:4023
p exp[i]
Definition: DebugPrint.cc:39

◆ ngfPower() [2/2]

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

Definition at line 224 of file gnumpfl.cc.

225 {
226  *u = ngfPower(x, exp, r);
227 }
static number ngfPower(number x, int exp, const coeffs r)
Definition: gnumpfl.cc:203
Variable x
Definition: cfModGcd.cc:4023
p exp[i]
Definition: DebugPrint.cc:39

◆ ngfRead()

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

Definition at line 308 of file gnumpfl.cc.

309 {
311 
312  char *s= (char *)start;
313 
314  //Print("%s\n",s);
315 
316  s= ngfEatFloatNExp( s );
317 
318  if (*s=='\0') // 0
319  {
320  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
321  (*(gmp_float**)a)->setFromStr(start);
322  }
323  else if (s==start) // 1
324  {
325  if ( *(gmp_float**)a != NULL ) delete (*(gmp_float**)a);
326  (*(gmp_float**)a)= new gmp_float(1);
327  }
328  else
329  {
330  gmp_float divisor(1.0);
331  char *start2=s;
332  if ( *s == '/' )
333  {
334  s++;
335  s= ngfEatFloatNExp( (char *)s );
336  if (s!= start2+1)
337  {
338  char tmp_c=*s;
339  *s='\0';
340  divisor.setFromStr(start2+1);
341  *s=tmp_c;
342  }
343  else
344  {
345  Werror("wrong long real format: %s",start2);
346  }
347  }
348  char c=*start2;
349  *start2='\0';
350  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
351  (*(gmp_float**)a)->setFromStr(start);
352  *start2=c;
353  if (divisor.isZero())
354  {
355  WerrorS(nDivBy0);
356  }
357  else
358  (**(gmp_float**)a) /= divisor;
359  }
360 
361  return s;
362 }
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:279
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()

static void ngfSetChar ( const coeffs  r)
static

Definition at line 398 of file gnumpfl.cc.

399 {
400  setGMPFloatDigits(r->float_len, r->float_len2);
401 }
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()

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

Definition at line 472 of file gnumpfl.cc.

473 {
474  assume( getCoeffType(dst) == n_long_R );
475 
476  if (src->rep==n_rep_gap_rat) /*Q, Z*/
477  {
478  return ngfMapQ;
479  }
480  if (src->rep==n_rep_gap_gmp) /*Q, Z*/
481  {
482  return ngfMapZ;
483  }
484  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
485  {
486  return ndCopyMap; //ngfCopyMap;
487  }
488  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
489  {
490  return ngfMapR;
491  }
492  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
493  {
494  return ngfMapC;
495  }
496  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
497  {
498  return ngfMapP;
499  }
500  return NULL;
501 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
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
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:463
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:446
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:455
(number), see longrat.h
Definition: coeffs.h:111
static number ngfMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpfl.cc:425
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:117
static number ngfMapQ(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:417
(int), see modulop.h
Definition: coeffs.h:110
(float), see shortfl.h
Definition: coeffs.h:116

◆ ngfSize()

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

Definition at line 69 of file gnumpfl.cc.

70 {
71  long i = ngfInt(n, r);
72  /* basically return the largest integer in n;
73  only if this happens to be zero although n != 0,
74  return 1;
75  (this code ensures that zero has the size zero) */
76  if ((i == 0) && (ngfIsZero(n,r) == FALSE)) i = 1;
77  return ABS(i);
78 }
#define FALSE
Definition: auxiliary.h:94
static BOOLEAN ngfIsZero(number a, const coeffs r)
Definition: gnumpfl.cc:62
static long ngfInt(number &i, const coeffs r)
Definition: gnumpfl.cc:51
int i
Definition: cfEzgcd.cc:123
#define ABS(x)
Definition: auxiliary.h:111

◆ 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 }
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
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()

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

Definition at line 367 of file gnumpfl.cc.

368 {
369  assume( getCoeffType(r) == n_long_R );
370 
371  char *out;
372  if ( a != NULL )
373  {
374  out= floatToStr(*(gmp_float*)a, r->float_len);
375  StringAppendS(out);
376  //omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
377  omFree( (void *)out );
378  }
379  else
380  {
381  StringAppendS("0");
382  }
383 }
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