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

Go to the source code of this file.

Functions

nMapFunc ngcSetMap (const coeffs src, const coeffs dst)
 Get a mapping function from src into the domain of this type: long_C! More...
 
number ngcMapQ (number from, const coeffs r, const coeffs aRing)
 
void ngcSetChar (const coeffs r)
 
BOOLEAN ngcGreaterZero (number za, const coeffs r)
 Note: MAY NOT WORK AS EXPECTED! More...
 
BOOLEAN ngcGreater (number a, number b, const coeffs r)
 
BOOLEAN ngcEqual (number a, number b, const coeffs r)
 
BOOLEAN ngcIsOne (number a, const coeffs r)
 
BOOLEAN ngcIsMOne (number a, const coeffs r)
 
BOOLEAN ngcIsZero (number za, const coeffs r)
 
number ngcInit (long i, const coeffs r)
 
long ngcInt (number &n, const coeffs r)
 
number ngcNeg (number za, const coeffs r)
 
number ngcInvers (number a, const coeffs r)
 
number ngcParameter (int i, const coeffs r)
 
number ngcAdd (number la, number li, const coeffs r)
 
number ngcSub (number la, number li, const coeffs r)
 
number ngcMult (number a, number b, const coeffs r)
 
number ngcDiv (number a, number b, const coeffs r)
 
void ngcPower (number x, int exp, number *lu, const coeffs r)
 
number ngcCopy (number a, const coeffs r)
 
number ngc_Copy (number a, coeffs r)
 
const char * ngcRead (const char *s, number *a, const coeffs r)
 
void ngcWrite (number a, const coeffs r)
 
number ngcRePart (number a, const coeffs r)
 
number ngcImPart (number a, const coeffs r)
 
void ngcDelete (number *a, const coeffs r)
 
void ngcCoeffWrite (const coeffs r, BOOLEAN details)
 
BOOLEAN ngcDBTest (number a, const char *f, const int l, const coeffs r)
 
int ngcSize (number n, const coeffs R)
 
BOOLEAN ngcCoeffIsEqual (const coeffs r, n_coeffType n, void *parameter)
 
static void ngcKillChar (coeffs r)
 
static char * ngcCoeffString (const coeffs r)
 
BOOLEAN ngcInitChar (coeffs n, void *parameter)
 Initialize r (n_long_C) More...
 
number ngcMapZ (number from, const coeffs aRing, const coeffs r)
 
static number ngcMapLongR (number from, const coeffs aRing, const coeffs r)
 
static number ngcMapR (number from, const coeffs aRing, const coeffs r)
 
static number ngcMapP (number from, const coeffs aRing, const coeffs r)
 
static number ngcCopyMap (number from, const coeffs aRing, const coeffs r)
 

Variables

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

Function Documentation

number ngc_Copy ( number  a,
coeffs  r 
)
number ngcAdd ( number  la,
number  li,
const coeffs  r 
)

Definition at line 192 of file gnumpc.cc.

193 {
194  assume( getCoeffType(R) == ID );
195 
196  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) );
197  return (number)r;
198 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
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:422
const poly b
Definition: syzextra.cc:213
BOOLEAN ngcCoeffIsEqual ( const coeffs  r,
n_coeffType  n,
void *  parameter 
)

Definition at line 421 of file gnumpc.cc.

