My Project  debian-1:4.1.1-p2+ds-4build2
Functions
gnumpc.cc File Reference
#include "misc/auxiliary.h"
#include "omalloc/omalloc.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 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 }

◆ 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  && (SHORT_REAL_LENGTH==r->float_len)
386  && (SHORT_REAL_LENGTH==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 }

◆ ngcCoeffName()

static char* ngcCoeffName ( const coeffs  r)
static

Definition at line 421 of file gnumpc.cc.

422 {
423  static char ngcCoeffName_buf[40];
424  const char *p=n_ParameterNames(r)[0];
425  if (ngcCoeffName_buf!=NULL) omFree(ngcCoeffName_buf);
426  sprintf(ngcCoeffName_buf,"complex,%d,%d,%s",r->float_len,r->float_len2,p);
427  return ngcCoeffName_buf;
428 }

◆ 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 }

◆ ngcCoeffWrite()

static void ngcCoeffWrite ( const coeffs  r,
BOOLEAN   
)
static

Definition at line 430 of file gnumpc.cc.

431 {
432  Print("real[%s](complex:%d digits, additional %d digits)/(%s^2+1)",n_ParameterNames(r)[0],
433  r->float_len, r->float_len2, n_ParameterNames(r)[0]); /* long C */
434 }

◆ 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 }

◆ ngcCopyMap()

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

Definition at line 510 of file gnumpc.cc.

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

◆ ngcDBTest()

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

Definition at line 33 of file gnumpc.cc.

