| 452 | } |
| 453 | |
| 454 | static poly maPoly_EvalMon(poly src, ring src_r, poly* dest_id, ring dest_r) |
| 455 | { |
| 456 | int i; |
| 457 | int e; |
| 458 | poly p=NULL; |
| 459 | poly pp; |
| 460 | BOOLEAN is_const=TRUE; // for constant src |
| 461 | for(i=1;i<=src_r->N;i++) |
| 462 | { |
| 463 | e=p_GetExp(src,i,src_r); |
| 464 | if (e>0) |
| 465 | { |
| 466 | pp=dest_id[i-1]; |
| 467 | if (pp==NULL) |
| 468 | { |
| 469 | p_Delete(&p,dest_r); |
| 470 | return NULL; |
| 471 | } |
| 472 | if (p==NULL) |
| 473 | { |
| 474 | if (!is_const) // possible only when the coefficient ring is not a field |
| 475 | { |
| 476 | return NULL; |
| 477 | } |
| 478 | p=p_Copy(pp /*dest_id[i-1]*/,dest_r); |
| 479 | e--; |
| 480 | } |
| 481 | while (e>0) |
| 482 | { |
| 483 | p=p_Mult_q(p,p_Copy(pp /*dest_id[i-1]*/,dest_r),dest_r); |
| 484 | e--; |
| 485 | } |
| 486 | is_const=FALSE; |
| 487 | } |
| 488 | } |
| 489 | if (is_const) |
| 490 | { |
| 491 | assume(p==NULL); |
| 492 | p=p_ISet(1,dest_r); |
| 493 | } |
| 494 | return p; |
| 495 | } |
| 496 | |
| 497 | void maPoly_Eval(mapoly root, ring src_r, ideal dest_id, ring dest_r, int total_cost) |
| 498 | { |