Functions
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)
 

Function Documentation

§ ngc_Copy()

number ngc_Copy ( number  a,
coeffs  r 
)

§ ngcAdd()

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

Definition at line 188 of file gnumpc.cc.

189 {
190  assume( getCoeffType(R) == n_long_C );
191 
192  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) );
193  return (number)r;
194 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:403
const ring R
Definition: DebugPrint.cc:36
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
const poly b
Definition: syzextra.cc:213

§ ngcCoeffIsEqual()

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

Definition at line 417 of file gnumpc.cc.

418 {
419  if (n==n_long_C)
420  {
421  LongComplexInfo* p = (LongComplexInfo *)(parameter);
422 
423  if ((p==NULL)
424  && (6==r->float_len)
425  && (6==r->float_len2)
426  && (strcmp("i",n_ParameterNames(r)[0]) == 0)
427  )
428  return TRUE;
429  if ((p!=NULL) &&
430  (p->float_len == r->float_len) &&
431  (p->float_len2 == r->float_len2)
432  )
433  if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
434  return (TRUE);
435  }
436  return (FALSE);
437 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
#define FALSE
Definition: auxiliary.h:97
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:101
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
complex floating point (GMP) numbers
Definition: coeffs.h:42
#define NULL
Definition: omList.c:10
const char * par_name
parameter name
Definition: coeffs.h:103

§ ngcCoeffString()

static char* ngcCoeffString ( const coeffs  r)
static

Definition at line 452 of file gnumpc.cc.

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

§ ngcCoeffWrite()

void ngcCoeffWrite ( const coeffs  r,
BOOLEAN  details 
)

Definition at line 728 of file gnumpc.cc.

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

§ ngcCopy()

number ngcCopy ( number  a,
const coeffs  r 
)

Definition at line 145 of file gnumpc.cc.

146 {
147  assume( getCoeffType(r) == n_long_C );
148 
149  gmp_complex* b= new gmp_complex( *(gmp_complex*)a );
150  return (number)b;
151 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
const poly b
Definition: syzextra.cc:213

§ ngcCopyMap()

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

Definition at line 683 of file gnumpc.cc.

684 {
685  assume( getCoeffType(r) == n_long_C );
686  assume( getCoeffType(aRing) == n_long_C );
687 
688  gmp_complex* b = NULL;
689 
690  if ( from != NULL )
691  {
692  b = new gmp_complex( *(gmp_complex*)from );
693  }
694  return (number)b;
695 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
#define NULL
Definition: omList.c:10
const poly b
Definition: syzextra.cc:213

§ ngcDBTest()

BOOLEAN ngcDBTest ( number  a,
const char *  f,
const int  l,
const coeffs  r 
)

Definition at line 72 of file gnumpc.cc.

73 {
74  assume( getCoeffType(r) == n_long_C );
75 
76  return TRUE;
77 }
#define TRUE
Definition: auxiliary.h:101
#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

§ ngcDelete()

void ngcDelete ( number *  a,
const coeffs  r 
)

Definition at line 131 of file gnumpc.cc.

132 {
133  assume( getCoeffType(r) == n_long_C );
134 
135  if ( *a != NULL )
136  {
137  delete *(gmp_complex**)a;
138  *a=NULL;
139  }
140 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
#define NULL
Definition: omList.c:10

§ ngcDiv()

number ngcDiv ( number  a,
number  b,
const coeffs  r 
)

Definition at line 221 of file gnumpc.cc.

222 {
223  assume( getCoeffType(r) == n_long_C );
224 
225  if (((gmp_complex*)b)->isZero())
226  {
227  // a/0 = error
228  WerrorS(nDivBy0);
229  return NULL;
230  }
231  gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) );
232  return (number)res;
233 }
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
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
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
bool isZero(const CFArray &A)
checks if entries of A are zero
const poly b
Definition: syzextra.cc:213

§ ngcEqual()

BOOLEAN ngcEqual ( number  a,
number  b,
const coeffs  r 
)

Definition at line 334 of file gnumpc.cc.

335 {
336  assume( getCoeffType(r) == n_long_C );
337 
338  gmp_complex *aa=(gmp_complex*)a;
339  gmp_complex *bb=(gmp_complex*)b;
340  return (*aa) == (*bb);
341 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
const poly b
Definition: syzextra.cc:213

§ ngcGreater()

BOOLEAN ngcGreater ( number  a,
number  b,
const coeffs  r 
)

Definition at line 322 of file gnumpc.cc.

323 {
324  assume( getCoeffType(r) == n_long_C );
325 
326  gmp_complex *aa=(gmp_complex*)a;
327  gmp_complex *bb=(gmp_complex*)b;
328  return (*aa) > (*bb);
329 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
const poly b
Definition: syzextra.cc:213

§ ngcGreaterZero()

BOOLEAN ngcGreaterZero ( number  za,
const coeffs  r 
)

Note: MAY NOT WORK AS EXPECTED!

Definition at line 309 of file gnumpc.cc.

310 {
311  assume( getCoeffType(r) == n_long_C );
312 
313  if ( ! ((gmp_complex*)a)->imag().isZero() )
314  return ( abs( *(gmp_complex*)a).sign() >= 0 );
315  else
316  return ( ((gmp_complex*)a)->real().sign() >= 0 );
317 }
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
#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
bool isZero(const CFArray &A)
checks if entries of A are zero
static int sign(int x)
Definition: ring.cc:3412

§ ngcImPart()

number ngcImPart ( number  a,
const coeffs  r 
)

Definition at line 298 of file gnumpc.cc.

299 {
300  assume( getCoeffType(r) == n_long_C );
301 
302  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->imag());
303  return (number)n;
304 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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

§ ngcInit()

number ngcInit ( long  i,
const coeffs  r 
)

Definition at line 94 of file gnumpc.cc.

95 {
96  assume( getCoeffType(r) == n_long_C );
97 
98  gmp_complex* n= new gmp_complex( (long)i, 0L );
99 
100  return (number)n;
101 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
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

§ ngcInitChar()

BOOLEAN ngcInitChar ( coeffs  n,
void *  parameter 
)

Initialize r (n_long_C)

Definition at line 460 of file gnumpc.cc.

461 {
462  assume( getCoeffType(n) == n_long_C );
463  n->is_field=TRUE;
464  n->is_domain=TRUE;
465  n->rep=n_rep_gmp_complex;
466 
467  n->cfKillChar = ngcKillChar;
468  n->ch = 0;
469  n->cfCoeffString=ngcCoeffString;
470 
471  n->cfDelete = ngcDelete;
472  //n->cfNormalize=ndNormalize;
473  n->cfInit = ngcInit;
474  n->cfInt = ngcInt;
475  n->cfAdd = ngcAdd;
476  n->cfSub = ngcSub;
477  n->cfMult = ngcMult;
478  n->cfDiv = ngcDiv;
479  n->cfExactDiv= ngcDiv;
480  n->cfInpNeg = ngcNeg;
481  n->cfInvers = ngcInvers;
482  n->cfCopy = ngcCopy;
483  n->cfGreater = ngcGreater;
484  n->cfEqual = ngcEqual;
485  n->cfIsZero = ngcIsZero;
486  n->cfIsOne = ngcIsOne;
487  n->cfIsMOne = ngcIsMOne;
488  n->cfGreaterZero = ngcGreaterZero;
489 
490  n->cfWriteLong = ngcWrite;
491  n->cfWriteShort = ngcWrite;
492 
493  n->cfRead = ngcRead;
494  n->cfPower = ngcPower;
495  n->cfSetMap = ngcSetMap;
496  n->cfRePart = ngcRePart;
497  n->cfImPart = ngcImPart;
498  n->cfCoeffWrite = ngcCoeffWrite;
499  // cfSize = ndSize;
500 #ifdef LDEBUG
501  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
502 #endif
503 
504  n->nCoeffIsEqual = ngcCoeffIsEqual;
505 
506  n->cfSetChar=ngcSetChar;
507 
508 // we need to initialize n->nNULL at least for minpoly printing
509  n->nNULL = n->cfInit(0,n);
510 
511 /*
512  //r->cfInitChar=nlInitChar;
513  r->cfKillChar=NULL;
514 
515  r->cfMult = nlMult;
516  r->cfSub = nlSub;
517  r->cfAdd = nlAdd;
518  r->cfDiv = nlDiv;
519  r->cfIntMod= nlIntMod;
520  r->cfExactDiv= nlExactDiv;
521  r->cfInit = nlInit;
522  r->cfSize = nlSize;
523  r->cfInt = nlInt;
524 #ifdef HAVE_RINGS
525  r->cfDivComp = NULL; // only for ring stuff
526  r->cfIsUnit = NULL; // only for ring stuff
527  r->cfGetUnit = NULL; // only for ring stuff
528  r->cfExtGcd = NULL; // only for ring stuff
529 #endif
530  r->cfInpNeg = nlNeg;
531  r->cfInvers= nlInvers;
532  r->cfCopy = nl_Copy;
533  r->cfRePart = nl_Copy;
534  r->cfImPart = ndReturn0;
535  r->cfWriteLong = nlWrite;
536  r->cfRead = nlRead;
537  r->cfNormalize=nlNormalize;
538  r->cfGreater = nlGreater;
539 #ifdef HAVE_RINGS
540  r->cfDivBy = NULL; // only for ring stuff
541 #endif
542  r->cfEqual = nlEqual;
543  r->cfIsZero = nlIsZero;
544  r->cfIsOne = nlIsOne;
545  r->cfIsMOne = nlIsMOne;
546  r->cfGreaterZero = nlGreaterZero;
547  r->cfPower = nlPower;
548  r->cfGetDenom = nlGetDenom;
549  r->cfGetNumerator = nlGetNumerator;
550  r->cfGcd = nlGcd;
551  r->cfLcm = nlLcm;
552  r->cfDelete= nlDelete;
553  r->cfSetMap = nlSetMap;
554  r->cfName = ndName;
555  r->cfInpMult=nlInpMult;
556  r->cfInit_bigint=nlCopyMap;
557 #ifdef LDEBUG
558  // debug stuff
559  r->cfDBTest=nlDBTest;
560 #endif
561 
562  // the variables:
563  r->nNULL = INT_TO_SR(0);
564  r->type = n_Q;
565  r->ch = 0;
566  r->has_simple_Alloc=FALSE;
567  r->has_simple_Inverse=FALSE;
568 */
569 
570  n->iNumberOfParameters = 1;
571  n->cfParameter = ngcParameter;
572 
573  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
574 
575  if( parameter != NULL)
576  {
577  LongComplexInfo* p = (LongComplexInfo*)parameter;
578  pParameterNames[0] = omStrDup(p->par_name);
579  // fix wrong parameters:
581  n->float_len = p->float_len;
582  n->float_len2 = p->float_len2;
583 
584  } else // default values, just for testing!
585  {
586  pParameterNames[0] = omStrDup("i");
587  n->float_len = SHORT_REAL_LENGTH;
588  n->float_len2 = SHORT_REAL_LENGTH;
589  }
590 
591  assume( pParameterNames != NULL );
592  assume( pParameterNames[0] != NULL );
593 
594  n->pParameterNames = (const char**)pParameterNames;
595 
596  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
597  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
598 
599  return FALSE;
600 }
void ngcPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpc.cc:238
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:439
number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:290
void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:131
number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:94
void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:401
number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:298
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
#define FALSE
Definition: auxiliary.h:97
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:697
long ngcInt(number &n, const coeffs r)
Definition: gnumpc.cc:106
#define TRUE
Definition: auxiliary.h:101
number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:221
BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:417
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
void ngcCoeffWrite(const coeffs r, BOOLEAN details)
Definition: gnumpc.cc:728
static char * ngcCoeffString(const coeffs r)
Definition: gnumpc.cc:452
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:602
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
BOOLEAN ngcGreaterZero(number za, const coeffs r)
Note: MAY NOT WORK AS EXPECTED!
Definition: gnumpc.cc:309
number ngcSub(number la, number li, const coeffs r)
Definition: gnumpc.cc:199
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:346
BOOLEAN ngcIsZero(number za, const coeffs r)
Definition: gnumpc.cc:283
BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:357
#define NULL
Definition: omList.c:10
number ngcMult(number a, number b, const coeffs r)
Definition: gnumpc.cc:210
number ngcAdd(number la, number li, const coeffs r)
Definition: gnumpc.cc:188
const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:368
BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:322
number ngcParameter(int i, const coeffs r)
Definition: gnumpc.cc:80
const char * par_name
parameter name
Definition: coeffs.h:103
number ngcInvers(number a, const coeffs r)
Definition: gnumpc.cc:169
number ngcNeg(number za, const coeffs r)
Definition: gnumpc.cc:157
BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:334
#define omAlloc0(size)
Definition: omAllocDecl.h:211
number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:145
#define omStrDup(s)
Definition: omAllocDecl.h:263

§ ngcInt()

long ngcInt ( number &  n,
const coeffs  r 
)

Definition at line 106 of file gnumpc.cc.

107 {
108  assume( getCoeffType(r) == n_long_C );
109 
110  return ((gmp_complex*)i)->real();
111 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
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

§ ngcInvers()

number ngcInvers ( number  a,
const coeffs  r 
)

Definition at line 169 of file gnumpc.cc.

170 {
171  assume( getCoeffType(R) == n_long_C );
172 
173  gmp_complex* r = NULL;
174  if (((gmp_complex*)a)->isZero())
175  {
176  WerrorS(nDivBy0);
177  }
178  else
179  {
180  r = new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) );
181  }
182  return (number)r;
183 }
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
#define assume(x)
Definition: mod2.h:403
const ring R
Definition: DebugPrint.cc:36
complex floating point (GMP) numbers
Definition: coeffs.h:42
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
bool isZero(const CFArray &A)
checks if entries of A are zero

§ ngcIsMOne()

BOOLEAN ngcIsMOne ( number  a,
const coeffs  r 
)

Definition at line 357 of file gnumpc.cc.

358 {
359  assume( getCoeffType(r) == n_long_C );
360 
361  return (((gmp_complex*)a)->real().isMOne() && ((gmp_complex*)a)->imag().isZero());
362  //return (((gmp_complex*)a)->real().isMOne());
363 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
bool isZero(const CFArray &A)
checks if entries of A are zero

§ ngcIsOne()

BOOLEAN ngcIsOne ( number  a,
const coeffs  r 
)

Definition at line 346 of file gnumpc.cc.

347 {
348  assume( getCoeffType(r) == n_long_C );
349 
350  return (((gmp_complex*)a)->real().isOne() && ((gmp_complex*)a)->imag().isZero());
351  //return (((gmp_complex*)a)->real().isOne());
352 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
bool isZero(const CFArray &A)
checks if entries of A are zero

§ ngcIsZero()

BOOLEAN ngcIsZero ( number  za,
const coeffs  r 
)

Definition at line 283 of file gnumpc.cc.

284 {
285  assume( getCoeffType(r) == n_long_C );
286 
287  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
288 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
bool isZero(const CFArray &A)
checks if entries of A are zero

§ ngcKillChar()

static void ngcKillChar ( coeffs  r)
static

Definition at line 439 of file gnumpc.cc.

440 {
441  char** p = (char**)n_ParameterNames(r);
442 
443  const int P = n_NumberOfParameters(r);
444 
445  for( int i = 1; i <= P; i++ )
446  if (p[i-1] != NULL)
447  omFree( (ADDRESS)p[i-1] );
448 
449  omFreeSize((ADDRESS)p, P * sizeof(char*));
450 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
return P p
Definition: myNF.cc:203
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:118
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:808
#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

§ ngcMapLongR()

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

Definition at line 644 of file gnumpc.cc.

645 {
646  assume( getCoeffType(r) == n_long_C );
647  assume( getCoeffType(aRing) == n_long_R );
648 
649  if ( from != NULL )
650  {
651  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
652  return (number)res;
653  }
654  else
655  return NULL;
656 }
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
#define NULL
Definition: omList.c:10

§ ngcMapP()

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

Definition at line 672 of file gnumpc.cc.

673 {
674  assume( getCoeffType(r) == n_long_C );
675  assume( getCoeffType(aRing) == n_Zp );
676 
677  if ( from != NULL )
678  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
679  else
680  return NULL;
681 }
number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:94
long npInt(number &n, const coeffs r)
Definition: modulop.cc:140
{p < 2^31}
Definition: coeffs.h:30
#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
#define NULL
Definition: omList.c:10

§ ngcMapQ()

number ngcMapQ ( number  from,
const coeffs  r,
const coeffs  aRing 
)

Definition at line 609 of file gnumpc.cc.

610 {
611  assume( getCoeffType(r) == n_long_C );
612  assume( aRing->rep == n_rep_gap_rat);
613 
614  if ( from != NULL )
615  {
617  return (number)res;
618  }
619  else
620  return NULL;
621 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
#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
#define NULL
Definition: omList.c:10
gmp_float numberFieldToFloat(number num, int k, const coeffs src)
Definition: mpr_complex.cc:440

§ ngcMapR()

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

Definition at line 658 of file gnumpc.cc.

659 {
660  assume( getCoeffType(r) == n_long_C );
661  assume( getCoeffType(aRing) == n_R );
662 
663  if ( from != NULL )
664  {
665  gmp_complex *res=new gmp_complex((double)nrFloat(from)); // FIXME? TODO? // extern float nrFloat(number n);
666  return (number)res;
667  }
668  else
669  return NULL;
670 }
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:75
#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
#define NULL
Definition: omList.c:10

§ ngcMapZ()

number ngcMapZ ( number  from,
const coeffs  aRing,
const coeffs  r 
)

Definition at line 623 of file gnumpc.cc.

624 {
625  assume( getCoeffType(r) == n_long_C );
626  assume( aRing->rep == n_rep_gap_gmp);
627 
628  if ( from != NULL )
629  {
630  if (SR_HDL(from) & SR_INT)
631  {
632  gmp_float f_i= gmp_float(SR_TO_INT(from));
633  gmp_complex *res=new gmp_complex(f_i);
634  return (number)res;
635  }
636  gmp_float f_i=(mpz_ptr)from;
637  gmp_complex *res=new gmp_complex(f_i);
638  return (number)res;
639  }
640  else
641  return NULL;
642 }
(), see rinteger.h, new impl.
Definition: coeffs.h:112
gmp_complex numbers based on
Definition: mpr_complex.h:178
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
#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

§ ngcMult()

number ngcMult ( number  a,
number  b,
const coeffs  r 
)

Definition at line 210 of file gnumpc.cc.

211 {
212  assume( getCoeffType(R) == n_long_C );
213 
214  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) );
215  return (number)r;
216 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:403
const ring R
Definition: DebugPrint.cc:36
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
const poly b
Definition: syzextra.cc:213

§ ngcNeg()

number ngcNeg ( number  za,
const coeffs  r 
)

Definition at line 157 of file gnumpc.cc.

158 {
159  assume( getCoeffType(R) == n_long_C );
160 
162  (*r).neg();
163  return (number)a;
164 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:403
const ring R
Definition: DebugPrint.cc:36
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

§ ngcParameter()

number ngcParameter ( int  i,
const coeffs  r 
)

Definition at line 80 of file gnumpc.cc.

81 {
82  assume( getCoeffType(r) == n_long_C );
83  assume(i==1);
84 
85  if( i == 1 )
86  return (number)(new gmp_complex( 0L, 1L ));
87 
88  return NULL; // new gmp_complex( ) // 0?
89 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
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
#define NULL
Definition: omList.c:10

§ ngcPower()

void ngcPower ( number  x,
int  exp,
number *  lu,
const coeffs  r 
)

Definition at line 238 of file gnumpc.cc.

239 {
240  assume( getCoeffType(r) == n_long_C );
241 
242  if ( exp == 0 )
243  {
244  gmp_complex* n = new gmp_complex(1);
245  *u=(number)n;
246  return;
247  }
248  else if ( exp == 1 )
249  {
250  n_New(u, r);
251  gmp_complex* n = new gmp_complex();
252  *n= *(gmp_complex*)x;
253  *u=(number)n;
254  return;
255  }
256  else if (exp == 2)
257  {
258  n_New(u, r);
259  gmp_complex* n = new gmp_complex();
260  *n= *(gmp_complex*)x;
261  *u=(number)n;
262  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
263  return;
264  }
265  if ( (exp & 1) == 1 )
266  {
267  ngcPower(x,exp-1,u, r);
268  gmp_complex *n = new gmp_complex();
269  *n=*(gmp_complex*)x;
270  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
271  delete n;
272  }
273  else
274  {
275  number w;
276  n_New(&w, r);
277  ngcPower(x,exp/2,&w, r);
278  ngcPower(w,2,u, r);
279  n_Delete(&w, r);
280  }
281 }
#define n_New(n, r)
Definition: coeffs.h:444
void ngcPower(number x, int exp, number *lu, const coeffs r)
Definition: gnumpc.cc:238
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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
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:459

§ ngcRead()

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

Definition at line 368 of file gnumpc.cc.

369 {
370  assume( getCoeffType(r) == n_long_C );
371  const char * const complex_parameter = n_ParameterNames(r)[0];
372  assume( complex_parameter != NULL );
373  const int N = strlen(complex_parameter);
374 
375  if ((*s >= '0') && (*s <= '9'))
376  {
377  gmp_float *re=NULL;
378  s=ngfRead(s,(number *)&re, r); // FIXME? TODO? // extern const char * ngfRead (const char *s, number *a, const coeffs r);
379  gmp_complex *aa=new gmp_complex(*re);
380  *a=(number)aa;
381  delete re;
382  }
383  else if (strncmp(s, complex_parameter, N)==0)
384  {
385  s += N;
386  gmp_complex *aa=new gmp_complex(0L,1L);
387  *a=(number)aa;
388  }
389  else
390  {
391  *a=(number) new gmp_complex(1L);
392  }
393  return s;
394 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
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
#define assume(x)
Definition: mod2.h:403
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:338
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
#define NULL
Definition: omList.c:10

§ ngcRePart()

number ngcRePart ( number  a,
const coeffs  r 
)

Definition at line 290 of file gnumpc.cc.

291 {
292  assume( getCoeffType(r) == n_long_C );
293 
294  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->real());
295  return (number)n;
296 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#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

§ ngcSetChar()

void ngcSetChar ( const coeffs  r)

Definition at line 602 of file gnumpc.cc.

603 {
604  setGMPFloatDigits(r->float_len, r->float_len2);
605 }
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

§ ngcSetMap()

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 697 of file gnumpc.cc.

698 {
699  assume( getCoeffType(dst) == n_long_C );
700 
701  if (src->rep==n_rep_gap_rat) /* Q, Z*/
702  {
703  return ngcMapQ;
704  }
705  if (src->rep==n_rep_gap_gmp) /* Z */
706  {
707  return ngcMapZ;
708  }
709  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
710  {
711  return ngcMapLongR;
712  }
713  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
714  {
715  return ngcCopyMap;
716  }
717  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
718  {
719  return ngcMapR;
720  }
721  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
722  {
723  return ngcMapP;
724  }
725  return NULL;
726 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:834
static number ngcMapR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:658
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 ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:623
number ngcMapQ(number from, const coeffs r, const coeffs aRing)
Definition: gnumpc.cc:609
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:672
#define assume(x)
Definition: mod2.h:403
complex floating point (GMP) numbers
Definition: coeffs.h:42
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
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
#define NULL
Definition: omList.c:10
(gmp_float), see
Definition: coeffs.h:117
(int), see modulop.h
Definition: coeffs.h:110
static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:683
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:644
(float), see shortfl.h
Definition: coeffs.h:116

§ ngcSize()

int ngcSize ( number  n,
const coeffs  R 
)

Definition at line 113 of file gnumpc.cc.

114 {
115  int r = (int)((gmp_complex*)n)->real();
116  if (r < 0) r = -r;
117  int i = (int)((gmp_complex*)n)->imag();
118  if (i < 0) i = -i;
119  int oneNorm = r + i;
120  /* basically return the 1-norm of n;
121  only if this happens to be zero although n != 0,
122  return 1;
123  (this code ensures that zero has the size zero) */
124  if ((oneNorm == 0.0) & (ngcIsZero(n,R) == FALSE)) oneNorm = 1;
125  return oneNorm;
126 }
#define FALSE
Definition: auxiliary.h:97
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:283
static CanonicalForm oneNorm(const CanonicalForm &F)

§ ngcSub()

number ngcSub ( number  la,
number  li,
const coeffs  r 
)

Definition at line 199 of file gnumpc.cc.

200 {
201  assume( getCoeffType(R) == n_long_C );
202 
203  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) - (*(gmp_complex*)b) );
204  return (number)r;
205 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:403
const ring R
Definition: DebugPrint.cc:36
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
const poly b
Definition: syzextra.cc:213

§ ngcWrite()

void ngcWrite ( number  a,
const coeffs  r 
)

Definition at line 401 of file gnumpc.cc.

402 {
403  assume( getCoeffType(r) == n_long_C );
404 
405  if (a==NULL)
406  StringAppendS("0");
407  else
408  {
409  char *out;
410  out= complexToStr(*(gmp_complex*)a, r->float_len, r);
411  StringAppendS(out);
412  // omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
413  omFree( (void *)out );
414  }
415 }
const poly a
Definition: syzextra.cc:212
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:403
void StringAppendS(const char *st)
Definition: reporter.cc:107
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
#define NULL
Definition: omList.c:10
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:717