34 {
35  assume( getCoeffType(r) == n_long_C );
36 
37  return TRUE;
38 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ ngcInit()

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

Definition at line 55 of file gnumpc.cc.

56 {
57  assume( getCoeffType(r) == n_long_C );
58 
59  gmp_complex* n= new gmp_complex( (long)i, 0L );
60 
61  return (number)n;
62 }

◆ ngcInitChar()

BOOLEAN ngcInitChar ( coeffs  n,
void *  parameter 
)

Initialize r (n_long_C)

Definition at line 555 of file gnumpc.cc.

556 {
557  assume( getCoeffType(n) == n_long_C );
558  n->is_field=TRUE;
559  n->is_domain=TRUE;
560  n->rep=n_rep_gmp_complex;
561 
562  n->cfKillChar = ngcKillChar;
563  n->ch = 0;
564  n->cfCoeffString=ngcCoeffString;
565  n->cfCoeffName=ngcCoeffName;
566 
567  n->cfDelete = ngcDelete;
568  //n->cfNormalize=ndNormalize;
569  n->cfInit = ngcInit;
570  n->cfInt = ngcInt;
571  n->cfAdd = ngcAdd;
572  n->cfSub = ngcSub;
573  n->cfMult = ngcMult;
574  n->cfDiv = ngcDiv;
575  n->cfExactDiv= ngcDiv;
576  n->cfInpNeg = ngcNeg;
577  n->cfInvers = ngcInvers;
578  n->cfCopy = ngcCopy;
579  n->cfGreater = ngcGreater;
580  n->cfEqual = ngcEqual;
581  n->cfIsZero = ngcIsZero;
582  n->cfIsOne = ngcIsOne;
583  n->cfIsMOne = ngcIsMOne;
584  n->cfGreaterZero = ngcGreaterZero;
585 
586  n->cfWriteLong = ngcWrite;
587  n->cfWriteShort = ngcWrite;
588 
589  n->cfRead = ngcRead;
590  n->cfPower = ngcPower;
591  n->cfSetMap = ngcSetMap;
592  n->cfRePart = ngcRePart;
593  n->cfImPart = ngcImPart;
594  n->cfCoeffWrite = ngcCoeffWrite;
595  // cfSize = ndSize;
596 #ifdef LDEBUG
597  //n->cfDBTest = ndDBTest; // not yet implemented: ngcDBTest
598 #endif
599 
600  n->nCoeffIsEqual = ngcCoeffIsEqual;
601 
602  n->cfSetChar=ngcSetChar;
603 
604 /*
605  //r->cfInitChar=nlInitChar;
606  r->cfKillChar=NULL;
607 
608  r->cfMult = nlMult;
609  r->cfSub = nlSub;
610  r->cfAdd = nlAdd;
611  r->cfDiv = nlDiv;
612  r->cfIntMod= nlIntMod;
613  r->cfExactDiv= nlExactDiv;
614  r->cfInit = nlInit;
615  r->cfSize = nlSize;
616  r->cfInt = nlInt;
617 #ifdef HAVE_RINGS
618  r->cfDivComp = NULL; // only for ring stuff
619  r->cfIsUnit = NULL; // only for ring stuff
620  r->cfGetUnit = NULL; // only for ring stuff
621  r->cfExtGcd = NULL; // only for ring stuff
622 #endif
623  r->cfInpNeg = nlNeg;
624  r->cfInvers= nlInvers;
625  r->cfCopy = nl_Copy;
626  r->cfRePart = nl_Copy;
627  r->cfImPart = ndReturn0;
628  r->cfWriteLong = nlWrite;
629  r->cfRead = nlRead;
630  r->cfNormalize=nlNormalize;
631  r->cfGreater = nlGreater;
632 #ifdef HAVE_RINGS
633  r->cfDivBy = NULL; // only for ring stuff
634 #endif
635  r->cfEqual = nlEqual;
636  r->cfIsZero = nlIsZero;
637  r->cfIsOne = nlIsOne;
638  r->cfIsMOne = nlIsMOne;
639  r->cfGreaterZero = nlGreaterZero;
640  r->cfPower = nlPower;
641  r->cfGetDenom = nlGetDenom;
642  r->cfGetNumerator = nlGetNumerator;
643  r->cfGcd = nlGcd;
644  r->cfLcm = nlLcm;
645  r->cfDelete= nlDelete;
646  r->cfSetMap = nlSetMap;
647  r->cfName = ndName;
648  r->cfInpMult=nlInpMult;
649  r->cfInit_bigint=nlCopyMap;
650 #ifdef LDEBUG
651  // debug stuff
652  r->cfDBTest=nlDBTest;
653 #endif
654 
655  // the variables:
656  r->type = n_Q;
657  r->ch = 0;
658  r->has_simple_Alloc=FALSE;
659  r->has_simple_Inverse=FALSE;
660 */
661 
662  n->iNumberOfParameters = 1;
663  n->cfParameter = ngcParameter;
664 
665  char ** pParameterNames = (char **) omAlloc0(sizeof(char *));
666 
667  if( parameter != NULL)
668  {
669  LongComplexInfo* p = (LongComplexInfo*)parameter;
670  pParameterNames[0] = omStrDup(p->par_name);
671  // fix wrong parameters:
672  if (p->float_len<SHORT_REAL_LENGTH) p->float_len=SHORT_REAL_LENGTH;
673  n->float_len = p->float_len;
674  n->float_len2 = p->float_len2;
675 
676  } else // default values, just for testing!
677  {
678  pParameterNames[0] = omStrDup("i");
679  n->float_len = SHORT_REAL_LENGTH;
680  n->float_len2 = SHORT_REAL_LENGTH;
681  }
682 
683  assume( pParameterNames != NULL );
684  assume( pParameterNames[0] != NULL );
685 
686  n->pParameterNames = (const char**)pParameterNames;
687 
688  // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0]
689  // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1)
690 
691  return FALSE;
692 }

◆ ngcInt()

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

Definition at line 67 of file gnumpc.cc.

68 {
69  assume( getCoeffType(r) == n_long_C );
70 
71  return ((gmp_complex*)i)->real();
72 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ ngcIsZero()

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

Definition at line 74 of file gnumpc.cc.

75 {
76  assume( getCoeffType(r) == n_long_C );
77 
78  return ( ((gmp_complex*)a)->real().isZero() && ((gmp_complex*)a)->imag().isZero());
79 }

◆ 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 }

◆ ngcMapLongR()

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

Definition at line 471 of file gnumpc.cc.

472 {
473  assume( getCoeffType(r) == n_long_C );
474  assume( getCoeffType(aRing) == n_long_R );
475 
476  if ( from != NULL )
477  {
478  gmp_complex *res=new gmp_complex(*((gmp_float *)from));
479  return (number)res;
480  }
481  else
482  return NULL;
483 }

◆ ngcMapP()

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

Definition at line 499 of file gnumpc.cc.

500 {
501  assume( getCoeffType(r) == n_long_C );
502  assume( getCoeffType(aRing) == n_Zp );
503 
504  if ( from != NULL )
505  return ngcInit(npInt(from, aRing), r); // FIXME? TODO? // extern int npInt (number &n, const coeffs r);
506  else
507  return NULL;
508 }

◆ ngcMapQ()

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

Definition at line 436 of file gnumpc.cc.

437 {
438  assume( getCoeffType(r) == n_long_C );
439  assume( aRing->rep == n_rep_gap_rat);
440 
441  if ( from != NULL )
442  {
444  return (number)res;
445  }
446  else
447  return NULL;
448 }

◆ ngcMapR()

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

Definition at line 485 of file gnumpc.cc.

486 {
487  assume( getCoeffType(r) == n_long_C );
488  assume( getCoeffType(aRing) == n_R );
489 
490  if ( from != NULL )
491  {
492  gmp_complex *res=new gmp_complex((double)nrFloat(from));
493  return (number)res;
494  }
495  else
496  return NULL;
497 }

◆ ngcMapZ()

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

Definition at line 450 of file gnumpc.cc.

451 {
452  assume( getCoeffType(r) == n_long_C );
453  assume( aRing->rep == n_rep_gap_gmp);
454 
455  if ( from != NULL )
456  {
457  if (SR_HDL(from) & SR_INT)
458  {
459  gmp_float f_i= gmp_float(SR_TO_INT(from));
460  gmp_complex *res=new gmp_complex(f_i);
461  return (number)res;
462  }
463  gmp_float f_i=(mpz_ptr)from;
464  gmp_complex *res=new gmp_complex(f_i);
465  return (number)res;
466  }
467  else
468  return NULL;
469 }

◆ 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 }

