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

BOOLEAN ngcDBTest (number a, const char *f, const int l, const coeffs r)
 
static number ngcParameter (int i, const coeffs r)
 
static number ngcInit (long i, const coeffs r)
 
static long ngcInt (number &i, const coeffs r)
 
static BOOLEAN ngcIsZero (number a, const coeffs r)
 
static int ngcSize (number n, const coeffs R)
 
static void ngcDelete (number *a, const coeffs r)
 
static number ngcCopy (number a, const coeffs r)
 
static number ngcNeg (number a, const coeffs R)
 
static number ngcInvers (number a, const coeffs R)
 
static number ngcAdd (number a, number b, const coeffs R)
 
static number ngcSub (number a, number b, const coeffs R)
 
static number ngcMult (number a, number b, const coeffs R)
 
static number ngcDiv (number a, number b, const coeffs r)
 
static void ngcPower (number x, int exp, number *u, const coeffs r)
 
static number ngcRePart (number a, const coeffs r)
 
static number ngcImPart (number a, const coeffs r)
 
static BOOLEAN ngcGreaterZero (number a, const coeffs r)
 
static BOOLEAN ngcGreater (number a, number b, const coeffs r)
 
static BOOLEAN ngcEqual (number a, number b, const coeffs r)
 
static BOOLEAN ngcIsOne (number a, const coeffs r)
 
static BOOLEAN ngcIsMOne (number a, const coeffs r)
 
static const char * ngcRead (const char *s, number *a, const coeffs r)
 
static void ngcWrite (number a, const coeffs r)
 
static BOOLEAN ngcCoeffIsEqual (const coeffs r, n_coeffType n, void *parameter)
 
static void ngcKillChar (coeffs r)
 
static char * ngcCoeffString (const coeffs r)
 
static void ngcCoeffWrite (const coeffs r, BOOLEAN)
 
static number ngcMapQ (number from, const coeffs aRing, const coeffs r)
 
static 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)
 
static nMapFunc ngcSetMap (const coeffs src, const coeffs dst)
 
BOOLEAN ngcInitChar (coeffs n, void *parameter)
 Initialize r (n_long_C) More...
 
void ngcSetChar (const coeffs r)
 

Function Documentation

◆ ngcAdd()

static number ngcAdd ( number  a,
number  b,
const coeffs  R 
)
static

Definition at line 156 of file gnumpc.cc.

157 {
158  assume( getCoeffType(R) == n_long_C );
159 
160  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) );
161  return (number)r;
162 }
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:394
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()

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

Definition at line 378 of file gnumpc.cc.

