My Project
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

static BOOLEAN ngcDBTest (number, const char *, const int, 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 void ngcInpAdd (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 void ngcInpMult (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 * 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 number ngcInitMPZ (mpz_t m, const coeffs)
 
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 151 of file gnumpc.cc.

152 {
153  assume( getCoeffType(R) == n_long_C );
154 
155  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) + (*(gmp_complex*)b) );
156  return (number)r;
157 }
CanonicalForm b
Definition: cfModGcd.cc:4103
gmp_complex numbers based on
Definition: mpr_complex.h:179
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:41
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
#define assume(x)
Definition: mod2.h:389
#define R
Definition: sirandom.c:27

◆ ngcCoeffIsEqual()

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

Definition at line 384 of file gnumpc.cc.

385 {
386  if (n==n_long_C)
387  {
388  LongComplexInfo* p = (LongComplexInfo *)(parameter);
389 
390  if ((p==NULL)
391  && (SHORT_REAL_LENGTH==r->float_len)
392  && (SHORT_REAL_LENGTH==r->float_len2)
393  && (strcmp("i",n_ParameterNames(r)[0]) == 0)
394  )
395  return TRUE;
396  if ((p!=NULL) &&
397  (p->float_len == r->float_len) &&
398  (p->float_len2 == r->float_len2)
399  )
400  if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0)
401  return (TRUE);
402  }
403  return (FALSE);
404 }
#define TRUE
Definition: auxiliary.h:100
#define FALSE
Definition: auxiliary.h:96
int p
Definition: cfModGcd.cc:4078
static FORCE_INLINE char const ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:775
#define SHORT_REAL_LENGTH
Definition: numbers.h:57
#define NULL
Definition: omList.c:12

◆ ngcCoeffName()

static char* ngcCoeffName ( const coeffs  r)
static

Definition at line 419 of file gnumpc.cc.

420 {
421  STATIC_VAR char ngcCoeffName_buf[40];
422  const char *p=n_ParameterNames(r)[0];
423  sprintf(ngcCoeffName_buf,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
424  return ngcCoeffName_buf;
425 }
#define STATIC_VAR
Definition: globaldefs.h:7

◆ ngcCoeffWrite()

static void ngcCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 427 of file gnumpc.cc.

428 {
429  Print("real[%s](complex:%d digits, additional %d digits)/(%s^2+1)",n_ParameterNames(r)[0],
430  r->float_len, r->float_len2, n_ParameterNames(r)[0]); /* long C */
431 }
#define Print
Definition: emacs.cc:80

◆ ngcCopy()

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

Definition at line 107 of file gnumpc.cc.

108 {
109  assume( getCoeffType(r) == n_long_C );
110 
111  gmp_complex* b= new gmp_complex( *(gmp_complex*)a );
112  return (number)b;
113 }

◆ ngcCopyMap()

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

Definition at line 507 of file gnumpc.cc.

508 {
509  assume( getCoeffType(r) == n_long_C );
510  assume( getCoeffType(aRing) == n_long_C );
511 
512  gmp_complex* b = NULL;
513 
514  if ( from != NULL )
515  {
516  b = new gmp_complex( *(gmp_complex*)from );
517  }
518  return (number)b;
519 }

◆ ngcDBTest()

static BOOLEAN ngcDBTest ( number  ,
const char *  ,
const int  ,
const coeffs  r 
)
static

Definition at line 27 of file gnumpc.cc.

28 {
29  assume( getCoeffType(r) == n_long_C );
30 
31  return TRUE;
32 }

◆ ngcDelete()

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

Definition at line 93 of file gnumpc.cc.

94 {
95  assume( getCoeffType(r) == n_long_C );
96 
97  if ( *a != NULL )
98  {
99  delete *(gmp_complex**)a;
100  *a=NULL;
101  }
102 }

◆ ngcDiv()

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

Definition at line 198 of file gnumpc.cc.

199 {
200  assume( getCoeffType(r) == n_long_C );
201 
202  if (((gmp_complex*)b)->isZero())
203  {
204  // a/0 = error
205  WerrorS(nDivBy0);
206  return (number)new gmp_complex( 0 );
207  }
208  gmp_complex* res = new gmp_complex( (*(gmp_complex*)a) / (*(gmp_complex*)b) );
209  return (number)res;
210 }
CanonicalForm res
Definition: facAbsFact.cc:60
bool isZero(const CFArray &A)
checks if entries of A are zero
void WerrorS(const char *s)
Definition: feFopen.cc:24
const char *const nDivBy0
Definition: numbers.h:89

◆ ngcEqual()

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

Definition at line 301 of file gnumpc.cc.

302 {
303  assume( getCoeffType(r) == n_long_C );
304 
305  gmp_complex *aa=(gmp_complex*)a;
306  gmp_complex *bb=(gmp_complex*)b;
307  return (*aa) == (*bb);
308 }

◆ ngcGreater()

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

Definition at line 289 of file gnumpc.cc.

290 {
291  assume( getCoeffType(r) == n_long_C );
292 
293  gmp_complex *aa=(gmp_complex*)a;
294  gmp_complex *bb=(gmp_complex*)b;
295  return (*aa) > (*bb);
296 }

◆ ngcGreaterZero()

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

Definition at line 276 of file gnumpc.cc.

277 {
278  assume( getCoeffType(r) == n_long_C );
279 
280  if ( ! ((gmp_complex*)a)->imag().isZero() )
281  return ( abs( *(gmp_complex*)a).sign() >= 0 );
282  else
283  return ( ((gmp_complex*)a)->real().sign() >= 0 );
284 }
Rational abs(const Rational &a)
Definition: GMPrat.cc:436
static int sign(int x)
Definition: ring.cc:3427

◆ ngcImPart()

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

Definition at line 265 of file gnumpc.cc.

266 {
267  assume( getCoeffType(r) == n_long_C );
268 
269  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->imag());
270  return (number)n;
271 }

