Data Structures | Functions | Variables
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)
 

Variables

static const n_coeffType ID = n_long_R
 Our Type! More...
 

Function Documentation

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

Definition at line 179 of file gnumpfl.cc.

180 {
181  assume( getCoeffType(R) == ID );
182 
183  gmp_float* r= new gmp_float( (*(gmp_float*)a) + (*(gmp_float*)b) );
184  return (number)r;
185 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define R
Definition: sirandom.c:26
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
BOOLEAN ngfCoeffIsEqual ( const coeffs  r,
n_coeffType  n,
void *  parameter 
)

Definition at line 418 of file gnumpfl.cc.

419 {
420  if (n==ID)
421  {
422  LongComplexInfo* p = (LongComplexInfo *)(parameter);
423  if ((p!=NULL)
424  && (p->float_len == r->float_len)
425  && (p->float_len2 == r->float_len2))
426  return TRUE;
427  }
428  return FALSE;
429 }
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define TRUE
Definition: auxiliary.h:144
short float_len2
additional char-flags, rInit
Definition: coeffs.h:101
short float_len
additional char-flags, rInit
Definition: coeffs.h:100
#define NULL
Definition: omList.c:10
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
static char* ngfCoeffString ( const coeffs  r)
static

Definition at line 436 of file gnumpfl.cc.

437 {
438  char *s=(char*)omAlloc(27);
439  snprintf(s,27,"real,%d,%d",r->float_len,r->float_len2);
440  return s;
441 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210
void ngfCoeffWrite ( const coeffs  r,
BOOLEAN  details 
)

Definition at line 593 of file gnumpfl.cc.

594 {
595  Print("// characteristic : 0 (real:%d digits, additional %d digits)\n",
596  r->float_len,r->float_len2); /* long R */
597 }
#define Print
Definition: emacs.cc:83
number ngfCopy ( number  a,
const coeffs  r 
)

Definition at line 123 of file gnumpfl.cc.

124 {
125  assume( getCoeffType(r) == ID );
126 
127  gmp_float* b= new gmp_float( *(gmp_float*)a );
128  return (number)b;
129 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
void ngfDelete ( number *  a,
const coeffs  r 
)

Definition at line 109 of file gnumpfl.cc.

110 {
111  assume( getCoeffType(r) == ID );
112 
113  if ( *a != NULL )
114  {
115  delete *(gmp_float**)a;
116  *a=NULL;
117  }
118 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define NULL
Definition: omList.c:10
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
number ngfDiv ( number  a,
number  b,
const coeffs  r 
)

Definition at line 212 of file gnumpfl.cc.

213 {
214  assume( getCoeffType(r) == ID );
215 
216  if ( ((gmp_float*)b)->isZero() )
217  {
218  // a/0 = error
219  WerrorS(nDivBy0);
220  return NULL;
221  }
222  gmp_float* f= new gmp_float( (*(gmp_float*)a) / (*(gmp_float*)b) );
223  return (number)f;
224 }
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:23
#define assume(x)
Definition: mod2.h:405
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:422
#define NULL
Definition: omList.c:10
bool isZero(const CFArray &A)
checks if entries of A are zero
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
static char* ngfEatFloatNExp ( char *  s)
static

Definition at line 312 of file gnumpfl.cc.

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

Definition at line 285 of file gnumpfl.cc.

286 {
287  assume( getCoeffType(r) == ID );
288 
289  return ( (*(gmp_float*)a) == (*(gmp_float*)b) );
290 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
BOOLEAN ngfGreater ( number  a,
number  b,
const coeffs  r 
)

Definition at line 275 of file gnumpfl.cc.

276 {
277  assume( getCoeffType(r) == ID );
278 
279  return ( (*(gmp_float*)a) > (*(gmp_float*)b) );
280 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
BOOLEAN ngfGreaterZero ( number  za,
const coeffs  r 
)

Note: MAY NOT WORK AS EXPECTED!

Definition at line 265 of file gnumpfl.cc.

266 {
267  assume( getCoeffType(r) == ID );
268 
269  return (((gmp_float*)a)->sign() > 0);
270 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
int sign(const CanonicalForm &a)
number ngfInit ( long  i,
const coeffs  r 
)

Definition at line 73 of file gnumpfl.cc.

74 {
75  assume( getCoeffType(r) == ID );
76 
77  gmp_float* n= new gmp_float( (double)i );
78  return (number)n;
79 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
BOOLEAN ngfInitChar ( coeffs  n,
void *  parameter 
)

Initialize r.

Definition at line 443 of file gnumpfl.cc.

444 {
445  assume( getCoeffType(n) == ID );
446 
447  n->is_field=TRUE;
448  n->is_domain=TRUE;
449  n->rep=n_rep_gmp_float;
450 
451  //n->cfKillChar = ndKillChar; /* dummy */
452 
453  n->cfSetChar = ngfSetChar;
454  n->ch = 0;
455  n->cfCoeffString=ngfCoeffString;
456 
457  n->cfDelete = ngfDelete;
458  //n->cfNormalize=ndNormalize;
459  n->cfInit = ngfInit;
460  n->cfInt = ngfInt;
461  n->cfAdd = ngfAdd;
462  n->cfSub = ngfSub;
463  n->cfMult = ngfMult;
464  n->cfDiv = ngfDiv;
465  n->cfExactDiv= ngfDiv;
466  n->cfInpNeg = ngfNeg;
467  n->cfInvers = ngfInvers;
468  n->cfCopy = ngfCopy;
469  n->cfGreater = ngfGreater;
470  n->cfEqual = ngfEqual;
471  n->cfIsZero = ngfIsZero;
472  n->cfIsOne = ngfIsOne;
473  n->cfIsMOne = ngfIsMOne;
474  n->cfGreaterZero = ngfGreaterZero;
475  n->cfWriteLong = ngfWrite;
476  n->cfRead = ngfRead;
477  n->cfPower = ngfPower;
478  n->cfSetMap = ngfSetMap;
479  n->cfCoeffWrite = ngfCoeffWrite;
480 #ifdef LDEBUG
481  //n->cfDBTest = ndDBTest; // not yet implemented: ngfDBTest
482 #endif
483 
484  n->nCoeffIsEqual = ngfCoeffIsEqual;
485 
486  if( parameter != NULL)
487  {
488  LongComplexInfo* p = (LongComplexInfo*)parameter;
489 
490  n->float_len = p->float_len;
491  n->float_len2 = p->float_len2;
492  } else // default values, just for testing!
493  {
494  n->float_len = SHORT_REAL_LENGTH;
495  n->float_len2 = SHORT_REAL_LENGTH;
496  }
497 
498  assume( n->float_len2 >= SHORT_REAL_LENGTH );
499 
500  assume( n_NumberOfParameters(n) == 0 );
501  assume( n_ParameterNames(n) == NULL );
502 
503  return FALSE;
504 }
BOOLEAN ngfCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpfl.cc:418
static char * ngfCoeffString(const coeffs r)
Definition: gnumpfl.cc:436
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
number ngfAdd(number la, number li, const coeffs r)
Definition: gnumpfl.cc:179
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
BOOLEAN ngfEqual(number a, number b, const coeffs r)
Definition: gnumpfl.cc:285
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
void ngfCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpfl.cc:593
#define TRUE
Definition: auxiliary.h:144
number ngfInvers(number a, const coeffs r)
Definition: gnumpfl.cc:160
number ngfDiv(number a, number b, const coeffs r)
Definition: gnumpfl.cc:212
void ngfDelete(number *a, const coeffs r)
Definition: gnumpfl.cc:109
short float_len2
additional char-flags, rInit
Definition: coeffs.h:101
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:792
short float_len
additional char-flags, rInit
Definition: coeffs.h:100
BOOLEAN ngfIsMOne(number a, const coeffs r)
Definition: gnumpfl.cc:305
#define assume(x)
Definition: mod2.h:405
nMapFunc ngfSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type:
Definition: gnumpfl.cc:562
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:341
void ngfWrite(number a, const coeffs r)
Definition: gnumpfl.cc:400
BOOLEAN ngfGreater(number a, number b, const coeffs r)
Definition: gnumpfl.cc:275
BOOLEAN ngfGreaterZero(number za, const coeffs r)
Note: MAY NOT WORK AS EXPECTED!
Definition: gnumpfl.cc:265
BOOLEAN ngfIsOne(number a, const coeffs r)
Definition: gnumpfl.cc:295
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:123
number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:73
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:116
void ngfSetChar(const coeffs r)
Definition: gnumpfl.cc:431
number ngfMult(number a, number b, const coeffs r)
Definition: gnumpfl.cc:201
number ngfSub(number la, number li, const coeffs r)
Definition: gnumpfl.cc:190
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
void ngfPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpfl.cc:250
BOOLEAN ngfIsZero(number za, const coeffs r)
Definition: gnumpfl.cc:255
long ngfInt(number &n, const coeffs r)
Definition: gnumpfl.cc:84
number ngfNeg(number za, const coeffs r)
Definition: gnumpfl.cc:149
long ngfInt ( number &  n,
const coeffs  r 
)

Definition at line 84 of file gnumpfl.cc.

85 {
86  assume( getCoeffType(r) == ID );
87 
88  double d=(double)*(gmp_float*)i;
89  if (d<0.0)
90  return (long)(d-0.5);
91  else
92  return (long)(d+0.5);
93 }
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
number ngfInvers ( number  a,
const coeffs  r 
)

Definition at line 160 of file gnumpfl.cc.

161 {
162  assume( getCoeffType(r) == ID );
163 
164  gmp_float* f= NULL;
165  if (((gmp_float*)a)->isZero() )
166  {
167  WerrorS(nDivBy0);
168  }
169  else
170  {
171  f= new gmp_float( gmp_float(1) / (*(gmp_float*)a) );
172  }
173  return (number)f;
174 }
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:23
#define assume(x)
Definition: mod2.h:405
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:422
#define NULL
Definition: omList.c:10
bool isZero(const CFArray &A)
checks if entries of A are zero
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
BOOLEAN ngfIsMOne ( number  a,
const coeffs  r 
)

Definition at line 305 of file gnumpfl.cc.

306 {
307  assume( getCoeffType(r) == ID );
308 
309  return ((gmp_float*)a)->isMOne();
310 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
BOOLEAN ngfIsOne ( number  a,
const coeffs  r 
)

Definition at line 295 of file gnumpfl.cc.

296 {
297  assume( getCoeffType(r) == ID );
298 
299  return ((gmp_float*)a)->isOne();
300 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
BOOLEAN ngfIsZero ( number  za,
const coeffs  r 
)

Definition at line 255 of file gnumpfl.cc.

256 {
257  assume( getCoeffType(r) == ID );
258 
259  return ( ((gmp_float*)a)->isZero() );
260 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
bool isZero(const CFArray &A)
checks if entries of A are zero
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
static number ngfMapC ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 553 of file gnumpfl.cc.

554 {
555  assume( getCoeffType(dst) == ID );
556  assume( getCoeffType(src) == n_long_C );
557 
558  gmp_float *res=new gmp_float(((gmp_complex*)from)->real());
559  return (number)res;
560 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:405
complex floating point (GMP) numbers
Definition: coeffs.h:41
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
static number ngfMapP ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 545 of file gnumpfl.cc.

546 {
547  assume( getCoeffType(dst) == ID );
548  assume( getCoeffType(src) == n_Zp );
549 
550  return ngfInit(npInt(from,src), dst); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
551 }
long npInt(number &n, const coeffs r)
Definition: modulop.cc:143
{p < 2^31}
Definition: coeffs.h:30
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:73
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
number ngfMapQ ( number  from,
const coeffs  src,
const coeffs  r 
)

Definition at line 506 of file gnumpfl.cc.

507 {
508  assume( getCoeffType(dst) == ID );
509  assume( src->rep == n_rep_gap_rat );
510 
512  return (number)res;
513 }
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:405
#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:422
(number), see longrat.h
Definition: coeffs.h:110
gmp_float numberFieldToFloat(number num, int k, const coeffs src)
Definition: mpr_complex.cc:440
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
static number ngfMapR ( number  from,
const coeffs  src,
const coeffs  dst 
)
static

Definition at line 536 of file gnumpfl.cc.

537 {
538  assume( getCoeffType(dst) == ID );
539  assume( getCoeffType(src) == n_R );
540 
541  gmp_float *res=new gmp_float((double)nf(from).F());
542  return (number)res;
543 }
Definition: gnumpfl.cc:60
poly res
Definition: myNF.cc:322
single prescision (6,6) real numbers
Definition: coeffs.h:32
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
number ngfMapZ ( number  from,
const coeffs  aRing,
const coeffs  r 
)

Definition at line 514 of file gnumpfl.cc.

515 {
516  assume( getCoeffType(r) == ID );
517  assume( aRing->rep == n_rep_gap_gmp);
518 
519  if ( from != NULL )
520  {
521  if (SR_HDL(from) & SR_INT)
522  {
523  gmp_float f_i= gmp_float(SR_TO_INT(from));
524  gmp_float *res=new gmp_float(f_i);
525  return (number)res;
526  }
527  gmp_float f_i=(mpz_ptr)from;
528  gmp_float *res=new gmp_float(f_i);
529  return (number)res;
530  }
531  else
532  return NULL;
533 }
(), see rinteger.h, new impl.
Definition: coeffs.h:111
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define SR_TO_INT(SR)
Definition: longrat.h:67
#define NULL
Definition: omList.c:10
#define SR_INT
Definition: longrat.h:65
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
#define SR_HDL(A)
Definition: tgb.cc:35
number ngfMult ( number  a,
number  b,
const coeffs  r 
)

Definition at line 201 of file gnumpfl.cc.

202 {
203  assume( getCoeffType(R) == ID );
204 
205  gmp_float* r= new gmp_float( (*(gmp_float*)a) * (*(gmp_float*)b) );
206  return (number)r;
207 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define R
Definition: sirandom.c:26
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
number ngfNeg ( number  za,
const coeffs  r 
)

Definition at line 149 of file gnumpfl.cc.

150 {
151  assume( getCoeffType(r) == ID );
152 
153  *(gmp_float*)a= -(*(gmp_float*)a);
154  return (number)a;
155 }
const poly a
Definition: syzextra.cc:212
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
void ngfPower ( number  x,
int  exp,
number *  lu,
const coeffs  r 
)

Definition at line 250 of file gnumpfl.cc.

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

Definition at line 229 of file gnumpfl.cc.

230 {
231  assume( getCoeffType(r) == ID );
232 
233  if ( exp == 0 )
234  {
235  gmp_float* n = new gmp_float(1);
236  return (number)n;
237  }
238  else if ( ngfIsZero(x, r) ) // 0^e, e>0
239  {
240  return ngfInit(0, r);
241  }
242  else if ( exp == 1 )
243  {
244  return ngfCopy(x,r);
245  }
246  return (number) ( new gmp_float( (*(gmp_float*)x)^exp ) );
247 }
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
number ngfCopy(number a, const coeffs r)
Definition: gnumpfl.cc:123
number ngfInit(long i, const coeffs r)
Definition: gnumpfl.cc:73
Variable x
Definition: cfModGcd.cc:4023
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
p exp[i]
Definition: DebugPrint.cc:39
BOOLEAN ngfIsZero(number za, const coeffs r)
Definition: gnumpfl.cc:255
const char * ngfRead ( const char *  s,
number *  a,
const coeffs  r 
)

Definition at line 341 of file gnumpfl.cc.

342 {
343  assume( getCoeffType(r) == ID or getCoeffType(r) == n_long_C);
344 
345  char *s= (char *)start;
346 
347  //Print("%s\n",s);
348 
349  s= ngfEatFloatNExp( s );
350 
351  if (*s=='\0') // 0
352  {
353  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
354  (*(gmp_float**)a)->setFromStr(start);
355  }
356  else if (s==start) // 1
357  {
358  if ( *(gmp_float**)a != NULL ) delete (*(gmp_float**)a);
359  (*(gmp_float**)a)= new gmp_float(1);
360  }
361  else
362  {
363  gmp_float divisor(1.0);
364  char *start2=s;
365  if ( *s == '/' )
366  {
367  s++;
368  s= ngfEatFloatNExp( (char *)s );
369  if (s!= start2+1)
370  {
371  char tmp_c=*s;
372  *s='\0';
373  divisor.setFromStr(start2+1);
374  *s=tmp_c;
375  }
376  else
377  {
378  Werror("wrong long real format: %s",start2);
379  }
380  }
381  char c=*start2;
382  *start2='\0';
383  if ( *(gmp_float**)a == NULL ) (*(gmp_float**)a)= new gmp_float();
384  (*(gmp_float**)a)->setFromStr(start);
385  *start2=c;
386  if (divisor.isZero())
387  {
388  WerrorS(nDivBy0);
389  }
390  else
391  (**(gmp_float**)a) /= divisor;
392  }
393 
394  return s;
395 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:23
#define assume(x)
Definition: mod2.h:405
complex floating point (GMP) numbers
Definition: coeffs.h:41
static char * ngfEatFloatNExp(char *s)
Definition: gnumpfl.cc:312
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:422
#define NULL
Definition: omList.c:10
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
void Werror(const char *fmt,...)
Definition: reporter.cc:199
void ngfSetChar ( const coeffs  r)

Definition at line 431 of file gnumpfl.cc.

432 {
433  setGMPFloatDigits(r->float_len, r->float_len2);
434 }
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
nMapFunc ngfSetMap ( const coeffs  src,
const coeffs  dst 
)

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

Definition at line 562 of file gnumpfl.cc.

563 {
564  assume( getCoeffType(dst) == ID );
565 
566  if (src->rep==n_rep_gap_rat) /*Q, Z*/
567  {
568  return ngfMapQ;
569  }
570  if (src->rep==n_rep_gap_gmp) /*Q, Z*/
571  {
572  return ngfMapZ;
573  }
574  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
575  {
576  return ndCopyMap; //ngfCopyMap;
577  }
578  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
579  {
580  return ngfMapR;
581  }
582  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
583  {
584  return ngfMapC;
585  }
586  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
587  {
588  return ngfMapP;
589  }
590  return NULL;
591 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:818
number ngfMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpfl.cc:514
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:892
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:834
(), see rinteger.h, new impl.
Definition: coeffs.h:111
number ngfMapQ(number from, const coeffs src, const coeffs r)
Definition: gnumpfl.cc:506
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:895
static number ngfMapC(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:553
#define assume(x)
Definition: mod2.h:405
(gmp_complex), see gnumpc.h
Definition: coeffs.h:117
static number ngfMapR(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:536
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
static number ngfMapP(number from, const coeffs src, const coeffs dst)
Definition: gnumpfl.cc:545
(number), see longrat.h
Definition: coeffs.h:110
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:116
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
(int), see modulop.h
Definition: coeffs.h:109
(float), see shortfl.h
Definition: coeffs.h:115
int ngfSize ( number  n,
const coeffs  r 
)

Definition at line 95 of file gnumpfl.cc.

96 {
97  long i = ngfInt(n, r);
98  /* basically return the largest integer in n;
99  only if this happens to be zero although n != 0,
100  return 1;
101  (this code ensures that zero has the size zero) */
102  if ((i == 0) && (ngfIsZero(n,r) == FALSE)) i = 1;
103  return i;
104 }
#define FALSE
Definition: auxiliary.h:140
const CanonicalForm CFMap CFMap int &both_non_zero int n
Definition: cfEzgcd.cc:52
int i
Definition: cfEzgcd.cc:123
BOOLEAN ngfIsZero(number za, const coeffs r)
Definition: gnumpfl.cc:255
long ngfInt(number &n, const coeffs r)
Definition: gnumpfl.cc:84
number ngfSub ( number  la,
number  li,
const coeffs  r 
)

Definition at line 190 of file gnumpfl.cc.

191 {
192  assume( getCoeffType(R) == ID );
193 
194  gmp_float* r= new gmp_float( (*(gmp_float*)a) - (*(gmp_float*)b) );
195  return (number)r;
196 }
const poly a
Definition: syzextra.cc:212
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:405
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define R
Definition: sirandom.c:26
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27
const poly b
Definition: syzextra.cc:213
void ngfWrite ( number  a,
const coeffs  r 
)

Definition at line 400 of file gnumpfl.cc.

401 {
402  assume( getCoeffType(r) == ID );
403 
404  char *out;
405  if ( a != NULL )
406  {
407  out= floatToStr(*(gmp_float*)a, r->float_len);
408  StringAppendS(out);
409  //omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
410  omFree( (void *)out );
411  }
412  else
413  {
414  StringAppendS("0");
415  }
416 }
const poly a
Definition: syzextra.cc:212
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:405
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:422
#define NULL
Definition: omList.c:10
char * floatToStr(const gmp_float &r, const unsigned int oprec)
Definition: mpr_complex.cc:591
static const n_coeffType ID
Our Type!
Definition: gnumpfl.cc:27

Variable Documentation

const n_coeffType ID = n_long_R
static

Our Type!

Definition at line 27 of file gnumpfl.cc.