Changeset ce3f53c in git
 Timestamp:
 May 6, 2011, 11:51:40 AM (12 years ago)
 Branches:
 (u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
 Children:
 fba6f18e59118e933bb2d9c5b69b31879517ddff
 Parents:
 d75f15102ef5a6cd3463bf6f11b85177f916e01b
 gitauthor:
 Martin Lee <martinlee84@web.de>20110506 11:51:40+02:00
 gitcommitter:
 Mohamed Barakat <mohamed.barakat@rwthaachen.de>20111109 12:31:37+01:00
 Location:
 libpolys/polys
 Files:

 4 edited
Legend:
 Unmodified
 Added
 Removed

libpolys/polys/clapconv.h
rd75f15 rce3f53c 19 19 #endif /* HAVE_FACTORY */ 20 20 21 poly convFactoryPSingP ( const CanonicalForm & f, const ring r =currRing);22 CanonicalForm convSingPFactoryP( poly p, const ring r =currRing);21 poly convFactoryPSingP ( const CanonicalForm & f, const ring r ); 22 CanonicalForm convSingPFactoryP( poly p, const ring r ); 23 23 24 24 CanonicalForm convSingAPFactoryAP ( poly p , const Variable & a, const ring r ); … … 26 26 poly convFactoryAPSingAP_R ( const CanonicalForm & f, int par_start, int var_start ); 27 27 28 CanonicalForm convSingGFFactoryGF ( poly p );29 poly convFactoryGFSingGF ( const CanonicalForm & f );28 CanonicalForm convSingGFFactoryGF ( poly p, const ring r ); 29 poly convFactoryGFSingGF ( const CanonicalForm & f, const ring r ); 30 30 31 CanonicalForm convSingAFactoryA ( n apolyp , const Variable & a, const ring r );32 n apolyconvFactoryASingA ( const CanonicalForm & f, const ring r );31 CanonicalForm convSingAFactoryA ( number p , const Variable & a, const ring r ); 32 number convFactoryASingA ( const CanonicalForm & f, const ring r ); 33 33 34 CanonicalForm convSingTrPFactoryP ( poly p, const ring r =currRing);35 poly convFactoryPSingTrP ( const CanonicalForm & f, const ring r =currRing);34 CanonicalForm convSingTrPFactoryP ( poly p, const ring r ); 35 poly convFactoryPSingTrP ( const CanonicalForm & f, const ring r ); 36 36 37 37 // CanonicalForm convSingIFactoryI( int i);a < by constructor of CanonicalForm 
libpolys/polys/clapsing.cc
rd75f15 rce3f53c 30 30 #include "monomials/ring.h" 31 31 #include "simpleideals.h" 32 32 //#include "polys.h" 33 33 34 34 void out_cf(const char *s1,const CanonicalForm &f,const char *s2); … … 57 57 if (rField_is_Q(r)  (rField_is_Zp(r))) 58 58 { 59 setCharacteristic( n_GetChar(r>cf) );59 setCharacteristic( rChar(r) ); 60 60 CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g, r ) ); 61 61 res=convFactoryPSingP( gcd( F, G ) , r); … … 65 65 { 66 66 if ( rField_is_Q_a(r)) setCharacteristic( 0 ); 67 else setCharacteristic(  n_GetChar(r) );68 if (r> minpoly!=NULL)67 else setCharacteristic( rChar(r) ); 68 if (r>cf>algring>minideal!=NULL) 69 69 { 70 70 bool b1=isOn(SW_USE_QGCD); 71 71 bool b2=isOn(SW_USE_fieldGCD); 72 if ( rField_is_Q_a( ) ) On(SW_USE_QGCD);72 if ( rField_is_Q_a(r) ) On(SW_USE_QGCD); 73 73 else On(SW_USE_fieldGCD); 74 CanonicalForm mipo=convSingPFactoryP( ((lnumber)r>minpoly)>z,75 r> algring);74 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 75 r>cf>algring); 76 76 Variable a=rootOf(mipo); 77 77 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), 78 78 G( convSingAPFactoryAP( g,a,r ) ); 79 res= convFactoryAPSingAP( gcd( F, G ), currRing);79 res= convFactoryAPSingAP( gcd( F, G ),r ); 80 80 if (!b1) Off(SW_USE_QGCD); 81 81 if (!b2) Off(SW_USE_fieldGCD); … … 106 106 } 107 107 108 poly singclap_gcd ( poly f, poly g 108 poly singclap_gcd ( poly f, poly g, const ring r) 109 109 { 110 110 poly res=NULL; 111 111 112 if (f!=NULL) p_Cleardenom(f, currRing);113 if (g!=NULL) p_Cleardenom(g, currRing);112 if (f!=NULL) p_Cleardenom(f, r); 113 if (g!=NULL) p_Cleardenom(g, r); 114 114 else return f; // g==0 => gcd=f (but do a p_Cleardenom) 115 115 if (f==NULL) return g; // f==0 => gcd=g (but do a p_Cleardenom) 116 116 117 res=singclap_gcd_r(f,g, currRing);118 p Delete(&f);119 p Delete(&g);117 res=singclap_gcd_r(f,g,r); 118 p_Delete(&f, r); 119 p_Delete(&g, r); 120 120 return res; 121 121 } 122 122 123 123 /*2 find the maximal exponent of var(i) in poly p*/ 124 int pGetExp_Var(poly p, int i )124 int pGetExp_Var(poly p, int i, const ring r) 125 125 { 126 126 int m=0; … … 128 128 while (p!=NULL) 129 129 { 130 mm=p GetExp(p,i);130 mm=p_GetExp(p,i,r); 131 131 if (mm>m) m=mm; 132 132 pIter(p); … … 136 136 137 137 // destroys f,g,x 138 poly singclap_resultant ( poly f, poly g , poly x )138 poly singclap_resultant ( poly f, poly g , poly x, const ring r) 139 139 { 140 140 poly res=NULL; 141 int i=p IsPurePower(x);141 int i=p_IsPurePower(x, r); 142 142 if (i==0) 143 143 { … … 149 149 // for now there is only the possibility to handle polynomials over 150 150 // Q and Fp ... 151 if (rField_is_Zp( )  rField_is_Q())151 if (rField_is_Zp(r)  rField_is_Q(r)) 152 152 { 153 153 Variable X(i); 154 setCharacteristic( nGetChar() );155 CanonicalForm F( convSingPFactoryP( f ) ), G( convSingPFactoryP( g) );156 res=convFactoryPSingP( resultant( F, G, X ) );154 setCharacteristic( rChar(r) ); 155 CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) ); 156 res=convFactoryPSingP( resultant( F, G, X ), r ); 157 157 Off(SW_RATIONAL); 158 158 goto resultant_returns_res; 159 159 } 160 160 // and over Q(a) / Fp(a) 161 else if (rField_is_Extension( ))162 { 163 if (rField_is_Q_a( )) setCharacteristic( 0 );164 else setCharacteristic(  nGetChar() );165 Variable X(i+rPar( currRing));166 if ( currRing>minpoly!=NULL)161 else if (rField_is_Extension(r)) 162 { 163 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 164 else setCharacteristic(  rChar(r) ); 165 Variable X(i+rPar(r)); 166 if (r>cf>algring>minideal!=NULL) 167 167 { 168 168 //Variable X(i); 169 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,170 currRing>algring);169 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 170 r>cf>algring); 171 171 Variable a=rootOf(mipo); 172 CanonicalForm F( convSingAPFactoryAP( f,a, currRing) ),173 G( convSingAPFactoryAP( g,a, currRing) );174 res= convFactoryAPSingAP( resultant( F, G, X ), currRing);172 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), 173 G( convSingAPFactoryAP( g,a,r ) ); 174 res= convFactoryAPSingAP( resultant( F, G, X ),r ); 175 175 } 176 176 else … … 178 178 //Variable X(i+rPar(currRing)); 179 179 number nf,ng; 180 p_Cleardenom_n(f, currRing,nf);p_Cleardenom_n(g, currRing,ng);180 p_Cleardenom_n(f, r,nf);p_Cleardenom_n(g, r,ng); 181 181 int ef,eg; 182 ef=pGetExp_Var(f,i );183 eg=pGetExp_Var(g,i );184 CanonicalForm F( convSingTrPFactoryP( f ) ), G( convSingTrPFactoryP( g) );185 res= convFactoryPSingTrP( resultant( F, G, X ) );186 if ((nf!=NULL)&&(!n IsOne(nf))&&(!nIsZero(nf)))187 { 188 number n=n Invers(nf);182 ef=pGetExp_Var(f,i,r); 183 eg=pGetExp_Var(g,i,r); 184 CanonicalForm F( convSingTrPFactoryP( f, r ) ), G( convSingTrPFactoryP( g, r ) ); 185 res= convFactoryPSingTrP( resultant( F, G, X ), r ); 186 if ((nf!=NULL)&&(!n_IsOne(nf,r>cf))&&(!n_IsZero(nf,r>cf))) 187 { 188 number n=n_Invers(nf,r>cf); 189 189 while(eg>0) 190 190 { 191 res=p Mult_nn(res,n);191 res=p_Mult_nn(res,n,r); 192 192 eg; 193 193 } 194 n Delete(&n);195 } 196 n Delete(&nf);197 if ((ng!=NULL)&&(!n IsOne(ng))&&(!nIsZero(ng)))198 { 199 number n=n Invers(ng);194 n_Delete(&n,r>cf); 195 } 196 n_Delete(&nf, r>cf); 197 if ((ng!=NULL)&&(!n_IsOne(ng, r>cf))&&(!n_IsZero(ng,r>cf))) 198 { 199 number n=n_Invers(ng,r>cf); 200 200 while(ef>0) 201 201 { 202 res=p Mult_nn(res,n);202 res=p_Mult_nn(res,n,r); 203 203 ef; 204 204 } 205 n Delete(&n);206 } 207 n Delete(&ng);205 n_Delete(&n,r>cf); 206 } 207 n_Delete(&ng,r>cf); 208 208 } 209 209 Off(SW_RATIONAL); … … 213 213 WerrorS( feNotImplemented ); 214 214 resultant_returns_res: 215 p Delete(&f);216 p Delete(&g);217 p Delete(&x);215 p_Delete(&f,r); 216 p_Delete(&g,r); 217 p_Delete(&x,r); 218 218 return res; 219 219 } … … 278 278 //} 279 279 280 BOOLEAN singclap_extgcd ( poly f, poly g, poly &res, poly &pa, poly &pb )280 BOOLEAN singclap_extgcd ( poly f, poly g, poly &res, poly &pa, poly &pb , const ring r) 281 281 { 282 282 // for now there is only the possibility to handle univariate … … 285 285 res=NULL;pa=NULL;pb=NULL; 286 286 On(SW_SYMMETRIC_FF); 287 if (rField_is_Zp( )  rField_is_Q())288 { 289 setCharacteristic( nGetChar() );290 CanonicalForm F( convSingPFactoryP( f ) ), G( convSingPFactoryP( g) );287 if (rField_is_Zp(r)  rField_is_Q(r)) 288 { 289 setCharacteristic( rChar(r) ); 290 CanonicalForm F( convSingPFactoryP( f, r ) ), G( convSingPFactoryP( g, r ) ); 291 291 CanonicalForm FpG=F+G; 292 292 if (!(FpG.isUnivariate() FpG.inCoeffDomain())) … … 299 299 CanonicalForm Fa,Gb; 300 300 On(SW_RATIONAL); 301 res=convFactoryPSingP( extgcd( F, G, Fa, Gb ) );302 pa=convFactoryPSingP(Fa );303 pb=convFactoryPSingP(Gb );301 res=convFactoryPSingP( extgcd( F, G, Fa, Gb ), r ); 302 pa=convFactoryPSingP(Fa, r); 303 pb=convFactoryPSingP(Gb, r); 304 304 Off(SW_RATIONAL); 305 305 } 306 306 // and over Q(a) / Fp(a) 307 else if (rField_is_Extension( ))308 { 309 if (rField_is_Q_a( )) setCharacteristic( 0 );310 else setCharacteristic(  nGetChar() );307 else if (rField_is_Extension(r)) 308 { 309 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 310 else setCharacteristic(  rChar(r) ); 311 311 CanonicalForm Fa,Gb; 312 if ( currRing>minpoly!=NULL)313 { 314 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,315 currRing>algring);312 if (r>cf>algring>minideal!=NULL) 313 { 314 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 315 r>cf>algring); 316 316 Variable a=rootOf(mipo); 317 CanonicalForm F( convSingAPFactoryAP( f,a, currRing) ),318 G( convSingAPFactoryAP( g,a, currRing) );317 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), 318 G( convSingAPFactoryAP( g,a,r ) ); 319 319 CanonicalForm FpG=F+G; 320 320 if (!(FpG.isUnivariate() FpG.inCoeffDomain())) … … 324 324 return TRUE; 325 325 } 326 res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ), currRing);327 pa=convFactoryAPSingAP(Fa, currRing);328 pb=convFactoryAPSingAP(Gb, currRing);326 res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ),r ); 327 pa=convFactoryAPSingAP(Fa,r); 328 pb=convFactoryAPSingAP(Gb,r); 329 329 } 330 330 else 331 331 { 332 CanonicalForm F( convSingTrPFactoryP( f ) ), G( convSingTrPFactoryP( g) );332 CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) ); 333 333 CanonicalForm FpG=F+G; 334 334 if (!(FpG.isUnivariate() FpG.inCoeffDomain())) … … 339 339 return TRUE; 340 340 } 341 res= convFactoryPSingTrP( extgcd( F, G, Fa, Gb ) );342 pa=convFactoryPSingTrP(Fa );343 pb=convFactoryPSingTrP(Gb );341 res= convFactoryPSingTrP( extgcd( F, G, Fa, Gb ),r ); 342 pa=convFactoryPSingTrP(Fa,r); 343 pb=convFactoryPSingTrP(Gb,r); 344 344 } 345 345 Off(SW_RATIONAL); … … 353 353 // checking the result of extgcd: 354 354 poly dummy; 355 dummy=p Sub(pAdd(pMult(pCopy(f),pCopy(pa)),pMult(pCopy(g),pCopy(pb))),pCopy(res));355 dummy=p_Sub(p_Add_q(pp_Mult_qq(f,pa,r),pp_Mult_qq(g,pb,r),r),p_Copy(res,r),r); 356 356 if (dummy!=NULL) 357 357 { 358 PrintS("extgcd( ");p Write(f);pWrite0(g);PrintS(" )\n");359 PrintS("gcd, cofactors:");p Write(res); pWrite(pa);pWrite(pb);360 p Delete(&dummy);358 PrintS("extgcd( ");p_Write(f,r);p_Write0(g,r);PrintS(" )\n"); 359 PrintS("gcd, cofactors:");p_Write(res,r); p_Write(pa,r);p_Write(pb,r); 360 p_Delete(&dummy,r); 361 361 } 362 362 #endif … … 373 373 if ( rField_is_Q(r)  rField_is_Zp(r) ) 374 374 { 375 setCharacteristic( n_GetChar(r) );375 setCharacteristic( rChar(r) ); 376 376 CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r) ); 377 377 CanonicalForm FpG=F+G; … … 394 394 { 395 395 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 396 else setCharacteristic(  n_GetChar(r) );396 else setCharacteristic(  rChar(r) ); 397 397 CanonicalForm Fa,Gb; 398 if (r> minpoly!=NULL)399 { 400 CanonicalForm mipo=convSingPFactoryP( ((lnumber)r>minpoly)>z,401 r>algring);398 if (r>cf>algring>minideal!=NULL) 399 { 400 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 401 r>cf>algring); 402 402 Variable a=rootOf(mipo); 403 403 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), … … 410 410 return TRUE; 411 411 } 412 res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ), currRing);413 pa=convFactoryAPSingAP(Fa, currRing);414 pb=convFactoryAPSingAP(Gb, currRing);412 res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ),r ); 413 pa=convFactoryAPSingAP(Fa,r); 414 pb=convFactoryAPSingAP(Gb,r); 415 415 } 416 416 else … … 439 439 } 440 440 441 poly singclap_pdivide ( poly f, poly g )441 poly singclap_pdivide ( poly f, poly g, const ring r ) 442 442 { 443 443 poly res=NULL; 444 444 On(SW_RATIONAL); 445 if (rField_is_Zp( )  rField_is_Q())446 { 447 setCharacteristic( nGetChar() );448 CanonicalForm F( convSingPFactoryP( f ) ), G( convSingPFactoryP( g) );449 res = convFactoryPSingP( F / G );450 } 451 else if (rField_is_Extension( ))452 { 453 if (rField_is_Q_a( )) setCharacteristic( 0 );454 else setCharacteristic(  nGetChar() );455 if ( currRing>minpoly!=NULL)456 { 457 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,458 currRing>algring);445 if (rField_is_Zp(r)  rField_is_Q(r)) 446 { 447 setCharacteristic( rChar(r) ); 448 CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r ) ); 449 res = convFactoryPSingP( F / G, r ); 450 } 451 else if (rField_is_Extension(r)) 452 { 453 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 454 else setCharacteristic(  rChar(r) ); 455 if (r>cf>algring>minideal!=NULL) 456 { 457 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 458 r>cf>algring); 459 459 Variable a=rootOf(mipo); 460 CanonicalForm F( convSingAPFactoryAP( f,a, currRing) ),461 G( convSingAPFactoryAP( g,a, currRing) );462 res= convFactoryAPSingAP( F / G, currRing);460 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), 461 G( convSingAPFactoryAP( g,a,r ) ); 462 res= convFactoryAPSingAP( F / G,r ); 463 463 } 464 464 else 465 465 { 466 CanonicalForm F( convSingTrPFactoryP( f ) ), G( convSingTrPFactoryP( g) );467 res= convFactoryPSingTrP( F / G );466 CanonicalForm F( convSingTrPFactoryP( f,r ) ), G( convSingTrPFactoryP( g,r ) ); 467 res= convFactoryPSingTrP( F / G,r ); 468 468 } 469 469 } … … 489 489 if (rField_is_Zp(r)  rField_is_Q(r)) 490 490 { 491 setCharacteristic( n_GetChar(r) );491 setCharacteristic( rChar(r) ); 492 492 CanonicalForm F( convSingPFactoryP( f,r ) ), G( convSingPFactoryP( g,r ) ); 493 493 res = convFactoryPSingP( F / G,r ); … … 496 496 { 497 497 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 498 else setCharacteristic(  n_GetChar(r) );499 if (r> minpoly!=NULL)500 { 501 CanonicalForm mipo=convSingPFactoryP( ((lnumber)r>minpoly)>z,502 r>algring);498 else setCharacteristic(  rChar(r) ); 499 if (r>cf>algring>minideal!=NULL) 500 { 501 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 502 r>cf>algring); 503 503 Variable a=rootOf(mipo); 504 504 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ), … … 527 527 } 528 528 529 void singclap_divide_content ( poly f )529 void singclap_divide_content ( poly f, const ring r ) 530 530 { 531 531 if ( f==NULL ) … … 535 535 else if ( pNext( f ) == NULL ) 536 536 { 537 p SetCoeff( f, nInit( 1 ));537 p_SetCoeff( f, n_Init( 1, r>cf ), r ); 538 538 return; 539 539 } 540 540 else 541 541 { 542 if ( rField_is_Q_a( ) )542 if ( rField_is_Q_a(r) ) 543 543 setCharacteristic( 0 ); 544 else if ( rField_is_Zp_a( ) )545 setCharacteristic(  nGetChar() );544 else if ( rField_is_Zp_a(r) ) 545 setCharacteristic( rChar(r) ); 546 546 else 547 547 return; /* not implemented*/ … … 556 556 number g2=pGetCoeff(p); // p==pNext(f); 557 557 pIter(p); 558 int sz1=n Size(g1);559 int sz2=n Size(g2);558 int sz1=n_Size(g1, r>cf); 559 int sz2=n_Size(g2, r>cf); 560 560 if (sz1>sz2) 561 561 { … … 567 567 while (p!=NULL) 568 568 { 569 int n_sz=n Size(pGetCoeff(p));569 int n_sz=n_Size(pGetCoeff(p),r>cf); 570 570 if (n_sz<sz1) 571 571 { … … 584 584 pIter(p); 585 585 } 586 g = convSingPFactoryP( ((lnumber)g1)>z, currRing>algring );587 g = gcd( g, convSingPFactoryP( ((lnumber)g2)>z , currRing>algring));586 g = convSingPFactoryP( ((lnumber)g1)>z, r>cf>algring ); 587 g = gcd( g, convSingPFactoryP( ((lnumber)g2)>z , r>cf>algring)); 588 588 589 589 // second run: gcd's … … 592 592 while ( (p != NULL) && (g != 1) && ( g != 0)) 593 593 { 594 h = convSingPFactoryP( ((lnumber)pGetCoeff(p))>z, currRing>algring );594 h = convSingPFactoryP( ((lnumber)pGetCoeff(p))>z, r>cf>algring ); 595 595 pIter( p ); 596 596 … … 610 610 { 611 611 lnumber c=(lnumber)pGetCoeff(p); 612 p_Delete(&c>z, currRing>algring); // 2nd arg used to be nacRing613 c>z=convFactoryPSingP( i.getItem() / g, currRing>algring );612 p_Delete(&c>z,r>cf>algring); // 2nd arg used to be nacRing 613 c>z=convFactoryPSingP( i.getItem() / g, r>cf>algring ); 614 614 //nTest((number)c); 615 615 //#ifdef LDEBUG … … 624 624 } 625 625 626 BOOLEAN count_Factors(ideal I, intvec *v,int j, poly &f, poly fac) 627 { 628 pTest(f); 629 pTest(fac); 626 static int primepower(int c, const ring r) 627 { 628 int p=1; 629 int cc=c; 630 while(cc!= rChar(r)) { cc*=c; p++; } 631 return p; 632 } 633 634 BOOLEAN count_Factors(ideal I, intvec *v,int j, poly &f, poly fac, const ring r) 635 { 636 p_Test(f,r); 637 p_Test(fac,r); 630 638 int e=0; 631 if (!p IsConstantPoly(fac))639 if (!p_IsConstantPoly(fac,r)) 632 640 { 633 641 #ifdef FACTORIZE2_DEBUG … … 638 646 CanonicalForm F, FAC,Q,R; 639 647 Variable a; 640 if (rField_is_Zp( )  rField_is_Q())641 { 642 F=convSingPFactoryP( f );643 FAC=convSingPFactoryP( fac );644 } 645 else if (rField_is_Extension( ))646 { 647 if ( currRing>minpoly!=NULL)648 { 649 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,650 currRing>algring);648 if (rField_is_Zp(r)  rField_is_Q(r)) 649 { 650 F=convSingPFactoryP( f,r ); 651 FAC=convSingPFactoryP( fac,r ); 652 } 653 else if (rField_is_Extension(r)) 654 { 655 if (r>cf>algring>minideal!=NULL) 656 { 657 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 658 r>cf>algring); 651 659 a=rootOf(mipo); 652 F=convSingAPFactoryAP( f,a, currRing);653 FAC=convSingAPFactoryAP( fac,a, currRing);660 F=convSingAPFactoryAP( f,a,r ); 661 FAC=convSingAPFactoryAP( fac,a,r ); 654 662 } 655 663 else 656 664 { 657 F=convSingTrPFactoryP( f );658 FAC=convSingTrPFactoryP( fac );665 F=convSingTrPFactoryP( f,r ); 666 FAC=convSingTrPFactoryP( fac,r ); 659 667 } 660 668 } … … 672 680 if (R.isZero()) 673 681 { 674 if (rField_is_Zp( )  rField_is_Q())682 if (rField_is_Zp(r)  rField_is_Q(r)) 675 683 { 676 q = convFactoryPSingP( Q );684 q = convFactoryPSingP( Q,r ); 677 685 } 678 else if (rField_is_Extension( ))686 else if (rField_is_Extension(r)) 679 687 { 680 if ( currRing>minpoly!=NULL)688 if (r>cf>algring>minideal!=NULL) 681 689 { 682 q= convFactoryAPSingAP( Q, currRing);690 q= convFactoryAPSingAP( Q,r ); 683 691 } 684 692 else 685 693 { 686 q= convFactoryPSingTrP( Q );694 q= convFactoryPSingTrP( Q,r ); 687 695 } 688 696 } 689 e++; p Delete(&f); f=q; q=NULL; F=Q;697 e++; p_Delete(&f,r); f=q; q=NULL; F=Q; 690 698 } 691 699 else … … 710 718 extern int libfac_interruptflag; 711 719 712 ideal singclap_factorize ( poly f, intvec ** v , int with_exps )720 ideal singclap_factorize ( poly f, intvec ** v , int with_exps, const ring r) 713 721 /* destroys f, sets *v */ 714 722 { 715 p Test(f);723 p_Test(f,r); 716 724 #ifdef FACTORIZE2_DEBUG 717 725 printf("singclap_factorize, degree %ld\n",pTotaldegree(f)); … … 741 749 int n=0; 742 750 int e; 743 for(i= pVariables;i>0;i) if(pGetExp(f,i)!=0) n++;751 for(i=rVar(r);i>0;i) if(p_GetExp(f,i,r)!=0) n++; 744 752 if (with_exps==0) n++; // with coeff 745 753 res=idInit(si_max(n,1),1); … … 747 755 { 748 756 case 0: // with coef & exp. 749 res>m[0]=p NSet(nCopy(pGetCoeff(f)));757 res>m[0]=p_NSet(n_Copy(pGetCoeff(f),r>cf),r); 750 758 // no break 751 759 case 2: // with exp. … … 760 768 if (n==0) 761 769 { 762 res>m[0]=p One();770 res>m[0]=p_One(r); 763 771 // (**v)[0]=1; is already done 764 772 } 765 773 else 766 774 { 767 for(i= pVariables;i>0;i)768 { 769 e=p GetExp(f,i);775 for(i=rVar(r);i>0;i) 776 { 777 e=p_GetExp(f,i,r); 770 778 if(e!=0) 771 779 { 772 780 n; 773 poly p=p One();774 p SetExp(p,i,1);775 p Setm(p);781 poly p=p_One(r); 782 p_SetExp(p,i,1,r); 783 p_Setm(p,r); 776 784 res>m[n]=p; 777 785 if (with_exps!=1) (**v)[n]=e; … … 779 787 } 780 788 } 781 p Delete(&f);789 p_Delete(&f,r); 782 790 return res; 783 791 } … … 788 796 #ifdef HAVE_NTL 789 797 extern int prime_number; 790 if(rField_is_Q( )) prime_number=0;798 if(rField_is_Q(r)) prime_number=0; 791 799 #endif 792 800 CFFList L; 793 801 number N=NULL; 794 802 number NN=NULL; 795 number old_lead_coeff=n Copy(pGetCoeff(f));796 797 if (!rField_is_Zp( ) && !rField_is_Zp_a()) /* Q, Q(a) */803 number old_lead_coeff=n_Copy(pGetCoeff(f), r>cf); 804 805 if (!rField_is_Zp(r) && !rField_is_Zp_a(r)) /* Q, Q(a) */ 798 806 { 799 807 //if (f!=NULL) // already tested at start of routine 800 808 { 801 number n0=n Copy(pGetCoeff(f));809 number n0=n_Copy(pGetCoeff(f),r>cf); 802 810 if (with_exps==0) 803 N=n Copy(n0);804 p_Cleardenom(f, currRing);805 NN=n Div(n0,pGetCoeff(f));806 n Delete(&n0);811 N=n_Copy(n0,r>cf); 812 p_Cleardenom(f, r); 813 NN=n_Div(n0,pGetCoeff(f),r>cf); 814 n_Delete(&n0,r>cf); 807 815 if (with_exps==0) 808 816 { 809 n Delete(&N);810 N=n Copy(NN);811 } 812 } 813 } 814 else if (rField_is_Zp_a( ))817 n_Delete(&N,r>cf); 818 N=n_Copy(NN,r>cf); 819 } 820 } 821 } 822 else if (rField_is_Zp_a(r)) 815 823 { 816 824 //if (f!=NULL) // already tested at start of routine 817 825 if (singclap_factorize_retry==0) 818 826 { 819 number n0=n Copy(pGetCoeff(f));827 number n0=n_Copy(pGetCoeff(f),r>cf); 820 828 if (with_exps==0) 821 N=n Copy(n0);822 p Norm(f);823 p_Cleardenom(f, currRing);824 NN=n Div(n0,pGetCoeff(f));825 n Delete(&n0);829 N=n_Copy(n0,r>cf); 830 p_Norm(f,r); 831 p_Cleardenom(f, r); 832 NN=n_Div(n0,pGetCoeff(f),r>cf); 833 n_Delete(&n0,r>cf); 826 834 if (with_exps==0) 827 835 { 828 n Delete(&N);829 N=n Copy(NN);830 } 831 } 832 } 833 if (rField_is_Q( )  rField_is_Zp())834 { 835 setCharacteristic( nGetChar() );836 CanonicalForm F( convSingPFactoryP( f ) );836 n_Delete(&N,r>cf); 837 N=n_Copy(NN,r>cf); 838 } 839 } 840 } 841 if (rField_is_Q(r)  rField_is_Zp(r)) 842 { 843 setCharacteristic( rChar(r) ); 844 CanonicalForm F( convSingPFactoryP( f,r ) ); 837 845 L = factorize( F ); 838 846 } … … 854 862 #endif 855 863 // and over Q(a) / Fp(a) 856 else if (rField_is_Extension( ))857 { 858 if (rField_is_Q_a( )) setCharacteristic( 0 );859 else setCharacteristic(  nGetChar() );860 if ( currRing>minpoly!=NULL)861 { 862 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,863 currRing>algring);864 else if (rField_is_Extension(r)) 865 { 866 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 867 else setCharacteristic( rChar(r) ); 868 if (r>cf>algring>minideal!=NULL) 869 { 870 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 871 r>cf>algring); 864 872 Variable a=rootOf(mipo); 865 CanonicalForm F( convSingAPFactoryAP( f,a, currRing) );866 if (rField_is_Zp_a( ))873 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ); 874 if (rField_is_Zp_a(r)) 867 875 { 868 876 L = factorize( F, a ); … … 876 884 else 877 885 { 878 CanonicalForm F( convSingTrPFactoryP( f ) );886 CanonicalForm F( convSingTrPFactoryP( f,r ) ); 879 887 L = factorize( F ); 880 888 } … … 885 893 } 886 894 { 887 poly ff=p Copy(f); // a copy for the retry stuff895 poly ff=p_Copy(f,r); // a copy for the retry stuff 888 896 // the first factor should be a constant 889 897 if ( ! L.getFirst().factor().inCoeffDomain() ) … … 907 915 { 908 916 if (with_exps!=1) (**v)[j] = J.getItem().exp(); 909 if (rField_is_Zp( )  rField_is_Q()) /* Q, Fp */917 if (rField_is_Zp(r)  rField_is_Q(r)) /* Q, Fp */ 910 918 { 911 919 //count_Factors(res,*v,f, j, convFactoryPSingP( J.getItem().factor() ); 912 res>m[j] = convFactoryPSingP( J.getItem().factor() );920 res>m[j] = convFactoryPSingP( J.getItem().factor(),r ); 913 921 } 914 922 #if 0 … … 916 924 res>m[j] = convFactoryGFSingGF( J.getItem().factor() ); 917 925 #endif 918 else if (rField_is_Extension( )) /* Q(a), Fp(a) */926 else if (rField_is_Extension(r)) /* Q(a), Fp(a) */ 919 927 { 920 928 intvec *w=NULL; 921 929 if (v!=NULL) w=*v; 922 if ( currRing>minpoly==NULL)930 if (r>cf>algring>minideal==NULL) 923 931 { 924 if(!count_Factors(res,w,j,ff,convFactoryPSingTrP( J.getItem().factor() )))932 if(!count_Factors(res,w,j,ff,convFactoryPSingTrP( J.getItem().factor(),r ),r)) 925 933 { 926 934 if (w!=NULL) 927 935 (*w)[j]=1; 928 res>m[j]=p One();936 res>m[j]=p_One(r); 929 937 } 930 938 } 931 939 else 932 940 { 933 if (!count_Factors(res,w,j,ff,convFactoryAPSingAP( J.getItem().factor(), currRing )))941 if (!count_Factors(res,w,j,ff,convFactoryAPSingAP( J.getItem().factor(),r ),r)) 934 942 { 935 943 if (w!=NULL) 936 944 (*w)[j]=1; 937 res>m[j]=p One();945 res>m[j]=p_One(r); 938 946 } 939 947 } 940 948 } 941 949 } 942 if (rField_is_Extension( ) && (!pIsConstantPoly(ff)))950 if (rField_is_Extension(r) && (!p_IsConstantPoly(ff,r))) 943 951 { 944 952 singclap_factorize_retry++; … … 950 958 #endif 951 959 intvec *ww=NULL; 952 id Test(res);953 ideal h=singclap_factorize ( ff, &ww , with_exps );954 id Test(h);960 id_Test(res,r); 961 ideal h=singclap_factorize ( ff, &ww , with_exps, r ); 962 id_Test(h,r); 955 963 int l=(*v)>length(); 956 964 (*v)>resize(l+ww>length()); … … 969 977 h>m[jj]=NULL; 970 978 } 971 id Delete(&res);972 id Delete(&h);979 id_Delete(&res,r); 980 id_Delete(&h,r); 973 981 res=hh; 974 id Test(res);982 id_Test(res,r); 975 983 ff=NULL; 976 984 } … … 982 990 idShow(res); 983 991 #endif 984 id Delete(&res);992 id_Delete(&res,r); 985 993 res=idInit(2,1); 986 res>m[0]=p One();994 res>m[0]=p_One(r); 987 995 res>m[1]=ff; ff=NULL; 988 996 } 989 997 } 990 p Delete(&ff);998 p_Delete(&ff,r); 991 999 if (N!=NULL) 992 1000 { 993 p Mult_nn(res>m[0],N);994 n Delete(&N);1001 p_Mult_nn(res>m[0],N,r); 1002 n_Delete(&N,r>cf); 995 1003 N=NULL; 996 1004 } … … 1004 1012 if ((res>m[i]!=NULL) 1005 1013 && (pNext(res>m[i])==NULL) 1006 && (p IsConstant(res>m[i])))1014 && (p_IsConstant(res>m[i],r))) 1007 1015 { 1008 1016 if (with_exps!=0) 1009 1017 { 1010 p Delete(&(res>m[i]));1018 p_Delete(&(res>m[i]),r); 1011 1019 if ((v!=NULL) && ((*v)!=NULL)) 1012 1020 (**v)[i]=0; … … 1017 1025 while ((v!=NULL) && ((*v)!=NULL) && ((**v)[i]>1)) 1018 1026 { 1019 res>m[0]=p Mult(res>m[0],pCopy(res>m[i]));1027 res>m[0]=p_Mult_q(res>m[0],p_Copy(res>m[i],r),r); 1020 1028 (**v)[i]; 1021 1029 } 1022 res>m[0]=p Mult(res>m[0],res>m[i]);1030 res>m[0]=p_Mult_q(res>m[0],res>m[i],r); 1023 1031 res>m[i]=NULL; 1024 1032 if ((v!=NULL) && ((*v)!=NULL)) … … 1048 1056 if (res>m[0]==NULL) 1049 1057 { 1050 res>m[0]=p One();1051 } 1052 } 1053 } 1054 if (rField_is_Q_a( ) && (currRing>minpoly!=NULL))1058 res>m[0]=p_One(r); 1059 } 1060 } 1061 } 1062 if (rField_is_Q_a(r) && (r>cf>algring>minideal!=NULL)) 1055 1063 { 1056 1064 int i=IDELEMS(res)1; … … 1059 1067 for(;i>=stop;i) 1060 1068 { 1061 p Norm(res>m[i]);1062 } 1063 if (with_exps==0) p SetCoeff(res>m[0],old_lead_coeff);1064 else n Delete(&old_lead_coeff);1069 p_Norm(res>m[i],r); 1070 } 1071 if (with_exps==0) p_SetCoeff(res>m[0],old_lead_coeff,r); 1072 else n_Delete(&old_lead_coeff,r>cf); 1065 1073 } 1066 1074 else 1067 n Delete(&old_lead_coeff);1075 n_Delete(&old_lead_coeff,r>cf); 1068 1076 errorreported=save_errorreported; 1069 1077 notImpl: … … 1072 1080 if (NN!=NULL) 1073 1081 { 1074 n Delete(&NN);1082 n_Delete(&NN,r>cf); 1075 1083 } 1076 1084 if (N!=NULL) 1077 1085 { 1078 n Delete(&N);1079 } 1080 if (f!=NULL) p Delete(&f);1086 n_Delete(&N,r>cf); 1087 } 1088 if (f!=NULL) p_Delete(&f,r); 1081 1089 //PrintS("......S\n"); 1082 1090 return res; 1083 1091 } 1084 ideal singclap_sqrfree ( poly f )1085 { 1086 p Test(f);1092 ideal singclap_sqrfree ( poly f, const ring r) 1093 { 1094 p_Test(f,r); 1087 1095 #ifdef FACTORIZE2_DEBUG 1088 1096 printf("singclap_sqrfree, degree %d\n",pTotaldegree(f)); … … 1107 1115 int n=0; 1108 1116 int e; 1109 for(i= pVariables;i>0;i) if(pGetExp(f,i)!=0) n++;1117 for(i=rVar(r);i>0;i) if(p_GetExp(f,i,r)!=0) n++; 1110 1118 n++; // with coeff 1111 1119 res=idInit(si_max(n,1),1); 1112 res>m[0]=p NSet(nCopy(pGetCoeff(f)));1120 res>m[0]=p_NSet(n_Copy(pGetCoeff(f),r>cf),r); 1113 1121 if (n==0) 1114 1122 { 1115 res>m[0]=p One();1123 res>m[0]=p_One(r); 1116 1124 // (**v)[0]=1; is already done 1117 1125 return res; 1118 1126 } 1119 for(i= pVariables;i>0;i)1120 { 1121 e=p GetExp(f,i);1127 for(i=rVar(r);i>0;i) 1128 { 1129 e=p_GetExp(f,i,r); 1122 1130 if(e!=0) 1123 1131 { 1124 1132 n; 1125 poly p=p One();1126 p SetExp(p,i,1);1127 p Setm(p);1133 poly p=p_One(r); 1134 p_SetExp(p,i,1,r); 1135 p_Setm(p,r); 1128 1136 res>m[n]=p; 1129 1137 } … … 1137 1145 #ifdef HAVE_NTL 1138 1146 extern int prime_number; 1139 if(rField_is_Q( )) prime_number=0;1147 if(rField_is_Q(r)) prime_number=0; 1140 1148 #endif 1141 1149 CFFList L; 1142 1150 1143 if (!rField_is_Zp( ) && !rField_is_Zp_a()) /* Q, Q(a) */1151 if (!rField_is_Zp(r) && !rField_is_Zp_a(r)) /* Q, Q(a) */ 1144 1152 { 1145 1153 //if (f!=NULL) // already tested at start of routine 1146 1154 { 1147 p_Cleardenom(f, currRing);1148 } 1149 } 1150 else if (rField_is_Zp_a( ))1155 p_Cleardenom(f, r); 1156 } 1157 } 1158 else if (rField_is_Zp_a(r)) 1151 1159 { 1152 1160 //if (f!=NULL) // already tested at start of routine 1153 1161 if (singclap_factorize_retry==0) 1154 1162 { 1155 p Norm(f);1156 p_Cleardenom(f, currRing);1157 } 1158 } 1159 if (rField_is_Q( )  rField_is_Zp())1160 { 1161 setCharacteristic( nGetChar() );1162 CanonicalForm F( convSingPFactoryP( f ) );1163 p_Norm(f,r); 1164 p_Cleardenom(f, r); 1165 } 1166 } 1167 if (rField_is_Q(r)  rField_is_Zp(r)) 1168 { 1169 setCharacteristic( rChar(r) ); 1170 CanonicalForm F( convSingPFactoryP( f,r ) ); 1163 1171 L = sqrFree( F ); 1164 1172 } … … 1166 1174 else if (rField_is_GF()) 1167 1175 { 1168 int c=rChar( currRing);1176 int c=rChar(r); 1169 1177 setCharacteristic( c, primepower(c) ); 1170 1178 CanonicalForm F( convSingGFFactoryGF( f ) ); … … 1180 1188 #endif 1181 1189 // and over Q(a) / Fp(a) 1182 else if (rField_is_Extension( ))1183 { 1184 if (rField_is_Q_a( )) setCharacteristic( 0 );1185 else setCharacteristic(  nGetChar() );1186 if ( currRing>minpoly!=NULL)1187 { 1188 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,1189 currRing>algring);1190 else if (rField_is_Extension(r)) 1191 { 1192 if (rField_is_Q_a(r)) setCharacteristic( 0 ); 1193 else setCharacteristic( rChar(r) ); 1194 if (r>cf>algring>minideal!=NULL) 1195 { 1196 CanonicalForm mipo=convSingPFactoryP(r>cf>algring>minideal>m[0], 1197 r>cf>algring); 1190 1198 Variable a=rootOf(mipo); 1191 CanonicalForm F( convSingAPFactoryAP( f,a, currRing) );1199 CanonicalForm F( convSingAPFactoryAP( f,a,r ) ); 1192 1200 CFFList SqrFreeMV( const CanonicalForm & f , const CanonicalForm & mipo=0) ; 1193 1201 … … 1198 1206 else 1199 1207 { 1200 CanonicalForm F( convSingTrPFactoryP( f ) );1208 CanonicalForm F( convSingTrPFactoryP( f,r ) ); 1201 1209 L = sqrFree( F ); 1202 1210 } … … 1215 1223 for ( ; J.hasItem(); J++, j++ ) 1216 1224 { 1217 if (rField_is_Zp( )  rField_is_Q()) /* Q, Fp */1225 if (rField_is_Zp(r)  rField_is_Q(r)) /* Q, Fp */ 1218 1226 //count_Factors(res,*v,f, j, convFactoryPSingP( J.getItem().factor() ); 1219 res>m[j] = convFactoryPSingP( J.getItem().factor() );1227 res>m[j] = convFactoryPSingP( J.getItem().factor(),r ); 1220 1228 #if 0 1221 1229 else if (rField_is_GF()) 1222 1230 res>m[j] = convFactoryGFSingGF( J.getItem().factor() ); 1223 1231 #endif 1224 else if (rField_is_Extension( )) /* Q(a), Fp(a) */1225 { 1226 if ( currRing>minpoly==NULL)1227 res>m[j]=convFactoryPSingTrP( J.getItem().factor() );1232 else if (rField_is_Extension(r)) /* Q(a), Fp(a) */ 1233 { 1234 if (r>cf>algring>minideal==NULL) 1235 res>m[j]=convFactoryPSingTrP( J.getItem().factor(),r ); 1228 1236 else 1229 res>m[j]=convFactoryAPSingAP( J.getItem().factor(), currRing);1237 res>m[j]=convFactoryAPSingAP( J.getItem().factor(),r ); 1230 1238 } 1231 1239 } 1232 1240 if (res>m[0]==NULL) 1233 1241 { 1234 res>m[0]=p One();1235 } 1236 } 1237 p Delete(&f);1242 res>m[0]=p_One(r); 1243 } 1244 } 1245 p_Delete(&f,r); 1238 1246 errorreported=save_errorreported; 1239 1247 notImpl: … … 1242 1250 return res; 1243 1251 } 1244 matrix singclap_irrCharSeries ( ideal I) 1252 1253 1254 TODO(somebody, add libfac) 1255 /*matrix singclap_irrCharSeries ( ideal I, const ring r) 1245 1256 { 1246 1257 if (idIs0(I)) return mpNew(1,1); … … 1254 1265 CFList L; 1255 1266 ListCFList LL; 1256 if ((( nGetChar() == 0)  (nGetChar() > 1) )1257 && ( currRing>parameter==NULL))1258 { 1259 setCharacteristic( nGetChar() );1267 if (((rChar(r) == 0)  (rChar(r) > 1) ) 1268 && (rPar(r)==0)) 1269 { 1270 setCharacteristic( rChar(r) ); 1260 1271 for(i=0;i<IDELEMS(I);i++) 1261 1272 { … … 1263 1274 if (p!=NULL) 1264 1275 { 1265 p=p Copy(p);1266 p_Cleardenom(p, currRing);1267 L.append(convSingPFactoryP(p ));1276 p=p_Copy(p,r); 1277 p_Cleardenom(p, r); 1278 L.append(convSingPFactoryP(p,r)); 1268 1279 } 1269 1280 } 1270 1281 } 1271 1282 // and over Q(a) / Fp(a) 1272 else if (( nGetChar()==1 ) /* Q(a) */1273  ( nGetChar() <1)) /* Fp(a) */1274 { 1275 if ( nGetChar()==1) setCharacteristic( 0 );1276 else setCharacteristic(  nGetChar() );1283 else if (( rChar(r)==1 ) // Q(a) 1284  (rChar(r) <1)) // Fp(a) 1285 { 1286 if (rChar(r)==1) setCharacteristic( 0 ); 1287 else setCharacteristic( rChar(r) ); 1277 1288 for(i=0;i<IDELEMS(I);i++) 1278 1289 { … … 1280 1291 if (p!=NULL) 1281 1292 { 1282 p=p Copy(p);1283 p_Cleardenom(p, currRing);1284 L.append(convSingTrPFactoryP(p ));1293 p=p_Copy(p,r); 1294 p_Cleardenom(p, r); 1295 L.append(convSingTrPFactoryP(p,r)); 1285 1296 } 1286 1297 } … … 1324 1335 for (n=1, Li = LLi.getItem(); Li.hasItem(); Li++, n++) 1325 1336 { 1326 if ( ( nGetChar() == 0)  (nGetChar() > 1) )1327 MATELEM(res,m,n)=convFactoryPSingP(Li.getItem() );1337 if ( (rChar(r) == 0)  (rChar(r) > 1) ) 1338 MATELEM(res,m,n)=convFactoryPSingP(Li.getItem(),r); 1328 1339 else 1329 MATELEM(res,m,n)=convFactoryPSingTrP(Li.getItem() );1340 MATELEM(res,m,n)=convFactoryPSingTrP(Li.getItem(),r); 1330 1341 } 1331 1342 } 1332 1343 Off(SW_RATIONAL); 1333 1344 return res; 1334 } 1335 1336 char* singclap_neworder ( ideal I)1345 }*/ 1346 1347 /*char* singclap_neworder ( ideal I, const ring r) 1337 1348 { 1338 1349 int i; … … 1340 1351 On(SW_SYMMETRIC_FF); 1341 1352 CFList L; 1342 if ((( nGetChar() == 0)  (nGetChar() > 1) )1343 && ( currRing>parameter==NULL))1344 { 1345 setCharacteristic( nGetChar() );1353 if (((rChar(r) == 0)  (rChar(r) > 1) ) 1354 && (rPar(r)==0)) 1355 { 1356 setCharacteristic( rChar(r) ); 1346 1357 for(i=0;i<IDELEMS(I);i++) 1347 1358 { 1348 L.append(convSingPFactoryP(I>m[i] ));1359 L.append(convSingPFactoryP(I>m[i],r)); 1349 1360 } 1350 1361 } 1351 1362 // and over Q(a) / Fp(a) 1352 else if (( nGetChar()==1 ) /* Q(a) */1353  ( nGetChar() <1)) /* Fp(a) */1354 { 1355 if ( nGetChar()==1) setCharacteristic( 0 );1356 else setCharacteristic(  nGetChar() );1363 else if (( rChar(r)==1 ) // Q(a) 1364  (rChar(r) <1)) // Fp(a) 1365 { 1366 if (rChar(r)==1) setCharacteristic( 0 ); 1367 else setCharacteristic( rChar(r) ); 1357 1368 for(i=0;i<IDELEMS(I);i++) 1358 1369 { 1359 L.append(convSingTrPFactoryP(I>m[i] ));1370 L.append(convSingTrPFactoryP(I>m[i],r)); 1360 1371 } 1361 1372 } … … 1370 1381 StringSetS(""); 1371 1382 Li = IL; 1372 int offs=rPar( currRing);1373 int* mark=(int*)omAlloc0(( pVariables+offs)*sizeof(int));1374 int cnt= pVariables+offs;1383 int offs=rPar(r); 1384 int* mark=(int*)omAlloc0((rVar(r)+offs)*sizeof(int)); 1385 int cnt=rVar(r)+offs; 1375 1386 loop 1376 1387 { … … 1382 1393 { 1383 1394 done=FALSE; 1384 //StringAppendS( currRing>parameter[i]);1395 //StringAppendS(r>parameter[i]); 1385 1396 } 1386 1397 else 1387 1398 { 1388 StringAppendS( currRing>names[ioffs]);1399 StringAppendS(r>names[ioffs]); 1389 1400 } 1390 1401 Li++; … … 1393 1404 if (done) StringAppendS(","); 1394 1405 } 1395 for(i=0;i< pVariables+offs;i++)1406 for(i=0;i<rVar(r)+offs;i++) 1396 1407 { 1397 1408 BOOLEAN done=TRUE; … … 1401 1412 { 1402 1413 done=FALSE; 1403 //StringAppendS( currRing>parameter[i]);1414 //StringAppendS(r>parameter[i]); 1404 1415 } 1405 1416 else 1406 1417 { 1407 StringAppendS( currRing>names[ioffs]);1418 StringAppendS(r>names[ioffs]); 1408 1419 } 1409 1420 cnt; … … 1415 1426 if (s[strlen(s)1]==',') s[strlen(s)1]='\0'; 1416 1427 return s; 1417 } 1418 1419 BOOLEAN singclap_isSqrFree(poly f )1428 }*/ 1429 1430 BOOLEAN singclap_isSqrFree(poly f, const ring r) 1420 1431 { 1421 1432 BOOLEAN b=FALSE; 1422 1433 Off(SW_RATIONAL); 1423 1434 // Q / Fp 1424 if ((( nGetChar() == 0)  (nGetChar() > 1) )1425 &&( currRing>parameter==NULL))1426 { 1427 setCharacteristic( nGetChar() );1428 CanonicalForm F( convSingPFactoryP( f ) );1429 if(( nGetChar()>1)&&(!F.isUnivariate()))1435 if (((rChar(r) == 0)  (rChar(r) > 1) ) 1436 &&(rPar(r)==0)) 1437 { 1438 setCharacteristic( rChar(r) ); 1439 CanonicalForm F( convSingPFactoryP( f,r ) ); 1440 if((rChar(r)>1)&&(!F.isUnivariate())) 1430 1441 goto err; 1431 1442 b=(BOOLEAN)isSqrFree(F); 1432 1443 } 1433 1444 // and over Q(a) / Fp(a) 1434 else if (( nGetChar()==1 ) /* Q(a) */1435  ( nGetChar() <1)) /* Fp(a) */1436 { 1437 if ( nGetChar()==1) setCharacteristic( 0 );1438 else setCharacteristic(  nGetChar() );1439 //if ( currRing>minpoly!=NULL)1445 else if (( rChar(r)==1 ) /* Q(a) */ 1446  (rChar(r) <1)) /* Fp(a) */ 1447 { 1448 if (rChar(r)==1) setCharacteristic( 0 ); 1449 else setCharacteristic( rChar(r) ); 1450 //if (r>minpoly!=NULL) 1440 1451 //{ 1441 // CanonicalForm mipo=convSingPFactoryP(((lnumber) currRing>minpoly)>z,1442 // currRing>algring);1452 // CanonicalForm mipo=convSingPFactoryP(((lnumber)r>minpoly)>z, 1453 // r>algring); 1443 1454 // Variable a=rootOf(mipo); 1444 1455 // CanonicalForm F( convSingAPFactoryAP( f,a ) ); … … 1447 1458 //else 1448 1459 { 1449 CanonicalForm F( convSingTrPFactoryP( f ) );1460 CanonicalForm F( convSingTrPFactoryP( f,r ) ); 1450 1461 b=(BOOLEAN)isSqrFree(F); 1451 1462 } … … 1460 1471 } 1461 1472 1462 poly singclap_det( const matrix m )1473 poly singclap_det( const matrix m, const ring s ) 1463 1474 { 1464 1475 int r=m>rows(); … … 1469 1480 } 1470 1481 poly res=NULL; 1471 if (( nGetChar() == 0  nGetChar()> 1 )1472 && ( currRing>parameter==NULL))1473 { 1474 setCharacteristic( nGetChar());1482 if (( s>cf>ch == 0  s>cf>ch > 1 ) 1483 && (rPar(s)==0)) 1484 { 1485 setCharacteristic( s>cf>ch ); 1475 1486 CFMatrix M(r,r); 1476 1487 int i,j; … … 1479 1490 for(j=r;j>0;j) 1480 1491 { 1481 M(i,j)=convSingPFactoryP(MATELEM(m,i,j) );1482 } 1483 } 1484 res= convFactoryPSingP( determinant(M,r) ) ;1492 M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s); 1493 } 1494 } 1495 res= convFactoryPSingP( determinant(M,r),s ) ; 1485 1496 } 1486 1497 // and over Q(a) / Fp(a) 1487 else if (( nGetChar()==1 ) /* Q(a) */1488  ( nGetChar()<1)) /* Fp(a) */1489 { 1490 if ( nGetChar()==1) setCharacteristic( 0 );1491 else setCharacteristic(  nGetChar());1498 else if (( s>cf>ch==1 ) /* Q(a) */ 1499  (s>cf>ch <1)) /* Fp(a) */ 1500 { 1501 if (s>cf>ch==1) setCharacteristic( 0 ); 1502 else setCharacteristic( s>cf>ch ); 1492 1503 CFMatrix M(r,r); 1493 1504 poly res; 1494 if ( currRing>minpoly!=NULL)1495 { 1496 CanonicalForm mipo=convSingPFactoryP( ((lnumber)currRing>minpoly)>z,1497 currRing>algring);1505 if (rField_is_Extension(s)&& s>cf>algring>minideal!=NULL) 1506 { 1507 CanonicalForm mipo=convSingPFactoryP(s>cf>algring>minideal>m[0], 1508 s>cf>algring); 1498 1509 Variable a=rootOf(mipo); 1499 1510 int i,j; … … 1502 1513 for(j=r;j>0;j) 1503 1514 { 1504 M(i,j)=convSingAPFactoryAP(MATELEM(m,i,j),a, currRing);1515 M(i,j)=convSingAPFactoryAP(MATELEM(m,i,j),a,s); 1505 1516 } 1506 1517 } 1507 res= convFactoryAPSingAP( determinant(M,r), currRing) ;1518 res= convFactoryAPSingAP( determinant(M,r),s ) ; 1508 1519 } 1509 1520 else … … 1514 1525 for(j=r;j>0;j) 1515 1526 { 1516 M(i,j)=convSingTrPFactoryP(MATELEM(m,i,j) );1527 M(i,j)=convSingTrPFactoryP(MATELEM(m,i,j),s); 1517 1528 } 1518 1529 } 1519 res= convFactoryPSingTrP( determinant(M,r) );1530 res= convFactoryPSingTrP( determinant(M,r),s ); 1520 1531 } 1521 1532 } … … 1526 1537 } 1527 1538 1528 int singclap_det_i( intvec * m 1539 int singclap_det_i( intvec * m) 1529 1540 { 1530 1541 setCharacteristic( 0 ); … … 1538 1549 } 1539 1550 } 1540 int res= convFactoryISingI( determinant(M,m>rows()) ) ;1551 int res= convFactoryISingI( determinant(M,m>rows()) ) ; 1541 1552 Off(SW_RATIONAL); 1542 1553 return res; 1543 1554 } 1544 1555 #ifdef HAVE_NTL 1545 matrix singntl_HNF(matrix m )1556 matrix singntl_HNF(matrix m, const ring s ) 1546 1557 { 1547 1558 int r=m>rows(); … … 1552 1563 } 1553 1564 matrix res=mpNew(r,r); 1554 if (rField_is_Q( currRing))1565 if (rField_is_Q(s)) 1555 1566 { 1556 1567 … … 1561 1572 for(j=r;j>0;j) 1562 1573 { 1563 M(i,j)=convSingPFactoryP(MATELEM(m,i,j) );1574 M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s ); 1564 1575 } 1565 1576 } … … 1569 1580 for(j=r;j>0;j) 1570 1581 { 1571 MATELEM(res,i,j)=convFactoryPSingP((*MM)(i,j) );1582 MATELEM(res,i,j)=convFactoryPSingP((*MM)(i,j),s); 1572 1583 } 1573 1584 } … … 1576 1587 return res; 1577 1588 } 1578 intvec* singntl_HNF(intvec* m 1589 intvec* singntl_HNF(intvec* m) 1579 1590 { 1580 1591 int r=m>rows(); … … 1606 1617 return mm; 1607 1618 } 1608 matrix singntl_LLL(matrix m )1619 matrix singntl_LLL(matrix m, const ring s ) 1609 1620 { 1610 1621 int r=m>rows(); 1611 1622 int c=m>cols(); 1612 1623 matrix res=mpNew(r,c); 1613 if (rField_is_Q( currRing))1624 if (rField_is_Q(s)) 1614 1625 { 1615 1626 CFMatrix M(r,c); … … 1619 1630 for(j=c;j>0;j) 1620 1631 { 1621 M(i,j)=convSingPFactoryP(MATELEM(m,i,j) );1632 M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s); 1622 1633 } 1623 1634 } … … 1627 1638 for(j=c;j>0;j) 1628 1639 { 1629 MATELEM(res,i,j)=convFactoryPSingP((*MM)(i,j) );1640 MATELEM(res,i,j)=convFactoryPSingP((*MM)(i,j),s); 1630 1641 } 1631 1642 } … … 1634 1645 return res; 1635 1646 } 1636 intvec* singntl_LLL(intvec* m 1647 intvec* singntl_LLL(intvec* m) 1637 1648 { 1638 1649 int r=m>rows(); 
libpolys/polys/clapsing.h
rd75f15 rce3f53c 21 21 //#include <kernel/longtrans.h> 22 22 23 poly singclap_gcd ( poly f, poly g );23 poly singclap_gcd ( poly f, poly g, const ring r ); 24 24 poly singclap_gcd_r ( poly f, poly g, const ring r ); 25 25 /* … … 28 28 */ 29 29 30 poly singclap_resultant ( poly f, poly g , poly x );30 poly singclap_resultant ( poly f, poly g , poly x, const ring r); 31 31 32 BOOLEAN singclap_extgcd ( poly f, poly g, poly &res, poly &pa, poly &pb );32 BOOLEAN singclap_extgcd ( poly f, poly g, poly &res, poly &pa, poly &pb , const ring r); 33 33 BOOLEAN singclap_extgcd_r ( poly f, poly g, poly &res, poly &pa, poly &pb, const ring r ); 34 34 35 poly singclap_pdivide ( poly f, poly g );35 poly singclap_pdivide ( poly f, poly g, const ring r ); 36 36 poly singclap_pdivide_r ( poly f, poly g, const ring r ); 37 37 38 void singclap_divide_content ( poly f 38 void singclap_divide_content ( poly f, const ring r); 39 39 40 ideal singclap_factorize ( poly f, intvec ** v , int with_exps );40 ideal singclap_factorize ( poly f, intvec ** v , int with_exps, const ring r); 41 41 42 ideal singclap_sqrfree ( poly f );42 ideal singclap_sqrfree ( poly f, const ring r ); 43 43 44 matrix singclap_irrCharSeries ( ideal I );44 matrix singclap_irrCharSeries ( ideal I, const ring r); 45 45 46 46 #ifdef HAVE_NTL 47 matrix singntl_HNF(matrix A );48 intvec* singntl_HNF(intvec* A );49 matrix singntl_LLL(matrix A );50 intvec* singntl_LLL(intvec* A );47 matrix singntl_HNF(matrix A, const ring r); 48 intvec* singntl_HNF(intvec* A, const ring r); 49 matrix singntl_LLL(matrix A, const ring r); 50 intvec* singntl_LLL(intvec* A, const ring r); 51 51 #endif 52 52 53 BOOLEAN singclap_isSqrFree(poly f );53 BOOLEAN singclap_isSqrFree(poly f, const ring r); 54 54 55 char* singclap_neworder ( ideal I );55 char* singclap_neworder ( ideal I, const ring r); 56 56 57 poly singclap_det( const matrix m );58 int singclap_det_i( intvec * m );57 poly singclap_det( const matrix m, const ring r ); 58 int singclap_det_i( intvec * m, const ring r ); 59 59 /* 60 60 BOOLEAN jjRESULTANT(leftv res, leftv u, leftv v, leftv w); 
libpolys/polys/monomials/p_polys.cc
rd75f15 rce3f53c 1909 1909 if ( (n_GetChar(r) == 1)  (n_GetChar(r) < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */ 1910 1910 { 1911 singclap_divide_content(ph );1911 singclap_divide_content(ph, r); 1912 1912 if(!n_GreaterZero(pGetCoeff(ph),r>cf)) ph = p_Neg(ph,r); 1913 1913 }
Note: See TracChangeset
for help on using the changeset viewer.