Functions
gnumpc.cc File Reference
#include "misc/auxiliary.h"
#include "misc/mylimits.h"
#include "reporter/reporter.h"
#include "coeffs/coeffs.h"
#include "coeffs/numbers.h"
#include "coeffs/mpr_complex.h"
#include "coeffs/gnumpc.h"
#include "coeffs/longrat.h"
#include "coeffs/gnumpfl.h"
#include "coeffs/modulop.h"
#include "coeffs/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 char * ngcCoeffName (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 155 of file gnumpc.cc.

156 {
157  assume( getCoeffType(R) == n_long_C );
158 
159  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) );
160  return (number)r;
161 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcCoeffIsEqual()

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

Definition at line 377 of file gnumpc.cc.

378 {
379  if (n==n_long_C)
380  {
381  LongComplexInfo* p = (LongComplexInfo *)(parameter);
382 
383  if ((p==NULL)
384  && (SHORT_REAL_LENGTH==r->float_len)
385  && (SHORT_REAL_LENGTH==r->float_len2)
386  && (strcmp("i",n_ParameterNames(r)[0]) == 0)
387  )
388  return TRUE;
389  if ((p!=NULL) &&
390  (p->float_len == r->float_len) &&
391  (p->float_len2 == r->float_len2)
392  )
393  if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
394  return (TRUE);
395  }
396  return (FALSE);
397 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
#define SHORT_REAL_LENGTH
Definition: numbers.h:57
#define FALSE
Definition: auxiliary.h:96
#define TRUE
Definition: auxiliary.h:100
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:12
const char * par_name
parameter name
Definition: coeffs.h:103
int p
Definition: cfModGcd.cc:4019

◆ ngcCoeffName()

static char* ngcCoeffName ( const coeffs  r)
static

Definition at line 420 of file gnumpc.cc.

421 {
422  STATIC_VAR char ngcCoeffName_buf[40];
423  const char *p=n_ParameterNames(r)[0];
424  sprintf(ngcCoeffName_buf,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
425  return ngcCoeffName_buf;
426 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
#define STATIC_VAR
Definition: globaldefs.h:7
int p
Definition: cfModGcd.cc:4019

◆ ngcCoeffString()

static char* ngcCoeffString ( const coeffs  r)
static

Definition at line 412 of file gnumpc.cc.

413 {
414  const char *p=n_ParameterNames(r)[0];
415  char *s=(char*)omAlloc(31+strlen(p));
416  sprintf(s,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
417  return s;
418 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
const CanonicalForm int s
Definition: facAbsFact.cc:55
#define omAlloc(size)
Definition: omAllocDecl.h:210
int p
Definition: cfModGcd.cc:4019

◆ ngcCoeffWrite()

static void ngcCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 428 of file gnumpc.cc.

429 {
430  Print("real[%s](complex:%d digits, additional %d digits)/(%s^2+1)",n_ParameterNames(r)[0],
431  r->float_len, r->float_len2, n_ParameterNames(r)[0]); /* long C */
432 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
#define Print
Definition: emacs.cc:80

◆ ngcCopy()

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

Definition at line 112 of file gnumpc.cc.

113 {
114  assume( getCoeffType(r) == n_long_C );
115 
116  gmp_complex* b= new gmp_complex( *(gmp_complex*)a );
117  return (number)b;
118 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcCopyMap()

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

Definition at line 508 of file gnumpc.cc.

509 {
510  assume( getCoeffType(r) == n_long_C );
511  assume( getCoeffType(aRing) == n_long_C );
512 
513  gmp_complex* b = NULL;
514 
515  if ( from != NULL )
516  {
517  b = new gmp_complex( *(gmp_complex*)from );
518  }
519  return (number)b;
520 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421
#define NULL
Definition: omList.c:12

◆ ngcDBTest()

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

Definition at line 32 of file gnumpc.cc.

33 {
34  assume( getCoeffType(r) == n_long_C );
35 
36  return TRUE;
37 }
#define TRUE
Definition: auxiliary.h:100
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcDelete()

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

Definition at line 98 of file gnumpc.cc.

99 {
100  assume( getCoeffType(r) == n_long_C );
101 
102  if ( *a != NULL )
103  {
104  delete *(gmp_complex**)a;
105  *a=NULL;
106  }
107 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421
#define NULL
Definition: omList.c:12

◆ ngcDiv()

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

Definition at line 188 of file gnumpc.cc.

189 {
190  assume( getCoeffType(r) == n_long_C );
191 
192  if (((gmp_complex*)b)->isZero())
193  {
194  // a/0 = error
195  WerrorS(nDivBy0);
196  return NULL;
197  }
198  gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) );
199  return (number)res;
200 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
complex floating point (GMP) numbers
Definition: coeffs.h:42
const char *const nDivBy0
Definition: numbers.h:88
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define NULL
Definition: omList.c:12
bool isZero(const CFArray &A)
checks if entries of A are zero

◆ ngcEqual()

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

Definition at line 294 of file gnumpc.cc.

295 {
296  assume( getCoeffType(r) == n_long_C );
297 
298  gmp_complex *aa=(gmp_complex*)a;
299  gmp_complex *bb=(gmp_complex*)b;
300  return (*aa) == (*bb);
301 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcGreater()

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

Definition at line 282 of file gnumpc.cc.

283 {
284  assume( getCoeffType(r) == n_long_C );
285 
286  gmp_complex *aa=(gmp_complex*)a;
287  gmp_complex *bb=(gmp_complex*)b;
288  return (*aa) > (*bb);
289 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcGreaterZero()

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

Definition at line 269 of file gnumpc.cc.

270 {
271  assume( getCoeffType(r) == n_long_C );
272 
273  if ( ! ((gmp_complex*)a)->imag().isZero() )
274  return ( abs( *(gmp_complex*)a).sign() >= 0 );
275  else
276  return ( ((gmp_complex*)a)->real().sign() >= 0 );
277 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
Rational abs(const Rational &a)
Definition: GMPrat.cc:436
#define assume(x)
Definition: mod2.h:390
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:421
bool isZero(const CFArray &A)
checks if entries of A are zero
static int sign(int x)
Definition: ring.cc:3375

◆ ngcImPart()

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

Definition at line 258 of file gnumpc.cc.

259 {
260  assume( getCoeffType(r) == n_long_C );
261 
262  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->imag());
263  return (number)n;
264 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcInit()

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

Definition at line 54 of file gnumpc.cc.

55 {
56  assume( getCoeffType(r) == n_long_C );
57 
58  gmp_complex* n= new gmp_complex( (long)i, 0L );
59 
60  return (number)n;
61 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
complex floating point (GMP) numbers
Definition: coeffs.h:42
int i
Definition: cfEzgcd.cc:125
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421

◆ ngcInitChar()

BOOLEAN ngcInitChar ( coeffs  n,
void *  parameter 
)

Initialize r (n_long_C)

Definition at line 553 of file gnumpc.cc.

554 {
555  assume( getCoeffType(n) == n_long_C );
556  n->is_field=TRUE;
557  n->is_domain=TRUE;
558  n->rep=n_rep_gmp_complex;
559 
560  n->cfKillChar = ngcKillChar;
561  n->ch = 0;
562  n->cfCoeffString=ngcCoeffString;
563  n->cfCoeffName=ngcCoeffName;
564 
565  n->cfDelete = ngcDelete;
566  //n->cfNormalize=ndNormalize;
567  n->cfInit = ngcInit;
568  n->cfInt = ngcInt;
569  n->cfAdd = ngcAdd;
570  n->cfSub = ngcSub;
571  n->cfMult = ngcMult;
572  n->cfDiv = ngcDiv;
573  n->cfExactDiv= ngcDiv;
574  n->cfInpNeg = ngcNeg;
575  n->cfInvers = ngcInvers;
576  n->cfCopy = ngcCopy;
577  n->cfGreater = ngcGreater;
578  n->cfEqual = ngcEqual;
579  n->cfIsZero = ngcIsZero;
580  n->cfIsOne = ngcIsOne;
581  n->cfIsMOne = ngcIsMOne;
582  n->cfGreaterZero = ngcGreaterZero;
583 
584  n->cfWriteLong = ngcWrite;
585  n->cfWriteShort = ngcWrite;
586 
587  n->cfRead = ngcRead;
588  n->cfPower = ngcPower;
589  n->cfSetMap = ngcSetMap;
590  n->cfRePart = ngcRePart;
591  n->cfImPart = ngcImPart;
592  n->cfCoeffWrite = ngcCoeffWrite;
593  // cfSize = ndSize;
594 #ifdef LDEBUG
595  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
596 #endif
597 
598  n->nCoeffIsEqual = ngcCoeffIsEqual;
599 
600  n->cfSetChar=ngcSetChar;
601 
602 /*
603  //r->cfInitChar=nlInitChar;
604  r->cfKillChar=NULL;
605 
606  r->cfMult = nlMult;
607  r->cfSub = nlSub;
608  r->cfAdd = nlAdd;
609  r->cfDiv = nlDiv;
610  r->cfIntMod= nlIntMod;
611  r->cfExactDiv= nlExactDiv;
612  r->cfInit = nlInit;
613  r->cfSize = nlSize;
614  r->cfInt = nlInt;
615 #ifdef HAVE_RINGS
616  r->cfDivComp = NULL; // only for ring stuff
617  r->cfIsUnit = NULL; // only for ring stuff
618  r->cfGetUnit = NULL; // only for ring stuff
619  r->cfExtGcd = NULL; // only for ring stuff
620 #endif
621  r->cfInpNeg = nlNeg;
622  r->cfInvers= nlInvers;
623  r->cfCopy = nl_Copy;
624  r->cfRePart = nl_Copy;
625  r->cfImPart = ndReturn0;
626  r->cfWriteLong = nlWrite;
627  r->cfRead = nlRead;
628  r->cfNormalize=nlNormalize;
629  r->cfGreater = nlGreater;
630 #ifdef HAVE_RINGS
631  r->cfDivBy = NULL; // only for ring stuff
632 #endif
633  r->cfEqual = nlEqual;
634  r->cfIsZero = nlIsZero;
635  r->cfIsOne = nlIsOne;
636  r->cfIsMOne = nlIsMOne;
637  r->cfGreaterZero = nlGreaterZero;
638  r->cfPower = nlPower;
639  r->cfGetDenom = nlGetDenom;
640  r->cfGetNumerator = nlGetNumerator;
641  r->cfGcd = nlGcd;
642  r->cfLcm = nlLcm;
643  r->cfDelete= nlDelete;
644  r->cfSetMap = nlSetMap;
645  r->cfName = ndName;
646  r->cfInpMult=nlInpMult;
647  r->cfInit_bigint=nlCopyMap;
648 #ifdef LDEBUG
649  // debug stuff
650  r->cfDBTest=nlDBTest;
651 #endif
652 
653  // the variables:
654  r->type = n_Q;
655  r->ch = 0;
656  r->has_simple_Alloc=FALSE;
657  r->has_simple_Inverse=FALSE;
658 */
659 
660  n->iNumberOfParameters = 1;
661  n->cfParameter = ngcParameter;
662 
663  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
664 
665  if( parameter != NULL)
666  {
667  LongComplexInfo* p = (LongComplexInfo*)parameter;
668  pParameterNames[0] = omStrDup(p->par_name);
669  // fix wrong parameters:
671  n->float_len = p->float_len;
672  n->float_len2 = p->float_len2;
673 
674  } else // default values, just for testing!
675  {
676  pParameterNames[0] = omStrDup("i");
677  n->float_len = SHORT_REAL_LENGTH;
678  n->float_len2 = SHORT_REAL_LENGTH;
679  }
680 
681  assume( pParameterNames != NULL );
682  assume( pParameterNames[0] != NULL );
683 
684  n->pParameterNames = (const char**)pParameterNames;
685 
686  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
687  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
688 
689  return FALSE;
690 }
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:399
static void ngcCoeffWrite(const coeffs r, BOOLEAN)
Definition: gnumpc.cc:428
static number ngcInvers(number a, const coeffs R)
Definition: gnumpc.cc:136
#define SHORT_REAL_LENGTH
Definition: numbers.h:57
static BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:282
#define FALSE
Definition: auxiliary.h:96
static number ngcNeg(number a, const coeffs R)
Definition: gnumpc.cc:124
static long ngcInt(number &i, const coeffs r)
Definition: gnumpc.cc:66
static number ngcSub(number a, number b, const coeffs R)
Definition: gnumpc.cc:166
#define TRUE
Definition: auxiliary.h:100
static BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:377
static void ngcPower(number x, int exp, number *u, const coeffs r)
Definition: gnumpc.cc:205
static number ngcMult(number a, number b, const coeffs R)
Definition: gnumpc.cc:177
static number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:188
short float_len2
additional char-flags, rInit
Definition: coeffs.h:102
static BOOLEAN ngcIsZero(number a, const coeffs r)
Definition: gnumpc.cc:73
static char * ngcCoeffString(const coeffs r)
Definition: gnumpc.cc:412
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:692
short float_len
additional char-flags, rInit
Definition: coeffs.h:101
#define assume(x)
Definition: mod2.h:390
static BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:294
static char * ngcCoeffName(const coeffs r)
Definition: gnumpc.cc:420
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:40
static number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:250
static number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:54
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
static nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
Definition: gnumpc.cc:522
static BOOLEAN ngcGreaterZero(number a, const coeffs r)
Definition: gnumpc.cc:269
#define NULL
Definition: omList.c:12
static BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:306
static number ngcAdd(number a, number b, const coeffs R)
Definition: gnumpc.cc:155
const char * par_name
parameter name
Definition: coeffs.h:103
static number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:258
static const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:328
int p
Definition: cfModGcd.cc:4019
static void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:98
static number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:112
#define omAlloc0(size)
Definition: omAllocDecl.h:211
static void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:361
#define omStrDup(s)
Definition: omAllocDecl.h:263
static BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:317

◆ ngcInt()

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

Definition at line 66 of file gnumpc.cc.

67 {
68  assume( getCoeffType(r) == n_long_C );
69 
70  return ((gmp_complex*)i)->real();
71 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
complex floating point (GMP) numbers
Definition: coeffs.h:42
int i
Definition: cfEzgcd.cc:125
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421

◆ ngcInvers()

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

Definition at line 136 of file gnumpc.cc.

137 {
138  assume( getCoeffType(R) == n_long_C );
139 
140  gmp_complex* r = NULL;
141  if (((gmp_complex*)a)->isZero())
142  {
143  WerrorS(nDivBy0);
144  }
145  else
146  {
147  r = new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) );
148  }
149  return (number)r;
150 }
void WerrorS(const char *s)
Definition: feFopen.cc:24
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
complex floating point (GMP) numbers
Definition: coeffs.h:42
const char *const nDivBy0
Definition: numbers.h:88
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define NULL
Definition: omList.c:12
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 317 of file gnumpc.cc.

318 {
319  assume( getCoeffType(r) == n_long_C );
320 
321  return (((gmp_complex*)a)->real().isMOne() && ((gmp_complex*)a)->imag().isZero());
322  //return (((gmp_complex*)a)->real().isMOne());
323 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421
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 306 of file gnumpc.cc.

307 {
308  assume( getCoeffType(r) == n_long_C );
309 
310  return (((gmp_complex*)a)->real().isOne() && ((gmp_complex*)a)->imag().isZero());
311  //return (((gmp_complex*)a)->real().isOne());
312 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421
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 73 of file gnumpc.cc.

74 {
75  assume( getCoeffType(r) == n_long_C );
76 
77  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
78 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421
bool isZero(const CFArray &A)
checks if entries of A are zero

◆ ngcKillChar()

static void ngcKillChar ( coeffs  r)
static

Definition at line 399 of file gnumpc.cc.

400 {
401  char** p = (char**)n_ParameterNames(r);
402 
403  const int P = n_NumberOfParameters(r);
404 
405  for( int i = 1; i <= P; i++ )
406  if (p[i-1] != NULL)
407  omFree( (ADDRESS)p[i-1] );
408 
409  omFreeSize((ADDRESS)p, P * sizeof(char*));
410 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
void * ADDRESS
Definition: auxiliary.h:135
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:796
#define omFree(addr)
Definition: omAllocDecl.h:261
int i
Definition: cfEzgcd.cc:125
#define NULL
Definition: omList.c:12
int p
Definition: cfModGcd.cc:4019

◆ ngcMapLongR()

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

Definition at line 469 of file gnumpc.cc.

470 {
471  assume( getCoeffType(r) == n_long_C );
472  assume( getCoeffType(aRing) == n_long_R );
473 
474  if ( from != NULL )
475  {
476  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
477  return (number)res;
478  }
479  else
480  return NULL;
481 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
real floating point (GMP) numbers
Definition: coeffs.h:34
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
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:421
#define NULL
Definition: omList.c:12

◆ ngcMapP()

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

Definition at line 497 of file gnumpc.cc.

498 {
499  assume( getCoeffType(r) == n_long_C );
500  assume( getCoeffType(aRing) == n_Zp );
501 
502  if ( from != NULL )
503  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
504  else
505  return NULL;
506 }
long npInt(number &n, const coeffs r)
Definition: modulop.cc:127
{p < 2^31}
Definition: coeffs.h:30
#define assume(x)
Definition: mod2.h:390
complex floating point (GMP) numbers
Definition: coeffs.h:42
static number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:54
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define NULL
Definition: omList.c:12

◆ ngcMapQ()

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

Definition at line 434 of file gnumpc.cc.

435 {
436  assume( getCoeffType(r) == n_long_C );
437  assume( aRing->rep == n_rep_gap_rat);
438 
439  if ( from != NULL )
440  {
442  return (number)res;
443  }
444  else
445  return NULL;
446 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
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:438
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:12

◆ ngcMapR()

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

Definition at line 483 of file gnumpc.cc.

484 {
485  assume( getCoeffType(r) == n_long_C );
486  assume( getCoeffType(aRing) == n_R );
487 
488  if ( from != NULL )
489  {
490  gmp_complex *res=new gmp_complex((double)nrFloat(from));
491  return (number)res;
492  }
493  else
494  return NULL;
495 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
single prescision (6,6) real numbers
Definition: coeffs.h:32
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
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:421
#define NULL
Definition: omList.c:12
SI_FLOAT nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
Definition: shortfl.cc:56

◆ ngcMapZ()

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

Definition at line 448 of file gnumpc.cc.

449 {
450  assume( getCoeffType(r) == n_long_C );
451  assume( aRing->rep == n_rep_gap_gmp);
452 
453  if ( from != NULL )
454  {
455  if (SR_HDL(from) & SR_INT)
456  {
457  gmp_float f_i= gmp_float(SR_TO_INT(from));
458  gmp_complex *res=new gmp_complex(f_i);
459  return (number)res;
460  }
461  gmp_float f_i=(mpz_ptr)from;
462  gmp_complex *res=new gmp_complex(f_i);
463  return (number)res;
464  }
465  else
466  return NULL;
467 }
(), see rinteger.h, new impl.
Definition: coeffs.h:112
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm res
Definition: facAbsFact.cc:64
#define assume(x)
Definition: mod2.h:390
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:421
#define SR_TO_INT(SR)
Definition: longrat.h:68
#define NULL
Definition: omList.c:12
#define SR_INT
Definition: longrat.h:66
#define SR_HDL(A)
Definition: tgb.cc:35

◆ ngcMult()

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

Definition at line 177 of file gnumpc.cc.

178 {
179  assume( getCoeffType(R) == n_long_C );
180 
181  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) );
182  return (number)r;
183 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcNeg()

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

Definition at line 124 of file gnumpc.cc.

125 {
126  assume( getCoeffType(R) == n_long_C );
127 
128  gmp_complex* r=(gmp_complex*)a;
129  (*r).neg();
130  return (number)a;
131 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421
gmp_complex & neg()
Definition: mpr_complex.cc:660

◆ ngcParameter()

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

Definition at line 40 of file gnumpc.cc.

41 {
42  assume( getCoeffType(r) == n_long_C );
43  assume(i==1);
44 
45  if( i == 1 )
46  return (number)(new gmp_complex( 0L, 1L ));
47 
48  return NULL; // new gmp_complex( ) // 0?
49 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
complex floating point (GMP) numbers
Definition: coeffs.h:42
int i
Definition: cfEzgcd.cc:125
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:421
#define NULL
Definition: omList.c:12

◆ ngcPower()

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

Definition at line 205 of file gnumpc.cc.

206 {
207  assume( getCoeffType(r) == n_long_C );
208 
209  if ( exp == 0 )
210  {
211  gmp_complex* n = new gmp_complex(1);
212  *u=(number)n;
213  return;
214  }
215  else if ( exp == 1 )
216  {
217  n_New(u, r);
218  gmp_complex* n = new gmp_complex();
219  *n= *(gmp_complex*)x;
220  *u=(number)n;
221  return;
222  }
223  else if (exp == 2)
224  {
225  n_New(u, r);
226  gmp_complex* n = new gmp_complex();
227  *n= *(gmp_complex*)x;
228  *u=(number)n;
229  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
230  return;
231  }
232  if ( (exp & 1) == 1 )
233  {
234  ngcPower(x,exp-1,u, r);
235  gmp_complex *n = new gmp_complex();
236  *n=*(gmp_complex*)x;
237  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
238  delete n;
239  }
240  else
241  {
242  number w;
243  n_New(&w, r);
244  ngcPower(x,exp/2,&w, r);
245  ngcPower(w,2,u, r);
246  n_Delete(&w, r);
247  }
248 }
#define n_New(n, r)
Definition: coeffs.h:440
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357
static void ngcPower(number x, int exp, number *u, const coeffs r)
Definition: gnumpc.cc:205
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421
const CanonicalForm & w
Definition: facAbsFact.cc:55
Variable x
Definition: cfModGcd.cc:4023
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:455

◆ ngcRead()

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

Definition at line 328 of file gnumpc.cc.

329 {
330  assume( getCoeffType(r) == n_long_C );
331  const char * const complex_parameter = n_ParameterNames(r)[0];
332  assume( complex_parameter != NULL );
333  const int N = strlen(complex_parameter);
334 
335  if ((*s >= '0') && (*s <= '9'))
336  {
337  gmp_float *re=NULL;
338  s=ngfRead(s,(number *)&re, r); // FIXME? TODO? // extern const char * ngfRead (const char *s, number *a, const coeffs r);
339  gmp_complex *aa=new gmp_complex(*re);
340  *a=(number)aa;
341  delete re;
342  }
343  else if (strncmp(s, complex_parameter, N)==0)
344  {
345  s += N;
346  gmp_complex *aa=new gmp_complex(0L,1L);
347  *a=(number)aa;
348  }
349  else
350  {
351  *a=(number) new gmp_complex(1L);
352  }
353  return s;
354 }
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:800
const CanonicalForm int s
Definition: facAbsFact.cc:55
gmp_complex numbers based on
Definition: mpr_complex.h:178
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:48
#define assume(x)
Definition: mod2.h:390
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:307
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:421
#define NULL
Definition: omList.c:12

◆ ngcRePart()

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

Definition at line 250 of file gnumpc.cc.

251 {
252  assume( getCoeffType(r) == n_long_C );
253 
254  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->real());
255  return (number)n;
256 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcSetChar()

void ngcSetChar ( const coeffs  r)

Definition at line 692 of file gnumpc.cc.

693 {
694  setGMPFloatDigits(r->float_len, r->float_len2);
695 }
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:60

◆ ngcSetMap()

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

Definition at line 522 of file gnumpc.cc.

523 {
524  assume( getCoeffType(dst) == n_long_C );
525 
526  if (src->rep==n_rep_gap_rat) /* Q, Z*/
527  {
528  return ngcMapQ;
529  }
530  if (src->rep==n_rep_gap_gmp) /* Z */
531  {
532  return ngcMapZ;
533  }
534  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
535  {
536  return ngcMapLongR;
537  }
538  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
539  {
540  return ngcCopyMap;
541  }
542  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
543  {
544  return ngcMapR;
545  }
546  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
547  {
548  return ngcMapP;
549  }
550  return NULL;
551 }
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:822
static number ngcMapR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:483
static number ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:448
static number ngcMapQ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:434
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:913
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:858
(), see rinteger.h, new impl.
Definition: coeffs.h:112
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:916
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:497
#define assume(x)
Definition: mod2.h:390
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:421
(number), see longrat.h
Definition: coeffs.h:111
#define NULL
Definition: omList.c:12
(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:508
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:469
(float), see shortfl.h
Definition: coeffs.h:116

◆ ngcSize()

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

Definition at line 80 of file gnumpc.cc.

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

◆ ngcSub()

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

Definition at line 166 of file gnumpc.cc.

167 {
168  assume( getCoeffType(R) == n_long_C );
169 
170  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) - (*(gmp_complex*)b) );
171  return (number)r;
172 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
CanonicalForm b
Definition: cfModGcd.cc:4044
#define assume(x)
Definition: mod2.h:390
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:421

◆ ngcWrite()

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

Definition at line 361 of file gnumpc.cc.

362 {
363  assume( getCoeffType(r) == n_long_C );
364 
365  if (a==NULL)
366  StringAppendS("0");
367  else
368  {
369  char *out;
370  out= complexToStr(*(gmp_complex*)a, r->float_len, r);
371  StringAppendS(out);
372  // omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
373  omFree( (void *)out );
374  }
375 }
gmp_complex numbers based on
Definition: mpr_complex.h:178
#define omFree(addr)
Definition: omAllocDecl.h:261
#define assume(x)
Definition: mod2.h:390
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:421
#define NULL
Definition: omList.c:12
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:704