◆ 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 
129  gmp_complex* r=(gmp_complex*)a;
130  (*r).neg();
131  return (number)a;
132 }

◆ ngcParameter()

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

Definition at line 41 of file gnumpc.cc.

42 {
43  assume( getCoeffType(r) == n_long_C );
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 }

◆ 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 }

◆ 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 }

◆ 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 }

◆ ngcSetChar()

void ngcSetChar ( const coeffs  r)

Definition at line 694 of file gnumpc.cc.

695 {
696  setGMPFloatDigits(r->float_len, r->float_len2);
697 }

◆ ngcSetMap()

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

Definition at line 524 of file gnumpc.cc.

525 {
526  assume( getCoeffType(dst) == n_long_C );
527 
528  if (src->rep==n_rep_gap_rat) /* Q, Z*/
529  {
530  return ngcMapQ;
531  }
532  if (src->rep==n_rep_gap_gmp) /* Z */
533  {
534  return ngcMapZ;
535  }
536  if ((src->rep==n_rep_gmp_float) && nCoeff_is_long_R(src))
537  {
538  return ngcMapLongR;
539  }
540  if ((src->rep==n_rep_gmp_complex) && nCoeff_is_long_C(src))
541  {
542  return ngcCopyMap;
543  }
544  if ((src->rep==n_rep_float) && nCoeff_is_R(src))
545  {
546  return ngcMapR;
547  }
548  if ((src->rep==n_rep_int) && nCoeff_is_Zp(src))
549  {
550  return ngcMapP;
551  }
552  return NULL;
553 }

◆ 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 }

◆ 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 }