◆ ngcInit()

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

Definition at line 49 of file gnumpc.cc.

50 {
51  assume( getCoeffType(r) == n_long_C );
52 
53  gmp_complex* n= new gmp_complex( (long)i, 0L );
54 
55  return (number)n;
56 }
int i
Definition: cfEzgcd.cc:132

◆ ngcInitChar()

BOOLEAN ngcInitChar ( coeffs  n,
void *  parameter 
)

Initialize r (n_long_C)

Definition at line 560 of file gnumpc.cc.

561 {
562  assume( getCoeffType(n) == n_long_C );
563  n->is_field=TRUE;
564  n->is_domain=TRUE;
565  n->rep=n_rep_gmp_complex;
566 
567  n->cfKillChar = ngcKillChar;
568  n->ch = 0;
569  n->cfCoeffName=ngcCoeffName;
570  n->cfCoeffWrite = ngcCoeffWrite;
571 
572  n->cfDelete = ngcDelete;
573  //n->cfNormalize=ndNormalize;
574  n->cfInit = ngcInit;
575  n->cfInitMPZ = ngcInitMPZ;
576  n->cfInt = ngcInt;
577  n->cfAdd = ngcAdd;
578  n->cfInpAdd = ngcInpAdd;
579  n->cfSub = ngcSub;
580  n->cfMult = ngcMult;
581  n->cfInpMult = ngcInpMult;
582  n->cfDiv = ngcDiv;
583  n->cfExactDiv= ngcDiv;
584  n->cfInpNeg = ngcNeg;
585  n->cfInvers = ngcInvers;
586  n->cfCopy = ngcCopy;
587  n->cfGreater = ngcGreater;
588  n->cfEqual = ngcEqual;
589  n->cfIsZero = ngcIsZero;
590  n->cfIsOne = ngcIsOne;
591  n->cfIsMOne = ngcIsMOne;
592  n->cfGreaterZero = ngcGreaterZero;
593  n->cfSize = ngcSize;
594 
595  n->cfWriteLong = ngcWrite;
596  n->cfWriteShort = ngcWrite;
597 
598  n->cfRead = ngcRead;
599  n->cfPower = ngcPower;
600  n->cfSetMap = ngcSetMap;
601  n->cfRePart = ngcRePart;
602  n->cfImPart = ngcImPart;
603  // cfSize = ndSize;
604 #ifdef LDEBUG
605  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
606 #endif
607 
608  n->nCoeffIsEqual = ngcCoeffIsEqual;
609 
610  n->cfSetChar=ngcSetChar;
611 
612 /*
613  //r->cfInitChar=nlInitChar;
614  r->cfKillChar=NULL;
615 
616  r->cfMult = nlMult;
617  r->cfSub = nlSub;
618  r->cfAdd = nlAdd;
619  r->cfDiv = nlDiv;
620  r->cfIntMod= nlIntMod;
621  r->cfExactDiv= nlExactDiv;
622  r->cfInit = nlInit;
623  r->cfSize = nlSize;
624  r->cfInt = nlInt;
625 #ifdef HAVE_RINGS
626  r->cfDivComp = NULL; // only for ring stuff
627  r->cfIsUnit = NULL; // only for ring stuff
628  r->cfGetUnit = NULL; // only for ring stuff
629  r->cfExtGcd = NULL; // only for ring stuff
630 #endif
631  r->cfInpNeg = nlNeg;
632  r->cfInvers= nlInvers;
633  r->cfCopy = nl_Copy;
634  r->cfRePart = nl_Copy;
635  r->cfImPart = ndReturn0;
636  r->cfWriteLong = nlWrite;
637  r->cfRead = nlRead;
638  r->cfNormalize=nlNormalize;
639  r->cfGreater = nlGreater;
640 #ifdef HAVE_RINGS
641  r->cfDivBy = NULL; // only for ring stuff
642 #endif
643  r->cfEqual = nlEqual;
644  r->cfIsZero = nlIsZero;
645  r->cfIsOne = nlIsOne;
646  r->cfIsMOne = nlIsMOne;
647  r->cfGreaterZero = nlGreaterZero;
648  r->cfPower = nlPower;
649  r->cfGetDenom = nlGetDenom;
650  r->cfGetNumerator = nlGetNumerator;
651  r->cfGcd = nlGcd;
652  r->cfLcm = nlLcm;
653  r->cfDelete= nlDelete;
654  r->cfSetMap = nlSetMap;
655  r->cfName = ndName;
656  r->cfInpMult=nlInpMult;
657 #ifdef LDEBUG
658  // debug stuff
659  r->cfDBTest=nlDBTest;
660 #endif
661 
662  // the variables:
663  r->type = n_Q;
664  r->ch = 0;
665  r->has_simple_Alloc=FALSE;
666  r->has_simple_Inverse=FALSE;
667 */
668 
669  n->iNumberOfParameters = 1;
670  n->cfParameter = ngcParameter;
671 
672  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
673 
674  if( parameter != NULL)
675  {
676  LongComplexInfo* p = (LongComplexInfo*)parameter;
677  pParameterNames[0] = omStrDup(p->par_name);
678  // fix wrong parameters:
679  if (p->float_len<SHORT_REAL_LENGTH) p->float_len=SHORT_REAL_LENGTH;
680  n->float_len = p->float_len;
681  n->float_len2 = p->float_len2;
682 
683  } else // default values, just for testing!
684  {
685  pParameterNames[0] = omStrDup("i");
686  n->float_len = SHORT_REAL_LENGTH;
687  n->float_len2 = SHORT_REAL_LENGTH;
688  }
689 
690  assume( pParameterNames != NULL );
691  assume( pParameterNames[0] != NULL );
692 
693  n->pParameterNames = (const char**)pParameterNames;
694 
695  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
696  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
697 
698  return FALSE;
699 }
@ n_rep_gmp_complex
(gmp_complex), see gnumpc.h
Definition: coeffs.h:118
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:406
static number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:265
static number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:198
static void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:93
static void ngcInpMult(number &a, number b, const coeffs R)
Definition: gnumpc.cc:188
static number ngcSub(number a, number b, const coeffs R)
Definition: gnumpc.cc:169
static const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:335
static number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:107
static number ngcInvers(number a, const coeffs R)
Definition: gnumpc.cc:131
static number ngcInitMPZ(mpz_t m, const coeffs)
Definition: gnumpc.cc:521
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:701
static void ngcPower(number x, int exp, number *u, const coeffs r)
Definition: gnumpc.cc:215
static number ngcAdd(number a, number b, const coeffs R)
Definition: gnumpc.cc:151
static nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
Definition: gnumpc.cc:529
static BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:324
static BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:384
static BOOLEAN ngcGreaterZero(number a, const coeffs r)
Definition: gnumpc.cc:276
static number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:49
static number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:257
static void ngcCoeffWrite(const coeffs r, BOOLEAN)
Definition: gnumpc.cc:427
static BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:289
static number ngcParameter(int i, const coeffs r)
Definition: gnumpc.cc:35
static void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:368
static int ngcSize(number n, const coeffs R)
Definition: gnumpc.cc:75
static number ngcNeg(number a, const coeffs R)
Definition: gnumpc.cc:119
static BOOLEAN ngcIsZero(number a, const coeffs r)
Definition: gnumpc.cc:68
static number ngcMult(number a, number b, const coeffs R)
Definition: gnumpc.cc:180
static void ngcInpAdd(number &a, number b, const coeffs R)
Definition: gnumpc.cc:159
static BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:313
static long ngcInt(number &i, const coeffs r)
Definition: gnumpc.cc:61
static char * ngcCoeffName(const coeffs r)
Definition: gnumpc.cc:419
static BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:301
#define omStrDup(s)
Definition: omAllocDecl.h:263
#define omAlloc0(size)
Definition: omAllocDecl.h:211

