Changeset 7fee876 in git for libpolys/coeffs/gnumpc.cc
- Timestamp:
- Mar 16, 2012, 9:26:19 PM (11 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'f875bbaccd0831e36aaed09ff6adeb3eb45aeb94')
- Children:
- 5a72fe43aa1fbae0fb93ebbff5685375e726f93c
- Parents:
- ce1f78b09d525de2d3babcf986a9f4821e60ed00
- git-author:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-16 21:26:19+01:00
- git-committer:
- Oleksandr Motsak <motsak@mathematik.uni-kl.de>2012-03-17 05:41:42+01:00
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/coeffs/gnumpc.cc
rce1f78 r7fee876 11 11 #include "config.h" 12 12 13 #include <omalloc/omalloc.h> 14 15 #include <misc/auxiliary.h> 16 #include <misc/mylimits.h> 17 18 #include <reporter/reporter.h> 19 #include <resources/feFopen.h> 20 13 21 #include <coeffs/coeffs.h> 14 22 #include <coeffs/numbers.h> 23 15 24 #include <coeffs/longrat.h> 16 25 #include <coeffs/modulop.h> 26 17 27 #include <coeffs/gnumpc.h> 18 28 #include <coeffs/gnumpfl.h> 29 #include <coeffs/shortfl.h> 30 19 31 #include <coeffs/mpr_complex.h> 20 #include <reporter/reporter.h> 21 #include <omalloc/omalloc.h> 22 23 24 #include <coeffs/shortfl.h> 32 33 34 /// Get a mapping function from src into the domain of this type: long_C! 35 nMapFunc ngcSetMap(const coeffs src, const coeffs dst); 36 37 number ngcMapQ(number from, const coeffs r, const coeffs aRing); 38 39 void ngcSetChar(const coeffs r); 40 41 // Private interface should be hidden!!! 42 43 /// Note: MAY NOT WORK AS EXPECTED! 44 BOOLEAN ngcGreaterZero(number za, const coeffs r); 45 BOOLEAN ngcGreater(number a, number b, const coeffs r); 46 BOOLEAN ngcEqual(number a, number b, const coeffs r); 47 BOOLEAN ngcIsOne(number a, const coeffs r); 48 BOOLEAN ngcIsMOne(number a, const coeffs r); 49 BOOLEAN ngcIsZero(number za, const coeffs r); 50 number ngcInit(long i, const coeffs r); 51 int ngcInt(number &n, const coeffs r); 52 number ngcNeg(number za, const coeffs r); 53 number ngcInvers(number a, const coeffs r); 54 number ngcParameter(int i, const coeffs r); 55 number ngcAdd(number la, number li, const coeffs r); 56 number ngcSub(number la, number li, const coeffs r); 57 number ngcMult(number a, number b, const coeffs r); 58 number ngcDiv(number a, number b, const coeffs r); 59 void ngcPower(number x, int exp, number *lu, const coeffs r); 60 number ngcCopy(number a, const coeffs r); 61 number ngc_Copy(number a, coeffs r); 62 const char * ngcRead (const char *s, number *a, const coeffs r); 63 void ngcWrite(number &a, const coeffs r); 64 number ngcRePart(number a, const coeffs r); 65 number ngcImPart(number a, const coeffs r); 66 67 void ngcDelete(number *a, const coeffs r); 68 void ngcCoeffWrite(const coeffs r, BOOLEAN details); 69 70 #ifdef LDEBUG 71 BOOLEAN ngcDBTest(number a, const char *f, const int l, const coeffs r); 72 #endif 73 74 75 // Why is this here? who needs it? 76 // number ngcMapQ(number from, const coeffs r, const coeffs aRing); 25 77 26 78 /// Our Type! … … 38 90 #endif 39 91 40 /* 41 number ngcPar(int i, const coeffs r) 92 number ngcParameter(int i, const coeffs r) 42 93 { 43 94 assume( getCoeffType(r) == ID ); 44 95 assume(i==1); 45 96 46 gmp_complex* n= new gmp_complex( (long)0, (long)1 ); 47 return (number)n; 48 } 49 */ 97 if( i == 1 ) 98 return (number)(new gmp_complex( (long)0, (long)1 )); 99 100 return NULL; // new gmp_complex( ) // 0? 101 } 50 102 51 103 /*2 … … 329 381 { 330 382 assume( getCoeffType(r) == ID ); 331 assume( r->complex_parameter != NULL ); 383 const char * const complex_parameter = n_ParameterNames(r)[0]; 384 assume( complex_parameter != NULL ); 385 const int N = strlen(complex_parameter); 332 386 333 387 if ((*s >= '0') && (*s <= '9')) … … 339 393 delete re; 340 394 } 341 else if (strncmp(s, r->complex_parameter,strlen(r->complex_parameter))==0)342 { 343 s +=strlen(r->complex_parameter);395 else if (strncmp(s, complex_parameter, N)==0) 396 { 397 s += N; 344 398 gmp_complex *aa=new gmp_complex((long)0,(long)1); 345 399 *a=(number)aa; … … 385 439 (p->float_len2 == r->float_len2) 386 440 ) 387 if (strcmp(p->par_name, r->complex_parameter) == 0)441 if (strcmp(p->par_name, n_ParameterNames(r)[0]) == 0) 388 442 return (TRUE); 389 443 } … … 391 445 } 392 446 447 static void ngcKillChar(coeffs r) 448 { 449 char** p = (char**)n_ParameterNames(r); 450 451 const int P = n_NumberOfParameters(r); 452 453 for( int i = 1; i <= P; i++ ) 454 if (p[i-1] != NULL) 455 omFree( (ADDRESS)p[i-1] ); 456 457 omFreeSize((ADDRESS)p, P * sizeof(char*)); 458 } 459 393 460 BOOLEAN ngcInitChar(coeffs n, void* parameter) 394 461 { 395 462 assume( getCoeffType(n) == ID ); 396 463 397 n->cfKillChar = n dKillChar; /* dummy */464 n->cfKillChar = ngcKillChar; 398 465 n->ch = 0; 399 466 … … 496 563 r->has_simple_Inverse=FALSE; 497 564 */ 498 565 566 n->iNumberOfParameters = 1; 567 n->cfParameter = ngcParameter; 568 569 char ** pParameterNames = (char **) omAlloc0(sizeof(char *)); 570 499 571 if( parameter != NULL) 500 572 { 501 573 LongComplexInfo* p = (LongComplexInfo*)parameter; 502 n->complex_parameter = omStrDup(p->par_name);574 pParameterNames[0] = omStrDup(p->par_name); //TODO use omAlloc for allocating memory and use strcpy? 503 575 n->float_len = p->float_len; 504 576 n->float_len2 = p->float_len2; … … 506 578 } else // default values, just for testing! 507 579 { 508 n->complex_parameter= omStrDup("i");580 pParameterNames[0] = omStrDup("i"); 509 581 n->float_len = SHORT_REAL_LENGTH; 510 582 n->float_len2 = SHORT_REAL_LENGTH; … … 513 585 assume( n->float_len <= n->float_len2 ); 514 586 assume( n->float_len2 >= SHORT_REAL_LENGTH ); 515 assume( n->complex_parameter != NULL ); 516 587 assume( pParameterNames != NULL ); 588 assume( pParameterNames[0] != NULL ); 589 590 n->pParameterNames = pParameterNames; 591 592 // NOTE: n->complex_parameter was replaced by n_ParameterNames(n)[0] 593 // TODO: nfKillChar MUST destroy n->pParameterNames[0] (0-term. string) && n->pParameterNames (array of size 1) 594 517 595 return FALSE; 518 596 } … … 623 701 Print("// characteristic : 0 (complex:%d digits, additional %d digits)\n", 624 702 r->float_len, r->float_len2); /* long C */ 625 Print("// 1 parameter : %s \n", r->complex_parameter);626 Print("// minpoly : (%s^2+1)\n", r->complex_parameter);627 } 703 Print("// 1 parameter : %s \n", n_ParameterNames(r)[0]); // this trailing space is for compatibility with the legacy Singular 704 Print("// minpoly : (%s^2+1)\n", n_ParameterNames(r)[0]); 705 }
Note: See TracChangeset
for help on using the changeset viewer.