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: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:95
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:99
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 #ifdef SINGULAR_4_1
444  snprintf(ngfCoeffName_buf,27,"real,%d,%d",r->float_len,r->float_len2);
445 #else
446  snprintf(ngfCoeffName_buf,27,"RR(%d,%d)",r->float_len,r->float_len2);
447 #endif
448  return ngfCoeffName_buf;
449 }

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

603 {
604  Print("// characteristic : 0 (real:%d digits, additional %d digits)\n",
605  r->float_len,r->float_len2); /* long R */
606 }
#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: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: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 451 of file gnumpfl.cc.

452 {
453  assume( getCoeffType(n) == n_long_R );
454 
455  n->is_field=TRUE;
456  n->is_domain=TRUE;
457  n->rep=n_rep_gmp_float;
458 
459  //n->cfKillChar = ndKillChar; /* dummy */
460 
461  n->cfSetChar = ngfSetChar;
462  n->ch = 0;
463  n->cfCoeffString=ngfCoeffString;
464  n->cfCoeffName=ngfCoeffName;
465 
466  n->cfDelete = ngfDelete;
467  //n->cfNormalize=ndNormalize;
468  n->cfInit = ngfInit;
469  n->cfInt = ngfInt;
470  n->cfAdd = ngfAdd;
471  n->cfSub = ngfSub;
472  n->cfMult = ngfMult;
473  n->cfDiv = ngfDiv;
474  n->cfExactDiv= ngfDiv;
475  n->cfInpNeg = ngfNeg;
476  n->cfInvers = ngfInvers;
477  n->cfCopy = ngfCopy;
478  n->cfGreater = ngfGreater;
479  n->cfEqual = ngfEqual;
480  n->cfIsZero = ngfIsZero;
481  n->cfIsOne = ngfIsOne;
482  n->cfIsMOne = ngfIsMOne;
483  n->cfGreaterZero = ngfGreaterZero;
484  n->cfWriteLong = ngfWrite;
485  n->cfRead = ngfRead;
486  n->cfPower = ngfPower;
487  n->cfSetMap = ngfSetMap;
488  n->cfCoeffWrite = ngfCoeffWrite;
489 #ifdef LDEBUG
490  //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
491 #endif
492 
493  n->nCoeffIsEqual = ngfCoeffIsEqual;
494 
495  if( parameter != NULL)
496  {
497  LongComplexInfo* p = (LongComplexInfo*)parameter;
498 
499  n->float_len = p->float_len;
500  n->float_len2 = p->float_len2;
501  } else // default values, just for testing!
502  {
503  n->float_len = SHORT_REAL_LENGTH;
504  n->float_len2 = SHORT_REAL_LENGTH;
505  }
506 
507  assume( n->float_len2 >= SHORT_REAL_LENGTH );
508 
509  assume( n_NumberOfParameters(n) == 0 );
510  assume( n_ParameterNames(n) == NULL );
511 
512  return FALSE;
513 }
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:95
return P p
Definition: myNF.cc:203
void ngfCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpfl.cc:602
#define TRUE
Definition: auxiliary.h:99
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:571
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: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 562 of file gnumpfl.cc.

563 {
564  assume( getCoeffType(dst) == n_long_R );
565  assume( getCoeffType(src) == n_long_C );
566 
567  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
568  return (number)res;
569 }
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 554 of file gnumpfl.cc.

555 {
556  assume( getCoeffType(dst) == n_long_R );
557  assume( getCoeffType(src) == n_Zp );
558 
559  return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
560 }
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 515 of file gnumpfl.cc.

516 {
517  assume( getCoeffType(dst) == n_long_R );
518  assume( src->rep == n_rep_gap_rat );
519 
521  return (number)res;
522 }
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 545 of file gnumpfl.cc.

546 {
547  assume( getCoeffType(dst) == n_long_R );
548  assume( getCoeffType(src) == n_R );
549 
550  gmp_float *res=new gmp_float((double)nf(from).F());
551  return (number)res;
552 }
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 523 of file gnumpfl.cc.

524 {
525  assume( getCoeffType(r) == n_long_R );
526  assume( aRing->rep == n_rep_gap_gmp);
527 
528  if ( from != NULL )
529  {
530  if (SR_HDL(from) & SR_INT)
531  {
532  gmp_float f_i= gmp_float(SR_TO_INT(from));
533  gmp_float *res=new gmp_float(f_i);
534  return (number)res;
535  }
536  gmp_float f_i=(mpz_ptr)from;
537  gmp_float *res=new gmp_float(f_i);
538  return (number)res;
539  }
540  else
541  return NULL;
542 }
(), 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 571 of file gnumpfl.cc.

572 {
573  assume( getCoeffType(dst) == n_long_R );
574 
575  if (src->rep==n_rep_gap_rat) /*Q, Z*/
576  {
577  return ngfMapQ;
578  }
579  if (src->rep==n_rep_gap_gmp) /*Q, Z*/
580  {
581  return ngfMapZ;
582  }
583  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
584  {
585  return ndCopyMap; //ngfCopyMap;
586  }
587  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
588  {
589  return ngfMapR;
590  }
591  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
592  {
593  return ngfMapC;
594  }
595  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
596  {
597  return ngfMapP;
598  }
599  return NULL;
600 }
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:523
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: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:515
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:562
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:545
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:554
(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:95
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:580