◆ ngcInitMPZ()

static number ngcInitMPZ ( mpz_t  m,
const  coeffs 
)
static

Definition at line 521 of file gnumpc.cc.

522 {
523  gmp_float mm(m);
524  gmp_complex* res = new gmp_complex(mm);
525  return (number)res;
526 }
int m
Definition: cfEzgcd.cc:128

◆ ngcInpAdd()

static void ngcInpAdd ( number &  a,
number  b,
const coeffs  R 
)
static

Definition at line 159 of file gnumpc.cc.

160 {
161  assume( getCoeffType(R) == n_long_C );
162 
163  (*(gmp_complex*)a) += (*(gmp_complex*)b);
164 }

◆ ngcInpMult()

static void ngcInpMult ( 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  (*(gmp_complex*)a) *= (*(gmp_complex*)b);
193 }

◆ ngcInt()

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

Definition at line 61 of file gnumpc.cc.

62 {
63  assume( getCoeffType(r) == n_long_C );
64 
65  return ((gmp_complex*)i)->real();
66 }

◆ ngcInvers()

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

Definition at line 131 of file gnumpc.cc.

132 {
133  assume( getCoeffType(R) == n_long_C );
134 
135  gmp_complex* r = NULL;
136  if (((gmp_complex*)a)->isZero())
137  {
138  WerrorS(nDivBy0);
139  r = new gmp_complex( 0 );
140  }
141  else
142  {
143  r = new gmp_complex( (gmp_complex)1 / (*(gmp_complex*)a) );
144  }
145  return (number)r;
146 }

