| 586 | assume(pos<=f_len-1); |
| 587 | } |
| 588 | poly pFastPowerMC(poly f, int n, ring r) |
| 589 | { |
| 590 | //only char=0 |
| 591 | |
| 592 | if(rChar(r)!=0) |
| 593 | WerrorS("Char not 0, pFastPowerMC not implemented for this case"); |
| 594 | if (n<=1) |
| 595 | WerrorS("not implemented for so small n, recursion fails");//should be length(f) |
| 596 | if (pLength(f)<=1) |
| 597 | WerrorS("not implemented for so small length of f, recursion fails"); |
| 598 | // number null_number=n_Init(0,r); |
| 599 | number* facult=(number*) omAlloc((n+1)*sizeof(number)); |
| 600 | facult[0]=n_Init(1,r->cf); |
| 601 | int i; |
| 602 | for(i=1;i<=n;i++) |
| 603 | { |
| 604 | number this_n=n_Init(i,r->cf); |
| 605 | facult[i]=n_Mult(this_n,facult[i-1],r->cf); |
| 606 | n_Delete(&this_n,r->cf); |
| 607 | } |
| 608 | |
| 609 | lm_bin=omGetSpecBin(POLYSIZE + (r->ExpL_Size)*sizeof(long)); |
| 610 | |
| 611 | kBucket_pt erg_bucket= kBucketCreate(currRing); |
| 612 | kBucketInit(erg_bucket,NULL,0); |
| 613 | const int f_len=pLength(f); |
| 614 | int* exp=(int*)omAlloc(f_len*sizeof(int)); |
| 615 | //poly f_terms[f_len]; |
| 616 | poly* f_terms=(poly*)omAlloc(f_len*sizeof(poly)); |
| 617 | poly** term_potences=(poly**) omAlloc(f_len*sizeof(poly*)); |
| 618 | |
| 619 | poly f_iter=f; |
| 620 | for(i=0;i<f_len;i++) |
| 621 | { |
| 622 | f_terms[i]=f_iter; |
| 623 | f_iter=pNext(f_iter); |
| 624 | } |
| 625 | for(i=0;i<f_len;i++) |
| 626 | { |
| 627 | term_potences[i]=(poly*)omAlloc((n+1)*sizeof(poly)); |
| 628 | term_potences[i][0]=p_ISet(1,r); |
| 629 | int j; |
| 630 | for(j=1;j<=n;j++){ |
| 631 | term_potences[i][j]=p_MonMultCMB(f_terms[i],term_potences[i][j-1],r); |
| 632 | } |
| 633 | } |
| 634 | assume(f_iter==NULL); |
| 635 | poly zw=NULL; |
| 636 | poly tmp=p_Init(r); |
| 637 | number one=n_Init(1,r->cf); |
| 638 | MC_iterate(f,n,r,f_len,&facult[0], &exp[0], &f_terms[0],erg_bucket,0,0,one/*facult[n]*/,zw,tmp, term_potences); |
| 639 | |
| 640 | |
| 641 | n_Delete(&one,r->cf); |
| 642 | |
| 643 | |
| 644 | |
| 645 | //free res |
no test coverage detected