Changeset 3c0498 in git for libpolys/polys/ext_fields
- Timestamp:
- Mar 21, 2012, 8:29:49 PM (12 years ago)
- Branches:
- (u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
- Children:
- 1f49983e2c0b18b90d6918660ec7a49d584e535e8c8dba7f7269572699622a97ae531f403418954a
- Parents:
- 2d2c99cd52253e2a0a953a1aa32a55546c4a67cc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libpolys/polys/ext_fields/algext.cc
r2d2c99c r3c0498 76 76 77 77 /// forward declarations 78 BOOLEAN naGreaterZero(number a, const coeffs cf); 78 BOOLEAN naGreaterZero(number a, const coeffs cf); 79 79 BOOLEAN naGreater(number a, number b, const coeffs cf); 80 80 BOOLEAN naEqual(number a, number b, const coeffs cf); … … 114 114 if (a == NULL) return TRUE; 115 115 p_Test((poly)a, naRing); 116 if(p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing)) 116 if((((poly)a)!=naMinpoly) 117 && p_Totaldegree((poly)a, naRing) >= p_Totaldegree(naMinpoly, naRing)) 117 118 { 118 119 Print("deg >= deg(minpoly) in %s:%d\n",f,l); … … 153 154 { 154 155 if (*a == NULL) return; 156 if (((poly)*a)==naMinpoly) { *a=NULL;return;} 155 157 poly aAsPoly = (poly)(*a); 156 158 p_Delete(&aAsPoly, naRing); … … 161 163 { 162 164 naTest(a); naTest(b); 163 165 164 166 /// simple tests 165 167 if (a == b) return TRUE; … … 173 175 if (b != NULL) bDeg = p_Totaldegree((poly)b, naRing); 174 176 if (aDeg != bDeg) return FALSE; 175 177 176 178 /// subtraction test 177 179 number c = naSub(a, b, cf); … … 185 187 naTest(a); 186 188 if (a == NULL) return NULL; 189 if (((poly)a)==naMinpoly) return a; 187 190 return (number)p_Copy((poly)a, naRing); 188 191 } … … 248 251 return NULL; 249 252 } 250 253 251 254 return (number)p_NSet(n, A); 252 255 } … … 298 301 { 299 302 assume( cf != NULL ); 300 303 301 304 const ring A = cf->extRing; 302 305 303 306 assume( A != NULL ); 304 307 assume( A->cf != NULL ); 305 308 306 309 n_CoeffWrite(A->cf, details); 307 310 308 311 // rWrite(A); 309 312 310 313 const int P = rVar(A); 311 314 assume( P > 0 ); 312 315 313 316 Print("// %d parameter : ", P); 314 317 315 318 for (int nop=0; nop < P; nop ++) 316 319 Print("%s ", rRingVar(nop, A)); 317 320 318 321 PrintLn(); 319 322 320 323 const ideal I = A->minideal; 321 324 322 325 assume( I != NULL ); 323 326 assume( IDELEMS(I) == 1 ); 324 327 325 328 326 329 if ( details ) … … 332 335 else 333 336 PrintS("// minpoly : ..."); 334 337 335 338 PrintLn(); 336 339 337 340 /* 338 341 char *x = rRingVar(0, A); … … 400 403 { 401 404 naTest(a); 402 405 403 406 /* special cases first */ 404 407 if (a == NULL) … … 410 413 else if (exp == 1) { *b = naCopy(a, cf); return; } 411 414 else if (exp == -1) { *b = naInvers(a, cf); return; } 412 415 413 416 int expAbs = exp; if (expAbs < 0) expAbs = -expAbs; 414 417 415 418 /* now compute a^expAbs */ 416 419 poly pow; poly aAsPoly = (poly)a; … … 446 449 definiteReduce(pow, naMinpoly, cf); 447 450 } 448 451 449 452 /* invert if original exponent was negative */ 450 453 number n = (number)pow; … … 552 555 if( rEqual(naRing, e->r, TRUE) ) 553 556 { 554 const ideal mi = naRing->minideal; 557 const ideal mi = naRing->minideal; 555 558 assume( IDELEMS(mi) == 1 ); 556 559 ideal ii = e->i; … … 566 569 } 567 570 568 return FALSE; 569 571 return FALSE; 572 570 573 } 571 574 … … 604 607 { 605 608 poly aa=(poly)a; 606 definiteReduce(aa,naMinpoly,cf); 609 if (aa!=naMinpoly) 610 definiteReduce(aa,naMinpoly,cf); 607 611 a=(number)aa; 608 612 } … … 646 650 naTest((number)theGcd); naTest((number)aFactor); naTest((number)mFactor); 647 651 /* the gcd must be 1 since naMinpoly is irreducible and a != NULL: */ 648 assume(naIsOne((number)theGcd, cf)); 652 assume(naIsOne((number)theGcd, cf)); 649 653 p_Delete(&theGcd, naRing); 650 654 p_Delete(&mFactor, naRing); … … 698 702 699 703 poly result = p_NSet(q, dst->extRing); 700 704 701 705 return (number)result; 702 706 } … … 730 734 731 735 if( src == dst ) return ndCopyMap; 732 736 733 737 int h = 0; /* the height of the extension tower given by dst */ 734 738 coeffs bDst = nCoeff_bottom(dst, h); /* the bottom field in the tower dst */ 735 739 coeffs bSrc = nCoeff_bottom(src, h); /* the bottom field in the tower src */ 736 740 737 741 /* for the time being, we only provide maps if h = 1 and if b is Q or 738 742 some field Z/pZ: */ … … 754 758 if ((!nCoeff_is_Zp(bDst)) && (!nCoeff_is_Q(bDst))) return NULL; 755 759 if ((!nCoeff_is_Zp(bSrc)) && (!nCoeff_is_Q(bSrc))) return NULL; 756 760 757 761 if (nCoeff_is_Q(bSrc) && nCoeff_is_Q(bDst)) 758 762 { … … 768 772 return NULL; /// Q(b) --> Q(a) 769 773 } 770 774 771 775 if (nCoeff_is_Zp(bSrc) && nCoeff_is_Zp(bDst)) 772 776 { … … 781 785 return NULL; /// Z/p(b) --> Z/p(a) 782 786 } 783 787 784 788 return NULL; /// default 785 789 } … … 798 802 799 803 const ring R = cf->extRing; 800 assume( R != NULL ); 804 assume( R != NULL ); 801 805 assume( 0 < iParameter && iParameter <= rVar(R) ); 802 806 803 807 poly p = p_One(R); p_SetExp(p, iParameter, 1, R); p_Setm(p, R); 804 808 805 return (number) p; 806 } 807 808 809 /// if m == var(i)/1 => return i, 809 return (number) p; 810 } 811 812 813 /// if m == var(i)/1 => return i, 810 814 int naIsParam(number m, const coeffs cf) 811 815 { … … 813 817 814 818 const ring R = cf->extRing; 815 assume( R != NULL ); 816 817 return p_Var( (poly)m, R ); 819 assume( R != NULL ); 820 821 return p_Var( (poly)m, R ); 818 822 } 819 823 820 824 BOOLEAN naInitChar(coeffs cf, void * infoStruct) 821 { 825 { 822 826 assume( infoStruct != NULL ); 823 827 … … 837 841 838 842 ring R = e->r; 839 assume(R != NULL); 840 843 841 844 R->ref ++; // increase the ref.counter for the ground poly. ring! 842 845 843 R->minideal = e->i; // make a copy? 846 R->minideal = e->i; // make a copy? 844 847 845 848 cf->extRing = R; … … 852 855 p_Test((poly)naMinpoly, naRing); 853 856 #endif 854 857 855 858 cf->cfGreaterZero = naGreaterZero; 856 859 cf->cfGreater = naGreater; … … 860 863 cf->cfIsMOne = naIsMOne; 861 864 cf->cfInit = naInit; 862 cf->cfInit_bigint = naInit_bigint; 865 cf->cfInit_bigint = naInit_bigint; 863 866 cf->cfInt = naInt; 864 867 cf->cfNeg = naNeg; … … 877 880 else 878 881 cf->cfWriteShort = naWriteLong; 879 882 880 883 cf->cfRead = naRead; 881 884 cf->cfDelete = naDelete; … … 901 904 #endif 902 905 cf->cfParDeg = naParDeg; 903 906 904 907 cf->iNumberOfParameters = rVar(R); 905 908 cf->pParameterNames = R->names; 906 909 cf->cfParameter = naParameter; 907 910 908 911 return FALSE; 909 912 }
Note: See TracChangeset
for help on using the changeset viewer.