379 {
380  if (n==n_long_C)
381  {
382  LongComplexInfo* p = (LongComplexInfo *)(parameter);
383 
384  if ((p==NULL)
385  && (6==r->float_len)
386  && (6==r->float_len2)
387  && (strcmp("i",n_ParameterNames(r)[0]) == 0)
388  )
389  return TRUE;
390  if ((p!=NULL) &&
391  (p->float_len == r->float_len) &&
392  (p->float_len2 == r->float_len2)
393  )
394  if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
395  return (TRUE);
396  }
397  return (FALSE);
398 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:812
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
#define TRUE
Definition: auxiliary.h:98
const ring r
Definition: syzextra.cc:208
complex floating point (GMP) numbers
Definition: coeffs.h:42
#define NULL
Definition: omList.c:10

◆ ngcCoeffString()

static char* ngcCoeffString ( const coeffs  r)
static

Definition at line 413 of file gnumpc.cc.

414 {
415  const char *p=n_ParameterNames(r)[0];
416  char *s=(char*)omAlloc(31+strlen(p));
417  sprintf(s,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
418  return s;
419 }
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
const ring r
Definition: syzextra.cc:208

◆ ngcCoeffWrite()

static void ngcCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 421 of file gnumpc.cc.

422 {
423  Print("float[%s](complex:%d digits, additional %d digits)/(%s^2+1)",n_ParameterNames(r)[0],
424  r->float_len, r->float_len2, n_ParameterNames(r)[0]); /* long C */
425 }
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
const ring r
Definition: syzextra.cc:208

◆ ngcCopy()

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

Definition at line 113 of file gnumpc.cc.

114 {
115  assume( getCoeffType(r) == n_long_C );
116 
117  gmp_complex* b= new gmp_complex( *(gmp_complex*)a );
118  return (number)b;
119 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

◆ ngcCopyMap()

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

Definition at line 501 of file gnumpc.cc.

502 {
503  assume( getCoeffType(r) == n_long_C );
504  assume( getCoeffType(aRing) == n_long_C );
505 
506  gmp_complex* b = NULL;
507 
508  if ( from != NULL )
509  {
510  b = new gmp_complex( *(gmp_complex*)from );
511  }
512  return (number)b;
513 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#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 33 of file gnumpc.cc.

34 {
36 
37  return TRUE;
38 }
#define TRUE
Definition: auxiliary.h:98
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

◆ ngcDelete()

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

Definition at line 99 of file gnumpc.cc.

100 {
101  assume( getCoeffType(r) == n_long_C );
102 
103  if ( *a != NULL )
104  {
105  delete *(gmp_complex**)a;
106  *a=NULL;
107  }
108 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10

◆ ngcDiv()

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

Definition at line 189 of file gnumpc.cc.

190 {
191  assume( getCoeffType(r) == n_long_C );
192 
193  if (((gmp_complex*)b)->isZero())
194  {
195  // a/0 = error
196  WerrorS(nDivBy0);
197  return NULL;
198  }
199  gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) );
200  return (number)res;
201 }
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
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
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()

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

Definition at line 295 of file gnumpc.cc.

296 {
297  assume( getCoeffType(r) == n_long_C );
298 
299  gmp_complex *aa=(gmp_complex*)a;
300  gmp_complex *bb=(gmp_complex*)b;
301  return (*aa) == (*bb);
302 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

◆ ngcGreater()

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

Definition at line 283 of file gnumpc.cc.

284 {
285  assume( getCoeffType(r) == n_long_C );
286 
287  gmp_complex *aa=(gmp_complex*)a;
288  gmp_complex *bb=(gmp_complex*)b;
289  return (*aa) > (*bb);
290 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
const poly b
Definition: syzextra.cc:213

◆ ngcGreaterZero()

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

Definition at line 270 of file gnumpc.cc.

271 {
272  assume( getCoeffType(r) == n_long_C );
273 
274  if ( ! ((gmp_complex*)a)->imag().isZero() )
275  return ( abs( *(gmp_complex*)a).sign() >= 0 );
276  else
277  return ( ((gmp_complex*)a)->real().sign() >= 0 );
278 }
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
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
bool isZero(const CFArray &A)
checks if entries of A are zero
static int sign(int x)
Definition: ring.cc:3342

◆ ngcImPart()

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

Definition at line 259 of file gnumpc.cc.

260 {
261  assume( getCoeffType(r) == n_long_C );
262 
263  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->imag());
264  return (number)n;
265 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

◆ ngcInit()

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

Definition at line 55 of file gnumpc.cc.

56 {
58 
59  gmp_complex* n= new gmp_complex( (long)i, 0L );
60 
61  return (number)n;
62 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
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 546 of file gnumpc.cc.

547 {
548  assume( getCoeffType(n) == n_long_C );
549  n->is_field=TRUE;
550  n->is_domain=TRUE;
551  n->rep=n_rep_gmp_complex;
552 
553  n->cfKillChar = ngcKillChar;
554  n->ch = 0;
555  n->cfCoeffString=ngcCoeffString;
556 
557  n->cfDelete = ngcDelete;
558  //n->cfNormalize=ndNormalize;
559  n->cfInit = ngcInit;
560  n->cfInt = ngcInt;
561  n->cfAdd = ngcAdd;
562  n->cfSub = ngcSub;
563  n->cfMult = ngcMult;
564  n->cfDiv = ngcDiv;
565  n->cfExactDiv= ngcDiv;
566  n->cfInpNeg = ngcNeg;
567  n->cfInvers = ngcInvers;
568  n->cfCopy = ngcCopy;
569  n->cfGreater = ngcGreater;
570  n->cfEqual = ngcEqual;
571  n->cfIsZero = ngcIsZero;
572  n->cfIsOne = ngcIsOne;
573  n->cfIsMOne = ngcIsMOne;
574  n->cfGreaterZero = ngcGreaterZero;
575 
576  n->cfWriteLong = ngcWrite;
577  n->cfWriteShort = ngcWrite;
578 
579  n->cfRead = ngcRead;
580  n->cfPower = ngcPower;
581  n->cfSetMap = ngcSetMap;
582  n->cfRePart = ngcRePart;
583  n->cfImPart = ngcImPart;
584  n->cfCoeffWrite = ngcCoeffWrite;
585  // cfSize = ndSize;
586 #ifdef LDEBUG
587  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
588 #endif
589 
590  n->nCoeffIsEqual = ngcCoeffIsEqual;
591 
592  n->cfSetChar=ngcSetChar;
593 
594 // we need to initialize n->nNULL at least for minpoly printing
595  n->nNULL = n->cfInit(0,n);
596 
597 /*
598  //r->cfInitChar=nlInitChar;
599  r->cfKillChar=NULL;
600 
601  r->cfMult = nlMult;
602  r->cfSub = nlSub;
603  r->cfAdd = nlAdd;
604  r->cfDiv = nlDiv;
605  r->cfIntMod= nlIntMod;
606  r->cfExactDiv= nlExactDiv;
607  r->cfInit = nlInit;
608  r->cfSize = nlSize;
609  r->cfInt = nlInt;
610 #ifdef HAVE_RINGS
611  r->cfDivComp = NULL; // only for ring stuff
612  r->cfIsUnit = NULL; // only for ring stuff
613  r->cfGetUnit = NULL; // only for ring stuff
614  r->cfExtGcd = NULL; // only for ring stuff
615 #endif
616  r->cfInpNeg = nlNeg;
617  r->cfInvers= nlInvers;
618  r->cfCopy = nl_Copy;
619  r->cfRePart = nl_Copy;
620  r->cfImPart = ndReturn0;
621  r->cfWriteLong = nlWrite;
622  r->cfRead = nlRead;
623  r->cfNormalize=nlNormalize;
624  r->cfGreater = nlGreater;
625 #ifdef HAVE_RINGS
626  r->cfDivBy = NULL; // only for ring stuff
627 #endif
628  r->cfEqual = nlEqual;
629  r->cfIsZero = nlIsZero;
630  r->cfIsOne = nlIsOne;
631  r->cfIsMOne = nlIsMOne;
632  r->cfGreaterZero = nlGreaterZero;
633  r->cfPower = nlPower;
634  r->cfGetDenom = nlGetDenom;
635  r->cfGetNumerator = nlGetNumerator;
636  r->cfGcd = nlGcd;
637  r->cfLcm = nlLcm;
638  r->cfDelete= nlDelete;
639  r->cfSetMap = nlSetMap;
640  r->cfName = ndName;
641  r->cfInpMult=nlInpMult;
642  r->cfInit_bigint=nlCopyMap;
643 #ifdef LDEBUG
644  // debug stuff
645  r->cfDBTest=nlDBTest;
646 #endif
647 
648  // the variables:
649  r->nNULL = INT_TO_SR(0);
650  r->type = n_Q;
651  r->ch = 0;
652  r->has_simple_Alloc=FALSE;
653  r->has_simple_Inverse=FALSE;
654 */
655 
656  n->iNumberOfParameters = 1;
657  n->cfParameter = ngcParameter;
658 
659  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
660 
661  if( parameter != NULL)
662  {
663  LongComplexInfo* p = (LongComplexInfo*)parameter;
664  pParameterNames[0] = omStrDup(p->par_name);
665  // fix wrong parameters:
666  if (p->float_len<SHORT_REAL_LENGTH) p->float_len=SHORT_REAL_LENGTH;
667  n->float_len = p->float_len;
668  n->float_len2 = p->float_len2;
669 
670  } else // default values, just for testing!
671  {
672  pParameterNames[0] = omStrDup("i");
673  n->float_len = SHORT_REAL_LENGTH;
674  n->float_len2 = SHORT_REAL_LENGTH;
675  }
676 
677  assume( pParameterNames != NULL );
678  assume( pParameterNames[0] != NULL );
679 
680  n->pParameterNames = (const char**)pParameterNames;
681 
682  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
683  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
684 
685  return FALSE;
686 }
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:400
static void ngcCoeffWrite(const coeffs r, BOOLEAN)
Definition: gnumpc.cc:421
static number ngcInvers(number a, const coeffs R)
Definition: gnumpc.cc:137
#define SHORT_REAL_LENGTH
Definition: numbers.h:54
static BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:283
#define FALSE
Definition: auxiliary.h:94
return P p
Definition: myNF.cc:203
static number ngcNeg(number a, const coeffs R)
Definition: gnumpc.cc:125
static long ngcInt(number &i, const coeffs r)
Definition: gnumpc.cc:67
static number ngcSub(number a, number b, const coeffs R)
Definition: gnumpc.cc:167
#define TRUE
Definition: auxiliary.h:98
static BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:378
static void ngcPower(number x, int exp, number *u, const coeffs r)
Definition: gnumpc.cc:206
static number ngcMult(number a, number b, const coeffs R)
Definition: gnumpc.cc:178
static number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:189
static BOOLEAN ngcIsZero(number a, const coeffs r)
Definition: gnumpc.cc:74
static char * ngcCoeffString(const coeffs r)
Definition: gnumpc.cc:413
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:688
#define assume(x)
Definition: mod2.h:394
static BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:295
complex floating point (GMP) numbers
Definition: coeffs.h:42
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static number ngcParameter(int i, const coeffs r)
Definition: gnumpc.cc:41
static number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:251
static number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:55
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
static nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
Definition: gnumpc.cc:515
static BOOLEAN ngcGreaterZero(number a, const coeffs r)
Definition: gnumpc.cc:270
#define NULL
Definition: omList.c:10
static BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:307
static number ngcAdd(number a, number b, const coeffs R)
Definition: gnumpc.cc:156
static number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:259
static const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:329
static void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:99
static number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:113
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:362
#define omStrDup(s)
Definition: omAllocDecl.h:263
static BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:318

◆ ngcInt()

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

Definition at line 67 of file gnumpc.cc.

68 {
70 
71  return ((gmp_complex*)i)->real();
72 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
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()

static number ngcInvers ( number  a,
const coeffs  R 
)
static

Definition at line 137 of file gnumpc.cc.

138 {
139  assume( getCoeffType(R) == n_long_C );
140 
141  gmp_complex* r = NULL;
142  if (((gmp_complex*)a)->isZero())
143  {
144  WerrorS(nDivBy0);
145  }
146  else
147  {
148  r = new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) );
149  }
150  return (number)r;
151 }
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:394
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()

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

Definition at line 318 of file gnumpc.cc.

319 {
320  assume( getCoeffType(r) == n_long_C );
321 
322  return (((gmp_complex*)a)->real().isMOne() && ((gmp_complex*)a)->imag().isZero());
323  //return (((gmp_complex*)a)->real().isMOne());
324 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
bool isZero(const CFArray &A)
checks if entries of A are zero

◆ ngcIsOne()

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

Definition at line 307 of file gnumpc.cc.

308 {
309  assume( getCoeffType(r) == n_long_C );
310 
311  return (((gmp_complex*)a)->real().isOne() && ((gmp_complex*)a)->imag().isZero());
312  //return (((gmp_complex*)a)->real().isOne());
313 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
bool isZero(const CFArray &A)
checks if entries of A are zero

◆ ngcIsZero()

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

Definition at line 74 of file gnumpc.cc.

75 {
77 
78  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
79 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
bool isZero(const CFArray &A)
checks if entries of A are zero

◆ ngcKillChar()

static void ngcKillChar ( coeffs  r)
static

Definition at line 400 of file gnumpc.cc.

401 {
402  char** p = (char**)n_ParameterNames(r);
403 
404  const int P = n_NumberOfParameters(r);
405 
406  for( int i = 1; i <= P; i++ )
407  if (p[i-1] != NULL)
408  omFree( (ADDRESS)p[i-1] );
409 
410  omFreeSize((ADDRESS)p, P * sizeof(char*));
411 }
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:115
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:808
const ring r
Definition: syzextra.cc:208
#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 462 of file gnumpc.cc.

463 {
464  assume( getCoeffType(r) == n_long_C );
465  assume( getCoeffType(aRing) == n_long_R );
466 
467  if ( from != NULL )
468  {
469  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
470  return (number)res;
471  }
472  else
473  return NULL;
474 }
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
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10

◆ ngcMapP()

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

Definition at line 490 of file gnumpc.cc.

491 {
492  assume( getCoeffType(r) == n_long_C );
493  assume( getCoeffType(aRing) == n_Zp );
494 
495  if ( from != NULL )
496  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
497  else
498  return NULL;
499 }
long npInt(number &n, const coeffs r)
Definition: modulop.cc:117
{p < 2^31}
Definition: coeffs.h:30
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:55
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()

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

Definition at line 427 of file gnumpc.cc.

428 {
429  assume( getCoeffType(r) == n_long_C );
430  assume( aRing->rep == n_rep_gap_rat);
431 
432  if ( from != NULL )
433  {
435  return (number)res;
436  }
437  else
438  return NULL;
439 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
#define QTOF
Definition: mpr_complex.h:19
gmp_float numberFieldToFloat(number num, int cf)
Definition: mpr_complex.cc:440
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:10

◆ ngcMapR()

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

Definition at line 476 of file gnumpc.cc.

477 {
478  assume( getCoeffType(r) == n_long_C );
479  assume( getCoeffType(aRing) == n_R );
480 
481  if ( from != NULL )
482  {
483  gmp_complex *res=new gmp_complex((double)nrFloat(from)); // FIXME? TODO? // extern float nrFloat(number n);
484  return (number)res;
485  }
486  else
487  return NULL;
488 }
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
const ring r
Definition: syzextra.cc:208
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#define NULL
Definition: omList.c:10

◆ ngcMapZ()

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

Definition at line 441 of file gnumpc.cc.

442 {
443  assume( getCoeffType(r) == n_long_C );
444  assume( aRing->rep == n_rep_gap_gmp);
445 
446  if ( from != NULL )
447  {
448  if (SR_HDL(from) & SR_INT)
449  {
450  gmp_float f_i= gmp_float(SR_TO_INT(from));
451  gmp_complex *res=new gmp_complex(f_i);
452  return (number)res;
453  }
454  gmp_float f_i=(mpz_ptr)from;
455  gmp_complex *res=new gmp_complex(f_i);
456  return (number)res;
457  }
458  else
459  return NULL;
460 }
(), 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
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
#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()

static number ngcMult ( number  a,
number  b,
const coeffs  R 
)
static

Definition at line 178 of file gnumpc.cc.

179 {
180  assume( getCoeffType(R) == n_long_C );
181 
182  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) );
183  return (number)r;
184 }
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:394
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()

static number ngcNeg ( number  a,
const coeffs  R 
)
static

Definition at line 125 of file gnumpc.cc.

126 {
127  assume( getCoeffType(R) == n_long_C );
128 
130  (*r).neg();
131  return (number)a;
132 }
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:394
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()

static number ngcParameter ( int  i,
const coeffs  r 
)
static

Definition at line 41 of file gnumpc.cc.

42 {
44  assume(i==1);
45 
46  if( i == 1 )
47  return (number)(new gmp_complex( 0L, 1L ));
48 
49  return NULL; // new gmp_complex( ) // 0?
50 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
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()

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

Definition at line 206 of file gnumpc.cc.

207 {
208  assume( getCoeffType(r) == n_long_C );
209 
210  if ( exp == 0 )
211  {
212  gmp_complex* n = new gmp_complex(1);
213  *u=(number)n;
214  return;
215  }
216  else if ( exp == 1 )
217  {
218  n_New(u, r);
219  gmp_complex* n = new gmp_complex();
220  *n= *(gmp_complex*)x;
221  *u=(number)n;
222  return;
223  }
224  else if (exp == 2)
225  {
226  n_New(u, r);
227  gmp_complex* n = new gmp_complex();
228  *n= *(gmp_complex*)x;
229  *u=(number)n;
230  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
231  return;
232  }
233  if ( (exp & 1) == 1 )
234  {
235  ngcPower(x,exp-1,u, r);
236  gmp_complex *n = new gmp_complex();
237  *n=*(gmp_complex*)x;
238  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
239  delete n;
240  }
241  else
242  {
243  number w;
244  n_New(&w, r);
245  ngcPower(x,exp/2,&w, r);
246  ngcPower(w,2,u, r);
247  n_Delete(&w, r);
248  }
249 }
#define n_New(n, r)
Definition: coeffs.h:444
static void ngcPower(number x, int exp, number *u, const coeffs r)
Definition: gnumpc.cc:206
gmp_complex numbers based on
Definition: mpr_complex.h:178
const ring r
Definition: syzextra.cc:208
#define assume(x)
Definition: mod2.h:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425
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()

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

Definition at line 329 of file gnumpc.cc.

330 {
331  assume( getCoeffType(r) == n_long_C );
332  const char * const complex_parameter = n_ParameterNames(r)[0];
333  assume( complex_parameter != NULL );
334  const int N = strlen(complex_parameter);
335 
336  if ((*s >= '0') && (*s <= '9'))
337  {
338  gmp_float *re=NULL;
339  s=ngfRead(s,(number *)&re, r); // FIXME? TODO? // extern const char * ngfRead (const char *s, number *a, const coeffs r);
340  gmp_complex *aa=new gmp_complex(*re);
341  *a=(number)aa;
342  delete re;
343  }
344  else if (strncmp(s, complex_parameter, N)==0)
345  {
346  s += N;
347  gmp_complex *aa=new gmp_complex(0L,1L);
348  *a=(number)aa;
349  }
350  else
351  {
352  *a=(number) new gmp_complex(1L);
353  }
354  return s;
355 }
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 ring r
Definition: syzextra.cc:208
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
#define assume(x)
Definition: mod2.h:394
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:308
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()

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

Definition at line 251 of file gnumpc.cc.

252 {
253  assume( getCoeffType(r) == n_long_C );
254 
255  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->real());
256  return (number)n;
257 }
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:394
complex floating point (GMP) numbers
Definition: coeffs.h:42
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:425

◆ ngcSetChar()

void ngcSetChar ( const coeffs  r)

Definition at line 688 of file gnumpc.cc.

689 {
690  setGMPFloatDigits(r->float_len, r->float_len2);
691 }
const ring r
Definition: syzextra.cc:208
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()

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

Definition at line 515 of file gnumpc.cc.

516 {
517  assume( getCoeffType(dst) == n_long_C );
518 
519  if (src->rep==n_rep_gap_rat) /* Q, Z*/
520  {
521  return ngcMapQ;
522  }
523  if (src->rep==n_rep_gap_gmp) /* Z */
524  {
525  return ngcMapZ;
526  }
527  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
528  {
529  return ngcMapLongR;
530  }
531  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
532  {
533  return ngcCopyMap;
534  }
535  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
536  {
537  return ngcMapR;
538  }
539  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
540  {
541  return ngcMapP;
542  }
543  return NULL;
544 }
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:476
static number ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:441
static number ngcMapQ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:427
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:908
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:853
(), see rinteger.h, new impl.
Definition: coeffs.h:112
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:911
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:490
#define assume(x)
Definition: mod2.h:394
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:501
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:462
(float), see shortfl.h
Definition: coeffs.h:116

◆ ngcSize()

static int ngcSize ( number  n,
const coeffs  R 
)
static

Definition at line 81 of file gnumpc.cc.

82 {
83  int r = (int)((gmp_complex*)n)->real();
84  if (r < 0) r = -r;
85  int i = (int)((gmp_complex*)n)->imag();
86  if (i < 0) i = -i;
87  int oneNorm = r + i;
88  /* basically return the 1-norm of n;
89  only if this happens to be zero although n != 0,
90  return 1;
91  (this code ensures that zero has the size zero) */
92  if ((oneNorm == 0.0) & (ngcIsZero(n,R) == FALSE)) oneNorm = 1;
93  return oneNorm;
94 }
#define FALSE
Definition: auxiliary.h:94
gmp_complex numbers based on
Definition: mpr_complex.h:178
static BOOLEAN ngcIsZero(number a, const coeffs r)
Definition: gnumpc.cc:74
const ring r
Definition: syzextra.cc:208
const ring R
Definition: DebugPrint.cc:36
int i
Definition: cfEzgcd.cc:123
static CanonicalForm oneNorm(const CanonicalForm &F)

◆ ngcSub()

static number ngcSub ( number  a,
number  b,
const coeffs  R 
)
static

Definition at line 167 of file gnumpc.cc.

168 {
169  assume( getCoeffType(R) == n_long_C );
170 
171  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) - (*(gmp_complex*)b) );
172  return (number)r;
173 }
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:394
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()

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

Definition at line 362 of file gnumpc.cc.

363 {
364  assume( getCoeffType(r) == n_long_C );
365 
366  if (a==NULL)
367  StringAppendS("0");
368  else
369  {
370  char *out;
371  out= complexToStr(*(gmp_complex*)a, r->float_len, r);
372  StringAppendS(out);
373  // omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
374  omFree( (void *)out );
375  }
376 }
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 omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:394
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:706