422 {
423  if (n==ID)
424  {
425  LongComplexInfo* p = (LongComplexInfo *)(parameter);
426 
427  if ((p==NULL)
428  && (6==r->float_len)
429  && (6==r->float_len2)
430  && (strcmp("i",n_ParameterNames(r)[0]) == 0)
431  )
432  return TRUE;
433  if ((p!=NULL) &&
434  (p->float_len == r->float_len) &&
435  (p->float_len2 == r->float_len2)
436  )
437  if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
438  return (TRUE);
439  }
440  return (FALSE);
441 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
#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
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define NULL
Definition: omList.c:10
const char * par_name
parameter name
Definition: coeffs.h:102
static char* ngcCoeffString ( const coeffs  r)
static

Definition at line 456 of file gnumpc.cc.

457 {
458  const char *p=n_ParameterNames(r)[0];
459  char *s=(char*)omAlloc(31+strlen(p));
460  sprintf(s,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
461  return s;
462 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
const CanonicalForm int s
Definition: facAbsFact.cc:55
return P p
Definition: myNF.cc:203
#define omAlloc(size)
Definition: omAllocDecl.h:210
void ngcCoeffWrite ( const coeffs  r,
BOOLEAN  details 
)

Definition at line 732 of file gnumpc.cc.

733 {
734  Print("// characteristic : 0 (complex:%d digits, additional %d digits)\n",
735  r->float_len, r->float_len2); /* long C */
736  Print("// 1 parameter : %s \n", n_ParameterNames(r)[0]); // this trailing space is for compatibility with the legacy Singular
737  Print("// minpoly : (%s^2+1)\n", n_ParameterNames(r)[0]);
738 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
#define Print
Definition: emacs.cc:83
number ngcCopy ( number  a,
const coeffs  r 
)

Definition at line 149 of file gnumpc.cc.

150 {
151  assume( getCoeffType(r) == ID );
152 
153  gmp_complex* b= new gmp_complex( *(gmp_complex*)a );
154  return (number)b;
155 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
const poly b
Definition: syzextra.cc:213
static number ngcCopyMap ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 687 of file gnumpc.cc.

688 {
689  assume( getCoeffType(r) == ID );
690  assume( getCoeffType(aRing) == ID );
691 
692  gmp_complex* b = NULL;
693 
694  if ( from != NULL )
695  {
696  b = new gmp_complex( *(gmp_complex*)from );
697  }
698  return (number)b;
699 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
const poly b
Definition: syzextra.cc:213
BOOLEAN ngcDBTest ( number  a,
const char *  f,
const int  l,
const coeffs  r 
)

Definition at line 76 of file gnumpc.cc.

77 {
78  assume( getCoeffType(r) == ID );
79 
80  return TRUE;
81 }
#define TRUE
Definition: auxiliary.h:144
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
void ngcDelete ( number *  a,
const coeffs  r 
)

Definition at line 135 of file gnumpc.cc.

136 {
137  assume( getCoeffType(r) == ID );
138 
139  if ( *a != NULL )
140  {
141  delete *(gmp_complex**)a;
142  *a=NULL;
143  }
144 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
number ngcDiv ( number  a,
number  b,
const coeffs  r 
)

Definition at line 225 of file gnumpc.cc.

226 {
227  assume( getCoeffType(r) == ID );
228 
229  if (((gmp_complex*)b)->isZero())
230  {
231  // a/0 = error
232  WerrorS(nDivBy0);
233  return NULL;
234  }
235  gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) );
236  return (number)res;
237 }
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:24
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
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
bool isZero(const CFArray &A)
checks if entries of A are zero
const poly b
Definition: syzextra.cc:213
BOOLEAN ngcEqual ( number  a,
number  b,
const coeffs  r 
)

Definition at line 338 of file gnumpc.cc.

339 {
340  assume( getCoeffType(r) == ID );
341 
342  gmp_complex *aa=(gmp_complex*)a;
343  gmp_complex *bb=(gmp_complex*)b;
344  return (*aa) == (*bb);
345 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
const poly b
Definition: syzextra.cc:213
BOOLEAN ngcGreater ( number  a,
number  b,
const coeffs  r 
)

Definition at line 326 of file gnumpc.cc.

327 {
328  assume( getCoeffType(r) == ID );
329 
330  gmp_complex *aa=(gmp_complex*)a;
331  gmp_complex *bb=(gmp_complex*)b;
332  return (*aa) > (*bb);
333 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
const poly b
Definition: syzextra.cc:213
BOOLEAN ngcGreaterZero ( number  za,
const coeffs  r 
)

Note: MAY NOT WORK AS EXPECTED!

Definition at line 313 of file gnumpc.cc.

314 {
315  assume( getCoeffType(r) == ID );
316 
317  if ( ! ((gmp_complex*)a)->imag().isZero() )
318  return ( abs( *(gmp_complex*)a).sign() >= 0 );
319  else
320  return ( ((gmp_complex*)a)->real().sign() >= 0 );
321 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
Rational abs(const Rational &a)
Definition: GMPrat.cc:443
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
int sign(const CanonicalForm &a)
number ngcImPart ( number  a,
const coeffs  r 
)

Definition at line 302 of file gnumpc.cc.

303 {
304  assume( getCoeffType(r) == ID );
305 
306  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->imag());
307  return (number)n;
308 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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 ngcInit ( long  i,
const coeffs  r 
)

Definition at line 98 of file gnumpc.cc.

99 {
100  assume( getCoeffType(r) == ID );
101 
102  gmp_complex* n= new gmp_complex( (long)i, (long)0 );
103 
104  return (number)n;
105 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
BOOLEAN ngcInitChar ( coeffs  n,
void *  parameter 
)

Initialize r (n_long_C)

Definition at line 464 of file gnumpc.cc.

465 {
466  assume( getCoeffType(n) == ID );
467  n->is_field=TRUE;
468  n->is_domain=TRUE;
469  n->rep=n_rep_gmp_complex;
470 
471  n->cfKillChar = ngcKillChar;
472  n->ch = 0;
473  n->cfCoeffString=ngcCoeffString;
474 
475  n->cfDelete = ngcDelete;
476  //n->cfNormalize=ndNormalize;
477  n->cfInit = ngcInit;
478  n->cfInt = ngcInt;
479  n->cfAdd = ngcAdd;
480  n->cfSub = ngcSub;
481  n->cfMult = ngcMult;
482  n->cfDiv = ngcDiv;
483  n->cfExactDiv= ngcDiv;
484  n->cfInpNeg = ngcNeg;
485  n->cfInvers = ngcInvers;
486  n->cfCopy = ngcCopy;
487  n->cfGreater = ngcGreater;
488  n->cfEqual = ngcEqual;
489  n->cfIsZero = ngcIsZero;
490  n->cfIsOne = ngcIsOne;
491  n->cfIsMOne = ngcIsMOne;
492  n->cfGreaterZero = ngcGreaterZero;
493 
494  n->cfWriteLong = ngcWrite;
495  n->cfWriteShort = ngcWrite;
496 
497  n->cfRead = ngcRead;
498  n->cfPower = ngcPower;
499  n->cfSetMap = ngcSetMap;
500  n->cfRePart = ngcRePart;
501  n->cfImPart = ngcImPart;
502  n->cfCoeffWrite = ngcCoeffWrite;
503  // cfSize = ndSize;
504 #ifdef LDEBUG
505  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
506 #endif
507 
508  n->nCoeffIsEqual = ngcCoeffIsEqual;
509 
510  n->cfSetChar=ngcSetChar;
511 
512 // we need to initialize n->nNULL at least for minpoly printing
513  n->nNULL = n->cfInit(0,n);
514 
515 /*
516  //r->cfInitChar=nlInitChar;
517  r->cfKillChar=NULL;
518 
519  r->cfMult = nlMult;
520  r->cfSub = nlSub;
521  r->cfAdd = nlAdd;
522  r->cfDiv = nlDiv;
523  r->cfIntMod= nlIntMod;
524  r->cfExactDiv= nlExactDiv;
525  r->cfInit = nlInit;
526  r->cfSize = nlSize;
527  r->cfInt = nlInt;
528 #ifdef HAVE_RINGS
529  r->cfDivComp = NULL; // only for ring stuff
530  r->cfIsUnit = NULL; // only for ring stuff
531  r->cfGetUnit = NULL; // only for ring stuff
532  r->cfExtGcd = NULL; // only for ring stuff
533 #endif
534  r->cfInpNeg = nlNeg;
535  r->cfInvers= nlInvers;
536  r->cfCopy = nl_Copy;
537  r->cfRePart = nl_Copy;
538  r->cfImPart = ndReturn0;
539  r->cfWriteLong = nlWrite;
540  r->cfRead = nlRead;
541  r->cfNormalize=nlNormalize;
542  r->cfGreater = nlGreater;
543 #ifdef HAVE_RINGS
544  r->cfDivBy = NULL; // only for ring stuff
545 #endif
546  r->cfEqual = nlEqual;
547  r->cfIsZero = nlIsZero;
548  r->cfIsOne = nlIsOne;
549  r->cfIsMOne = nlIsMOne;
550  r->cfGreaterZero = nlGreaterZero;
551  r->cfPower = nlPower;
552  r->cfGetDenom = nlGetDenom;
553  r->cfGetNumerator = nlGetNumerator;
554  r->cfGcd = nlGcd;
555  r->cfLcm = nlLcm;
556  r->cfDelete= nlDelete;
557  r->cfSetMap = nlSetMap;
558  r->cfName = ndName;
559  r->cfInpMult=nlInpMult;
560  r->cfInit_bigint=nlCopyMap;
561 #ifdef LDEBUG
562  // debug stuff
563  r->cfDBTest=nlDBTest;
564 #endif
565 
566  // the variables:
567  r->nNULL = INT_TO_SR(0);
568  r->type = n_Q;
569  r->ch = 0;
570  r->has_simple_Alloc=FALSE;
571  r->has_simple_Inverse=FALSE;
572 */
573 
574  n->iNumberOfParameters = 1;
575  n->cfParameter = ngcParameter;
576 
577  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
578 
579  if( parameter != NULL)
580  {
581  LongComplexInfo* p = (LongComplexInfo*)parameter;
582  pParameterNames[0] = omStrDup(p->par_name);
583  // fix wrong parameters:
585  n->float_len = p->float_len;
586  n->float_len2 = p->float_len2;
587 
588  } else // default values, just for testing!
589  {
590  pParameterNames[0] = omStrDup("i");
591  n->float_len = SHORT_REAL_LENGTH;
592  n->float_len2 = SHORT_REAL_LENGTH;
593  }
594 
595  assume( pParameterNames != NULL );
596  assume( pParameterNames[0] != NULL );
597 
598  n->pParameterNames = (const char**)pParameterNames;
599 
600  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
601  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
602 
603  return FALSE;
604 }
void ngcPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpc.cc:242
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:443
number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:294
void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:135
number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:98
void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:405
number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:302
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
Get a mapping function from src into the domain of this type: long_C!
Definition: gnumpc.cc:701
long ngcInt(number &n, const coeffs r)
Definition: gnumpc.cc:110
#define TRUE
Definition: auxiliary.h:144
number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:225
BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:421
short float_len2
additional char-flags, rInit
Definition: coeffs.h:101
void ngcCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpc.cc:732
static char * ngcCoeffString(const coeffs r)
Definition: gnumpc.cc:456
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:606
short float_len
additional char-flags, rInit
Definition: coeffs.h:100
BOOLEAN ngcGreaterZero(number za, const coeffs r)
Note: MAY NOT WORK AS EXPECTED!
Definition: gnumpc.cc:313
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
number ngcSub(number la, number li, const coeffs r)
Definition: gnumpc.cc:203
#define assume(x)
Definition: mod2.h:405
(gmp_complex), see gnumpc.h
Definition: coeffs.h:117
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:350
BOOLEAN ngcIsZero(number za, const coeffs r)
Definition: gnumpc.cc:287
BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:361
#define NULL
Definition: omList.c:10
number ngcMult(number a, number b, const coeffs r)
Definition: gnumpc.cc:214
number ngcAdd(number la, number li, const coeffs r)
Definition: gnumpc.cc:192
const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:372
BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:326
number ngcParameter(int i, const coeffs r)
Definition: gnumpc.cc:84
const char * par_name
parameter name
Definition: coeffs.h:102
number ngcInvers(number a, const coeffs r)
Definition: gnumpc.cc:173
number ngcNeg(number za, const coeffs r)
Definition: gnumpc.cc:161
BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:338
#define omAlloc0(size)
Definition: omAllocDecl.h:211
number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:149
#define omStrDup(s)
Definition: omAllocDecl.h:263
long ngcInt ( number &  n,
const coeffs  r 
)

Definition at line 110 of file gnumpc.cc.

111 {
112  assume( getCoeffType(r) == ID );
113 
114  return ((gmp_complex*)i)->real();
115 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
number ngcInvers ( number  a,
const coeffs  r 
)

Definition at line 173 of file gnumpc.cc.

174 {
175  assume( getCoeffType(R) == ID );
176 
177  gmp_complex* r = NULL;
178  if (((gmp_complex*)a)->isZero())
179  {
180  WerrorS(nDivBy0);
181  }
182  else
183  {
184  r = new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) );
185  }
186  return (number)r;
187 }
const poly a
Definition: syzextra.cc:212
void WerrorS(const char *s)
Definition: feFopen.cc:24
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
const ring R
Definition: DebugPrint.cc:36
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
bool isZero(const CFArray &A)
checks if entries of A are zero
BOOLEAN ngcIsMOne ( number  a,
const coeffs  r 
)

Definition at line 361 of file gnumpc.cc.

362 {
363  assume( getCoeffType(r) == ID );
364 
365  return (((gmp_complex*)a)->real().isMOne() && ((gmp_complex*)a)->imag().isZero());
366  //return (((gmp_complex*)a)->real().isMOne());
367 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
BOOLEAN ngcIsOne ( number  a,
const coeffs  r 
)

Definition at line 350 of file gnumpc.cc.

351 {
352  assume( getCoeffType(r) == ID );
353 
354  return (((gmp_complex*)a)->real().isOne() && ((gmp_complex*)a)->imag().isZero());
355  //return (((gmp_complex*)a)->real().isOne());
356 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
BOOLEAN ngcIsZero ( number  za,
const coeffs  r 
)

Definition at line 287 of file gnumpc.cc.

288 {
289  assume( getCoeffType(r) == ID );
290 
291  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
292 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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 void ngcKillChar ( coeffs  r)
static

Definition at line 443 of file gnumpc.cc.

444 {
445  char** p = (char**)n_ParameterNames(r);
446 
447  const int P = n_NumberOfParameters(r);
448 
449  for( int i = 1; i <= P; i++ )
450  if (p[i-1] != NULL)
451  omFree( (ADDRESS)p[i-1] );
452 
453  omFreeSize((ADDRESS)p, P * sizeof(char*));
454 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:161
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:792
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:123
#define NULL
Definition: omList.c:10
kBucketDestroy & P
Definition: myNF.cc:191
static number ngcMapLongR ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 648 of file gnumpc.cc.

649 {
650  assume( getCoeffType(r) == ID );
651  assume( getCoeffType(aRing) == n_long_R );
652 
653  if ( from != NULL )
654  {
655  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
656  return (number)res;
657  }
658  else
659  return NULL;
660 }
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
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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 number ngcMapP ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 676 of file gnumpc.cc.

677 {
678  assume( getCoeffType(r) == ID );
679  assume( getCoeffType(aRing) == n_Zp );
680 
681  if ( from != NULL )
682  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
683  else
684  return NULL;
685 }
number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:98
long npInt(number &n, const coeffs r)
Definition: modulop.cc:143
{p < 2^31}
Definition: coeffs.h:30
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
number ngcMapQ ( number  from,
const coeffs  r,
const coeffs  aRing 
)

Definition at line 613 of file gnumpc.cc.

614 {
615  assume( getCoeffType(r) == ID );
616  assume( aRing->rep == n_rep_gap_rat);
617 
618  if ( from != NULL )
619  {
621  return (number)res;
622  }
623  else
624  return NULL;
625 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
#define NULL
Definition: omList.c:10
gmp_float numberFieldToFloat(number num, int k, const coeffs src)
Definition: mpr_complex.cc:440
static number ngcMapR ( number  from,
const coeffs  aRing,
const coeffs  r 
)
static

Definition at line 662 of file gnumpc.cc.

663 {
664  assume( getCoeffType(r) == ID );
665  assume( getCoeffType(aRing) == n_R );
666 
667  if ( from != NULL )
668  {
669  gmp_complex *res=new gmp_complex((double)nrFloat(from)); // FIXME? TODO? // extern float nrFloat(number n);
670  return (number)res;
671  }
672  else
673  return NULL;
674 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
single prescision (6,6) real numbers
Definition: coeffs.h:32
float nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
Definition: shortfl.cc:78
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
number ngcMapZ ( number  from,
const coeffs  aRing,
const coeffs  r 
)

Definition at line 627 of file gnumpc.cc.

628 {
629  assume( getCoeffType(r) == ID );
630  assume( aRing->rep == n_rep_gap_gmp);
631 
632  if ( from != NULL )
633  {
634  if (SR_HDL(from) & SR_INT)
635  {
636  gmp_float f_i= gmp_float(SR_TO_INT(from));
637  gmp_complex *res=new gmp_complex(f_i);
638  return (number)res;
639  }
640  gmp_float f_i=(mpz_ptr)from;
641  gmp_complex *res=new gmp_complex(f_i);
642  return (number)res;
643  }
644  else
645  return NULL;
646 }
(), see rinteger.h, new impl.
Definition: coeffs.h:111
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
#define SR_HDL(A)
Definition: tgb.cc:35
number ngcMult ( number  a,
number  b,
const coeffs  r 
)

Definition at line 214 of file gnumpc.cc.

215 {
216  assume( getCoeffType(R) == ID );
217 
218  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) );
219  return (number)r;
220 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
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:422
const poly b
Definition: syzextra.cc:213
number ngcNeg ( number  za,
const coeffs  r 
)

Definition at line 161 of file gnumpc.cc.

162 {
163  assume( getCoeffType(R) == ID );
164 
166  (*r).neg();
167  return (number)a;
168 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
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:422
number ngcParameter ( int  i,
const coeffs  r 
)

Definition at line 84 of file gnumpc.cc.

85 {
86  assume( getCoeffType(r) == ID );
87  assume(i==1);
88 
89  if( i == 1 )
90  return (number)(new gmp_complex( (long)0, (long)1 ));
91 
92  return NULL; // new gmp_complex( ) // 0?
93 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
#define NULL
Definition: omList.c:10
void ngcPower ( number  x,
int  exp,
number *  lu,
const coeffs  r 
)

Definition at line 242 of file gnumpc.cc.

243 {
244  assume( getCoeffType(r) == ID );
245 
246  if ( exp == 0 )
247  {
248  gmp_complex* n = new gmp_complex(1);
249  *u=(number)n;
250  return;
251  }
252  else if ( exp == 1 )
253  {
254  n_New(u, r);
255  gmp_complex* n = new gmp_complex();
256  *n= *(gmp_complex*)x;
257  *u=(number)n;
258  return;
259  }
260  else if (exp == 2)
261  {
262  n_New(u, r);
263  gmp_complex* n = new gmp_complex();
264  *n= *(gmp_complex*)x;
265  *u=(number)n;
266  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
267  return;
268  }
269  if ( (exp & 1) == 1 )
270  {
271  ngcPower(x,exp-1,u, r);
272  gmp_complex *n = new gmp_complex();
273  *n=*(gmp_complex*)x;
274  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
275  delete n;
276  }
277  else
278  {
279  number w;
280  n_New(&w, r);
281  ngcPower(x,exp/2,&w, r);
282  ngcPower(w,2,u, r);
283  n_Delete(&w, r);
284  }
285 }
#define n_New(n, r)
Definition: coeffs.h:441
void ngcPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpc.cc:242
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
const CanonicalForm & w
Definition: facAbsFact.cc:55
Variable x
Definition: cfModGcd.cc:4023
p exp[i]
Definition: DebugPrint.cc:39
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
const char * ngcRead ( const char *  s,
number *  a,
const coeffs  r 
)

Definition at line 372 of file gnumpc.cc.

373 {
374  assume( getCoeffType(r) == ID );
375  const char * const complex_parameter = n_ParameterNames(r)[0];
376  assume( complex_parameter != NULL );
377  const int N = strlen(complex_parameter);
378 
379  if ((*s >= '0') && (*s <= '9'))
380  {
381  gmp_float *re=NULL;
382  s=ngfRead(s,(number *)&re, r); // FIXME? TODO? // extern const char * ngfRead (const char *s, number *a, const coeffs r);
383  gmp_complex *aa=new gmp_complex(*re);
384  *a=(number)aa;
385  delete re;
386  }
387  else if (strncmp(s, complex_parameter, N)==0)
388  {
389  s += N;
390  gmp_complex *aa=new gmp_complex((long)0,(long)1);
391  *a=(number)aa;
392  }
393  else
394  {
395  *a=(number) new gmp_complex((long)1);
396  }
397  return s;
398 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:796
const CanonicalForm int s
Definition: facAbsFact.cc:55
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:341
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
number ngcRePart ( number  a,
const coeffs  r 
)

Definition at line 294 of file gnumpc.cc.

295 {
296  assume( getCoeffType(r) == ID );
297 
298  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->real());
299  return (number)n;
300 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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
void ngcSetChar ( const coeffs  r)

Definition at line 606 of file gnumpc.cc.

607 {
608  setGMPFloatDigits(r->float_len, r->float_len2);
609 }
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 ngcSetMap ( const coeffs  src,
const coeffs  dst 
)

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

Definition at line 701 of file gnumpc.cc.

702 {
703  assume( getCoeffType(dst) == ID );
704 
705  if (src->rep==n_rep_gap_rat) /* Q, Z*/
706  {
707  return ngcMapQ;
708  }
709  if (src->rep==n_rep_gap_gmp) /* Z */
710  {
711  return ngcMapZ;
712  }
713  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
714  {
715  return ngcMapLongR;
716  }
717  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
718  {
719  return ngcCopyMap;
720  }
721  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
722  {
723  return ngcMapR;
724  }
725  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
726  {
727  return ngcMapP;
728  }
729  return NULL;
730 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:818
static number ngcMapR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:662
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 ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:627
number ngcMapQ(number from, const coeffs r, const coeffs aRing)
Definition: gnumpc.cc:613
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:895
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:676
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
(gmp_complex), see gnumpc.h
Definition: coeffs.h:117
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
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:116
(int), see modulop.h
Definition: coeffs.h:109
static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:687
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:648
(float), see shortfl.h
Definition: coeffs.h:115
int ngcSize ( number  n,
const coeffs  R 
)

Definition at line 117 of file gnumpc.cc.

118 {
119  int r = (int)((gmp_complex*)n)->real();
120  if (r < 0) r = -r;
121  int i = (int)((gmp_complex*)n)->imag();
122  if (i < 0) i = -i;
123  int oneNorm = r + i;
124  /* basically return the 1-norm of n;
125  only if this happens to be zero although n != 0,
126  return 1;
127  (this code ensures that zero has the size zero) */
128  if ((oneNorm == 0.0) & (ngcIsZero(n,R) == FALSE)) oneNorm = 1;
129  return oneNorm;
130 }
#define FALSE
Definition: auxiliary.h:140
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
int i
Definition: cfEzgcd.cc:123
BOOLEAN ngcIsZero(number za, const coeffs r)
Definition: gnumpc.cc:287
static CanonicalForm oneNorm(const CanonicalForm &F)
number ngcSub ( number  la,
number  li,
const coeffs  r 
)

Definition at line 203 of file gnumpc.cc.

204 {
205  assume( getCoeffType(R) == ID );
206 
207  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) - (*(gmp_complex*)b) );
208  return (number)r;
209 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#define assume(x)
Definition: mod2.h:405
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:422
const poly b
Definition: syzextra.cc:213
void ngcWrite ( number  a,
const coeffs  r 
)

Definition at line 405 of file gnumpc.cc.

406 {
407  assume( getCoeffType(r) == ID );
408 
409  if (a==NULL)
410  StringAppendS("0");
411  else
412  {
413  char *out;
414  out= complexToStr(*(gmp_complex*)a, r->float_len, r);
415  StringAppendS(out);
416  // omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
417  omFree( (void *)out );
418  }
419 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
static const n_coeffType ID
Our Type!
Definition: gnumpc.cc:71
#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 * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:717

Variable Documentation

const n_coeffType ID = n_long_C
static

Our Type!

Definition at line 71 of file gnumpc.cc.