◆ ngcIsMOne()

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

Definition at line 324 of file gnumpc.cc.

325 {
326  assume( getCoeffType(r) == n_long_C );
327 
328  return (((gmp_complex*)a)->real().isMOne() && ((gmp_complex*)a)->imag().isZero());
329  //return (((gmp_complex*)a)->real().isMOne());
330 }

◆ ngcIsOne()

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

Definition at line 313 of file gnumpc.cc.

314 {
315  assume( getCoeffType(r) == n_long_C );
316 
317  return (((gmp_complex*)a)->real().isOne() && ((gmp_complex*)a)->imag().isZero());
318  //return (((gmp_complex*)a)->real().isOne());
319 }

◆ ngcIsZero()

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

Definition at line 68 of file gnumpc.cc.

69 {
70  assume( getCoeffType(r) == n_long_C );
71 
72  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
73 }

◆ ngcKillChar()

static void ngcKillChar ( coeffs  r)
static

Definition at line 406 of file gnumpc.cc.

407 {
408  char** p = (char**)n_ParameterNames(r);
409 
410  const int P = n_NumberOfParameters(r);
411 
412  for( int i = 1; i <= P; i++ )
413  if (p[i-1] != NULL)
414  omFree( (ADDRESS)p[i-1] );
415 
416  omFreeSize((ADDRESS)p, P * sizeof(char*));
417 }
void * ADDRESS
Definition: auxiliary.h:119
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:771
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
#define omFree(addr)
Definition: omAllocDecl.h:261

◆ ngcMapLongR()

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

Definition at line 468 of file gnumpc.cc.

469 {
470  assume( getCoeffType(r) == n_long_C );
471  assume( getCoeffType(aRing) == n_long_R );
472 
473  if ( from != NULL )
474  {
475  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
476  return (number)res;
477  }
478  else
479  return NULL;
480 }
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:33

◆ ngcMapP()

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