◆ 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 }
getCoeffType
static FORCE_INLINE n_coeffType getCoeffType(const coeffs r)
Returns the type of coeffs domain.
Definition: coeffs.h:422
n_rep_gap_rat
@ n_rep_gap_rat
(number), see longrat.h
Definition: coeffs.h:112
FALSE
#define FALSE
Definition: auxiliary.h:94
ngcMapQ
static number ngcMapQ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:436
ngcInvers
static number ngcInvers(number a, const coeffs R)
Definition: gnumpc.cc:137
numberFieldToFloat
gmp_float numberFieldToFloat(number num, int cf)
Definition: mpr_complex.cc:439
ngfRead
const char * ngfRead(const char *s, number *a, const coeffs r)
Definition: gnumpfl.cc:308
nCoeff_is_Zp
static FORCE_INLINE BOOLEAN nCoeff_is_Zp(const coeffs r)
Definition: coeffs.h:831
StringAppendS
void StringAppendS(const char *st)
Definition: reporter.cc:107
ngcKillChar
static void ngcKillChar(coeffs r)
Definition: gnumpc.cc:400
isZero
bool isZero(const CFArray &A)
checks if entries of A are zero
Definition: facSparseHensel.h:468
omFree
#define omFree(addr)
Definition: omAllocDecl.h:261
ngcCoeffWrite
static void ngcCoeffWrite(const coeffs r, BOOLEAN)
Definition: gnumpc.cc:430
nCoeff_is_R
static FORCE_INLINE BOOLEAN nCoeff_is_R(const coeffs r)
Definition: coeffs.h:850
ngcDelete
static void ngcDelete(number *a, const coeffs r)
Definition: gnumpc.cc:99
LongComplexInfo
Definition: coeffs.h:100
ngcCopy
static number ngcCopy(number a, const coeffs r)
Definition: gnumpc.cc:113
ngcInt
static long ngcInt(number &i, const coeffs r)
Definition: gnumpc.cc:67
x
Variable x
Definition: cfModGcd.cc:4023
ngcGreater
static BOOLEAN ngcGreater(number a, number b, const coeffs r)
Definition: gnumpc.cc:283
n_New
#define n_New(n, r)
Definition: coeffs.h:441
SHORT_REAL_LENGTH
#define SHORT_REAL_LENGTH
Definition: numbers.h:58
n_long_C
@ n_long_C
complex floating point (GMP) numbers
Definition: coeffs.h:42
ngcCoeffIsEqual
static BOOLEAN ngcCoeffIsEqual(const coeffs r, n_coeffType n, void *parameter)
Definition: gnumpc.cc:378
ngcNeg
static number ngcNeg(number a, const coeffs R)
Definition: gnumpc.cc:125
ADDRESS
void * ADDRESS
Definition: auxiliary.h:133
n_rep_float
@ n_rep_float
(float), see shortfl.h
Definition: coeffs.h:117
ngcCoeffString
static char * ngcCoeffString(const coeffs r)
Definition: gnumpc.cc:413
omStrDup
#define omStrDup(s)
Definition: omAllocDecl.h:263
sign
static int sign(int x)
Definition: ring.cc:3328
nrFloat
SI_FLOAT nrFloat(number n)
Converts a n_R number into a float. Needed by Maps.
Definition: shortfl.cc:57
n_Delete
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete 'p'
Definition: coeffs.h:456
N
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
oneNorm
static CanonicalForm oneNorm(const CanonicalForm &F)
Definition: cfModResultant.cc:242
n_NumberOfParameters
static FORCE_INLINE int n_NumberOfParameters(const coeffs r)
Returns the number of parameters.
Definition: coeffs.h:805
n_rep_int
@ n_rep_int
(int), see modulop.h
Definition: coeffs.h:111
ngcSub
static number ngcSub(number a, number b, const coeffs R)
Definition: gnumpc.cc:167
ngcIsZero
static BOOLEAN ngcIsZero(number a, const coeffs r)
Definition: gnumpc.cc:74
w
const CanonicalForm & w
Definition: facAbsFact.cc:55
nCoeff_is_long_C
static FORCE_INLINE BOOLEAN nCoeff_is_long_C(const coeffs r)
Definition: coeffs.h:908
b
CanonicalForm b
Definition: cfModGcd.cc:4044
ngcMult
static number ngcMult(number a, number b, const coeffs R)
Definition: gnumpc.cc:178
ngcMapZ
static number ngcMapZ(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:450
ngcMapR
static number ngcMapR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:485
n_long_R
@ n_long_R
real floating point (GMP) numbers
Definition: coeffs.h:34
gmp_complex::neg
gmp_complex & neg()
Definition: mpr_complex.cc:661
ngcPower
static void ngcPower(number x, int exp, number *u, const coeffs r)
Definition: gnumpc.cc:206
TRUE
#define TRUE
Definition: auxiliary.h:98
i
int i
Definition: cfEzgcd.cc:125
res
CanonicalForm res
Definition: facAbsFact.cc:64
abs
Rational abs(const Rational &a)
Definition: GMPrat.cc:439
setGMPFloatDigits
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:61
nDivBy0
const char *const nDivBy0
Definition: numbers.h:89
omFreeSize
#define omFreeSize(addr, size)
Definition: omAllocDecl.h:260
ngcDiv
static number ngcDiv(number a, number b, const coeffs r)
Definition: gnumpc.cc:189
ngcRePart
static number ngcRePart(number a, const coeffs r)
Definition: gnumpc.cc:251
ngcParameter
static number ngcParameter(int i, const coeffs r)
Definition: gnumpc.cc:41
ngcEqual
static BOOLEAN ngcEqual(number a, number b, const coeffs r)
Definition: gnumpc.cc:295
ngcMapP
static number ngcMapP(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:499
nCoeff_is_long_R
static FORCE_INLINE BOOLEAN nCoeff_is_long_R(const coeffs r)
Definition: coeffs.h:905
omAlloc
#define omAlloc(size)
Definition: omAllocDecl.h:210
ngcSetChar
void ngcSetChar(const coeffs r)
Definition: gnumpc.cc:694
ngcCoeffName
static char * ngcCoeffName(const coeffs r)
Definition: gnumpc.cc:421
ngcIsOne
static BOOLEAN ngcIsOne(number a, const coeffs r)
Definition: gnumpc.cc:307
complexToStr
char * complexToStr(gmp_complex &c, const unsigned int oprec, const coeffs src)
Definition: mpr_complex.cc:705
SR_INT
#define SR_INT
Definition: longrat.h:68
n_R
@ n_R
single prescision (6,6) real numbers
Definition: coeffs.h:32
n_ParameterNames
static FORCE_INLINE const char ** n_ParameterNames(const coeffs r)
Returns a (const!) pointer to (const char*) names of parameters.
Definition: coeffs.h:809
exp
gmp_float exp(const gmp_float &a)
Definition: mpr_complex.cc:358
SR_TO_INT
#define SR_TO_INT(SR)
Definition: longrat.h:70
npInt
long npInt(number &n, const coeffs r)
Definition: modulop.cc:128
ngcGreaterZero
static BOOLEAN ngcGreaterZero(number a, const coeffs r)
Definition: gnumpc.cc:270
ngcAdd
static number ngcAdd(number a, number b, const coeffs R)
Definition: gnumpc.cc:156
n_Zp
@ n_Zp
\F{p < 2^31}
Definition: coeffs.h:30
ngcImPart
static number ngcImPart(number a, const coeffs r)
Definition: gnumpc.cc:259
ngcSetMap
static nMapFunc ngcSetMap(const coeffs src, const coeffs dst)
Definition: gnumpc.cc:524
n_rep_gmp_float
@ n_rep_gmp_float
(gmp_float), see
Definition: coeffs.h:118
Print
#define Print
Definition: emacs.cc:80
ngcCopyMap
static number ngcCopyMap(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:510
WerrorS
void WerrorS(const char *s)
Definition: feFopen.cc:24
ngcInit
static number ngcInit(long i, const coeffs r)
Definition: gnumpc.cc:55
SR_HDL
#define SR_HDL(A)
Definition: tgb.cc:35
assume
#define assume(x)
Definition: mod2.h:390
NULL
#define NULL
Definition: omList.c:10
R
#define R
Definition: sirandom.c:26
QTOF
#define QTOF
Definition: mpr_complex.h:19
p
int p
Definition: cfModGcd.cc:4019
s
const CanonicalForm int s
Definition: facAbsFact.cc:55
ngcRead
static const char * ngcRead(const char *s, number *a, const coeffs r)
Definition: gnumpc.cc:329
ngcWrite
static void ngcWrite(number a, const coeffs r)
Definition: gnumpc.cc:362
ngcIsMOne
static BOOLEAN ngcIsMOne(number a, const coeffs r)
Definition: gnumpc.cc:318
n_rep_gmp_complex
@ n_rep_gmp_complex
(gmp_complex), see gnumpc.h
Definition: coeffs.h:119
omAlloc0
#define omAlloc0(size)
Definition: omAllocDecl.h:211
gmp_float
Definition: mpr_complex.h:31
ngcMapLongR
static number ngcMapLongR(number from, const coeffs aRing, const coeffs r)
Definition: gnumpc.cc:471
gmp_complex
gmp_complex numbers based on
Definition: mpr_complex.h:178
n_rep_gap_gmp
@ n_rep_gap_gmp
(), see rinteger.h, new impl.
Definition: coeffs.h:113