Changeset 40b31de in git for kernel/ratgring.cc
- Timestamp:
- Feb 21, 2009, 4:25:43 PM (15 years ago)
- Branches:
- (u'spielwiese', 'd0474371d8c5d8068ab70bfb42719c97936b18a6')
- Children:
- 28734edefa255520d20d13c4c0f3ba4f92590a2a
- Parents:
- 9e9dbcc8d214c3ffadd3d652094fe70a53aa1302
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/ratgring.cc
r9e9dbc r40b31de 7 7 * Author: levandov (Viktor Levandovsky) 8 8 * Created: 8/00 - 11/00 9 * Version: $Id: ratgring.cc,v 1.1 1 2008-08-07 21:15:56levandov Exp $9 * Version: $Id: ratgring.cc,v 1.12 2009-02-21 15:25:43 levandov Exp $ 10 10 *******************************************************************/ 11 11 #include "mod2.h" … … 97 97 { 98 98 /* modifies p*/ 99 Print("start: "); Print(" "); p_wrp(*p,r);99 // Print("start: "); Print(" "); p_wrp(*p,r); 100 100 p_LmCheckPolyRing2(*p, r); 101 101 poly q = p_Head(*p,r); … … 104 104 { 105 105 p_LmDelete(p,r); 106 Print("while: ");p_wrp(*p,r);Print(" ");107 } 108 p_wrp(*p,r);Print(" ");109 PrintS("end\n");106 // Print("while: ");p_wrp(*p,r);Print(" "); 107 } 108 // p_wrp(*p,r);Print(" "); 109 // PrintS("end\n"); 110 110 p_LmDelete(&q,r); 111 111 } … … 146 146 ideal ncGCD2(poly p, poly q, const ring r) 147 147 { 148 // todo: must destroy p,q 148 149 intvec *w = NULL; 149 150 ideal h = idInit(2,1); … … 193 194 ideal ncGCD(poly p, poly q, const ring r) 194 195 { 196 // destroys p and q 195 197 // assume: p,q are in the comm. ring 196 198 // to be used in the coeff business 197 199 #ifdef PDEBUG 198 Print ("G_start:");200 PrintS(" GCD_start:"); 199 201 #endif 200 202 poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r)); 201 203 #ifdef PDEBUG 202 204 p_wrp(g,r); 203 Print ("G_end;");205 PrintS(" GCD_end;\n"); 204 206 #endif 205 207 poly u = singclap_pdivide(q,g); //q/g 206 208 poly v = singclap_pdivide(p,g); //p/g 209 p_Delete(&p,r); 210 p_Delete(&q,r); 207 211 ideal h = idInit(2,1); 208 212 h->m[0] = u; // p_Copy(u,r); … … 385 389 386 390 poly m = pOne(); 387 p_ExpVectorDiffRat(m, p 1, p2, ishift, r); // includes X and D parts391 p_ExpVectorDiffRat(m, p2, p1, ishift, r); // includes X and D parts 388 392 //p_Setm(m,r); 389 393 // m = p_GetExp_k_n(m,1,ishift,r); /* rat D-exp of m */ 390 394 #ifdef PDEBUG 391 395 p_Test(m,r); 396 PrintS("d^alpha = "); p_wrp(m,r); PrintLn(); 392 397 #endif 393 398 … … 395 400 poly HH = NULL; 396 401 poly H = NULL; 397 HH = p_ Copy(p_HeadRat(p1,is,r),r); // lm_D(g)402 HH = p_HeadRat(p1,is,r); //p_Copy(p_HeadRat(p1,is,r),r); // lm_D(g) 398 403 // H = r->nc->p_Procs.mm_Mult_p(m, p_Copy(HH, r), r); // d^aplha lm_D(g) 399 H = nc_mm_Mult_pp(m, HH, r); // d^aplha lm_D(g) == h_g in the paper 400 401 poly K = p_Copy( p_GetCoeffRat(H, is, r), r); // k in the paper 402 Print("k: "); p_wrp(K,r); PrintS("\n"); 403 poly P = p_Copy( p_GetCoeffRat(p2, is, r), r); // lc_D(p_2) == lc_D(f) 404 Print("p: "); p_wrp(P,r); PrintS("\n"); 405 406 // HH = p_Neg(HH, r); 407 // poly out = NULL; 408 // out = p_Add_q(p_Copy(p1,r), HH, r); // out == t_g 409 410 Print("f: "); p_wrp(p2,r); PrintS("\n"); 411 Print("g: "); p_wrp(p1,r); PrintS("\n"); 412 404 H = nc_mm_Mult_p(m, HH, r); // d^aplha lm_D(g) == h_g in the paper 405 406 poly K = p_GetCoeffRat(H, is, r); //p_Copy( p_GetCoeffRat(H, is, r), r); // k in the paper 407 poly P = p_GetCoeffRat(p2, is, r); //p_Copy( p_GetCoeffRat(p2, is, r), r); // lc_D(p_2) == lc_D(f) 408 409 #ifdef PDEBUG 410 PrintS("k: "); p_wrp(K,r); PrintS("\n"); 411 PrintS("p: "); p_wrp(P,r); PrintS("\n"); 412 PrintS("f: "); p_wrp(p2,r); PrintS("\n"); 413 PrintS("g: "); p_wrp(p1,r); PrintS("\n"); 414 #endif 413 415 // alt: 414 poly out = p 1; //p_Copy(p1,r);416 poly out = p_Copy(p1,r); 415 417 p_LmDeleteAndNextRat(&out, is+1, r); // out == t_g 416 418 417 Print("t_g: "); p_wrp(out,r);418 419 419 ideal ncsyz = ncGCD(P,K,r); 420 poly KK = p_Copy(ncsyz->m[0],r); // k' 421 poly PP = p_Copy(ncsyz->m[1],r); // p' 422 423 // HH = p_Copy(p_HeadRat(p2,is,r),r); 424 // HH = p_Neg(HH, r); 425 // p2 = p_Add_q(p2, HH, r); // t_f 426 427 // alt: 420 poly KK = ncsyz->m[0]; ncsyz->m[0]=NULL; //p_Copy(ncsyz->m[0],r); // k' 421 poly PP = ncsyz->m[1]; ncsyz->m[1]= NULL; //p_Copy(ncsyz->m[1],r); // p' 422 423 #ifdef PDEBUG 424 PrintS("t_g: "); p_wrp(out,r); 425 PrintS("k': "); p_wrp(KK,r); PrintS("\n"); 426 PrintS("p': "); p_wrp(PP,r); PrintS("\n"); 427 #endif 428 id_Delete(&ncsyz,r); 428 429 p_LmDeleteAndNextRat(&p2, is+1, r); // t_f 429 430 Print("t_f: "); p_wrp(p2,r); 431 432 // HH = p_Copy(p_HeadRat(H,is,r),r); 433 // HH = p_Neg(HH, r); 434 // H = p_Add_q(H, HH, r); // r_g 435 436 // alt: 437 p_LmDeleteAndNextRat(&H, is+1, r); // r_g 438 439 Print("r_g: "); p_wrp(H,r); 430 p_LmDeleteAndNextRat(&H, is+1, r); // r_g = h_g - lt_D(h_g) 431 432 #ifdef PDEBUG 433 PrintS(" t_f: "); p_wrp(p2,r); 434 PrintS(" r_g: "); p_wrp(H,r); 435 #endif 440 436 441 437 p2 = p_Mult_q(KK, p2, r); // p2 = k' t_f 438 439 #ifdef PDEBUG 442 440 p_Test(p2,r); 443 // p_Delete(&KK,r); 444 445 Print("k' t_f: "); p_wrp(p2,r); 441 PrintS(" k' t_f: "); p_wrp(p2,r); 442 #endif 446 443 447 444 // out = r->nc->p_Procs.mm_Mult_p(m, out, r); // d^aplha t_g 448 445 out = nc_mm_Mult_p(m, out, r); // d^aplha t_g 449 450 446 p_Delete(&m,r); 451 447 452 Print("d^a t_g: "); p_wrp(out,r); 453 Print(" end reduction\n"); 448 #ifdef PDEBUG 449 PrintS(" d^a t_g: "); p_wrp(out,r); 450 PrintS(" end reduction\n"); 451 #endif 452 454 453 out = p_Add_q(H, out, r); // r_g + d^a t_g 454 455 #ifdef PDEBUG 455 456 p_Test(out,r); 456 out = p_Mult_q(PP, out, r); // c' (r_g + d^a t_g) 457 457 #endif 458 out = p_Mult_q(PP, out, r); // p' (r_g + d^a t_g) 458 459 out = p_Add_q(p2,out,r); // delete out, p2; // the sum 460 461 #ifdef PDEBUG 459 462 p_Test(out,r); 463 #endif 464 460 465 if ( out!=NULL ) pContent(out); 461 466 return(out); … … 468 473 BOOLEAN p_DivisibleByRat(poly a, poly b, int ishift, const ring r) 469 474 { 475 #ifdef PDEBUG 476 PrintS("invoke p_DivByRat with a = "); 477 p_wrp(p_Head(a,r),r); 478 PrintS(" and b= "); 479 p_wrp(p_Head(b,r),r); 480 PrintLn(); 481 #endif 470 482 int i; 471 for(i=r->N;i>ishift;i--) 472 { 483 for(i=r->N; i>ishift; i--) 484 { 485 #ifdef PDEBUG 486 PrintS("i=%d,",i); 487 #endif 473 488 if (p_GetExp(a,i,r) > p_GetExp(b,i,r)) return FALSE; 474 489 } … … 491 506 for(i=rl-1;i>=0;i--) 492 507 { 508 // Print("test %d, l=%d (curr=%d, l=%d\n",i,red_length[i],j,l); 493 509 if ((l>red_length[i]) && (p_DivisibleByRat(reducer[i],*h,ishift,r))) 494 510 { 495 511 j=i; l=red_length[i]; 512 // PrintS(" yes\n"); 496 513 } 514 // else PrintS(" no\n"); 497 515 } 498 516 if (j >=rl)
Note: See TracChangeset
for help on using the changeset viewer.