Definition at line 496 of file gnumpc.cc.

497 {
498  assume( getCoeffType(r) == n_long_C );
499  assume( getCoeffType(aRing) == n_Zp );
500 
501  if ( from != NULL )
502  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
503  else
504  return NULL;
505 }
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:29
long npInt(number &n, const coeffs r)
Definition: modulop.cc:83

◆ ngcMapQ()

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

Definition at line 433 of file gnumpc.cc.

434 {
435  assume( getCoeffType(r) == n_long_C );
436  assume( aRing->rep == n_rep_gap_rat);
437 
438  if ( from != NULL )
439  {
441  return (number)res;
442  }
443  else
444  return NULL;
445 }
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:111
gmp_float numberFieldToFloat(number num, int cf)
Definition: mpr_complex.cc:438
#define QTOF
Definition: mpr_complex.h:19

◆ ngcMapR()

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

Definition at line 482 of file gnumpc.cc.

483 {
484  assume( getCoeffType(r) == n_long_C );
485  assume( getCoeffType(aRing) == n_R );
486 
487  if ( from != NULL )
488  {
489  gmp_complex *res=new gmp_complex((double)nrFloat(from));
490  return (number)res;
491  }
492  else
493  return NULL;
494 }
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:31
SI_FLOAT nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
Definition: shortfl.cc:48

◆ ngcMapZ()

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

Definition at line 447 of file gnumpc.cc.

448 {
449  assume( getCoeffType(r) == n_long_C );
450  assume( aRing->rep == n_rep_gap_gmp);
451 
452  if ( from != NULL )
453  {
454  if (SR_HDL(from) & SR_INT)
455  {
456  gmp_float f_i= gmp_float(SR_TO_INT(from));
457  gmp_complex *res=new gmp_complex(f_i);
458  return (number)res;
459  }
460  gmp_float f_i=(mpz_ptr)from;
461  gmp_complex *res=new gmp_complex(f_i);
462  return (number)res;
463  }
464  else
465  return NULL;
466 }
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:112
#define SR_INT
Definition: longrat.h:67
#define SR_TO_INT(SR)
Definition: longrat.h:69
#define SR_HDL(A)
Definition: tgb.cc:35

◆ ngcMult()

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

Definition at line 180 of file gnumpc.cc.

181 {
182  assume( getCoeffType(R) == n_long_C );
183 
184  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) * (*(gmp_complex*)b) );
185  return (number)r;
186 }

◆ ngcNeg()

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

Definition at line 119 of file gnumpc.cc.

120 {
121  assume( getCoeffType(R) == n_long_C );
122 
123  gmp_complex* r=(gmp_complex*)a;
124  (*r).neg();
125  return (number)a;
126 }
gmp_complex & neg()
Definition: mpr_complex.cc:660

◆ ngcParameter()

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

Definition at line 35 of file gnumpc.cc.

36 {
37  assume( getCoeffType(r) == n_long_C );
38  assume(i==1);
39 
40  if( i == 1 )
41  return (number)(new gmp_complex( 0L, 1L ));
42 
43  return NULL; // new gmp_complex( ) // 0?
44 }

◆ ngcPower()

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

Definition at line 215 of file gnumpc.cc.

216 {
217  assume( getCoeffType(r) == n_long_C );
218 
219  if ( exp == 0 )
220  {
221  gmp_complex* n = new gmp_complex(1);
222  *u=(number)n;
223  return;
224  }
225  else if ( exp == 1 )
226  {
227  gmp_complex* n = new gmp_complex();
228  *n= *(gmp_complex*)x;
229  *u=(number)n;
230  return;
231  }
232  else if (exp == 2)
233  {
234  gmp_complex* n = new gmp_complex();
235  *n= *(gmp_complex*)x;
236  *u=(number)n;
237  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
238  return;
239  }
240  if ( (exp & 1) == 1 )
241  {
242  ngcPower(x,exp-1,u, r);
243  gmp_complex *n = new gmp_complex();
244  *n=*(gmp_complex*)x;
245  *(gmp_complex*)(*u) *= *(gmp_complex*)n;
246  delete n;
247  }
248  else
249  {
250  number w=NULL;
251  ngcPower(x,exp/2,&w, r);
252  ngcPower(w,2,u, r);
253  n_Delete(&w, r);
254  }
255 }
Variable x
Definition: cfModGcd.cc:4082
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:452
const CanonicalForm & w
Definition: facAbsFact.cc:51
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:357

◆ ngcRead()

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

Definition at line 335 of file gnumpc.cc.

336 {
337  assume( getCoeffType(r) == n_long_C );
338  const char * const complex_parameter = n_ParameterNames(r)[0];
339  assume( complex_parameter != NULL );
340  const int N = strlen(complex_parameter);
341 
342  if ((*s >= '0') && (*s <= '9'))
343  {
344  gmp_float *re=NULL;
345  s=ngfRead(s,(number *)&re, r); // FIXME? TODO? // extern const char * ngfRead (const char *s, number *a, const coeffs r);
346  gmp_complex *aa=new gmp_complex(*re);
347  *a=(number)aa;
348  delete re;
349  }
350  else if (strncmp(s, complex_parameter, N)==0)
351  {
352  s += N;
353  gmp_complex *aa=new gmp_complex(0L,1L);
354  *a=(number)aa;
355  }
356  else
357  {
358  *a=(number) new gmp_complex(1L);
359  }
360  return s;
361 }
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:56
const CanonicalForm int s
Definition: facAbsFact.cc:51
const char * ngfRead(const char *start, number *a, const coeffs r)
Definition: gnumpfl.cc:324

◆ ngcRePart()

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

Definition at line 257 of file gnumpc.cc.

258 {
259  assume( getCoeffType(r) == n_long_C );
260 
261  gmp_complex* n = new gmp_complex(((gmp_complex*)a)->real());
262  return (number)n;
263 }

◆ ngcSetChar()

void ngcSetChar ( const coeffs  r)

Definition at line 701 of file gnumpc.cc.

702 {
703  setGMPFloatDigits(r->float_len, r->float_len2);
704 }
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 529 of file gnumpc.cc.

530 {
531  assume( getCoeffType(dst) == n_long_C );
532 
533  if (src->rep==n_rep_gap_rat) /* Q, Z*/
534  {
535  return ngcMapQ;
536  }
537  if (src->rep==n_rep_gap_gmp) /* Z */
538  {
539  return ngcMapZ;
540  }
541  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
542  {
543  return ngcMapLongR;
544  }
545  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
546  {
547  return ngcCopyMap;
548  }
549  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
550  {
551  return ngcMapR;
552  }
553  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
554  {
555  return ngcMapP;
556  }
557  return NULL;
558 }
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:888
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:797
@ n_rep_float
(float), see shortfl.h
Definition: coeffs.h:116
@ n_rep_int
(int), see modulop.h
Definition: coeffs.h:110
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:117
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:833
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:891
static number ngcMapQ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:433
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:496
static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:507
static number ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:447
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:468
static number ngcMapR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:482

◆ ngcSize()

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

Definition at line 75 of file gnumpc.cc.

76 {
77  int r = (int)((gmp_complex*)n)->real();
78  if (r < 0) r = -r;
79  int i = (int)((gmp_complex*)n)->imag();
80  if (i < 0) i = -i;
81  int oneNorm = r + i;
82  /* basically return the 1-norm of n;
83  only if this happens to be zero although n != 0,
84  return 1;
85  (this code ensures that zero has the size zero) */
86  if ((oneNorm == 0.0) & (ngcIsZero(n,R) == FALSE)) oneNorm = 1;
87  return oneNorm;
88 }
static CanonicalForm oneNorm(const CanonicalForm &F)

◆ ngcSub()

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

Definition at line 169 of file gnumpc.cc.

170 {
171  assume( getCoeffType(R) == n_long_C );
172 
173  gmp_complex* r= new gmp_complex( (*(gmp_complex*)a) - (*(gmp_complex*)b) );
174  return (number)r;
175 }

◆ ngcWrite()

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

Definition at line 368 of file gnumpc.cc.

369 {
370  assume( getCoeffType(r) == n_long_C );
371 
372  if (a==NULL)
373  StringAppendS("0");
374  else
375  {
376  char *out;
377  out= complexToStr(*(gmp_complex*)a, r->float_len, r);
378  StringAppendS(out);
379  // omFreeSize((void *)out, (strlen(out)+1)* sizeof(char) );
380  omFree( (void *)out );
381  }
382 }
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:704
void StringAppendS(const char *st)
Definition: reporter.cc:107