Changeset fca87a in git


Ignore:
Timestamp:
Apr 30, 2009, 7:00:27 PM (14 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', '0d6b7fcd9813a1ca1ed4220cfa2b104b97a0a003')
Children:
0661d420fbd0c4909468e67e60c2b21895686e9d
Parents:
86f23e885c1e8d5a7cd1318b09da181f353e0393
Message:
*hannes: omalloc, format


git-svn-id: file:///usr/local/Singular/svn/trunk@11761 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/digitech.cc

    r86f23e rfca87a  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: digitech.cc,v 1.5 2007-01-11 10:57:51 Singular Exp $ */
     4/* $Id: digitech.cc,v 1.6 2009-04-30 17:00:27 Singular Exp $ */
    55#include "mod2.h"
    66#include "ring.h"
     
    1111static ideal zero_ideal;
    1212#if 1
    13 void bit_reduce(poly & f,ring r){
     13void bit_reduce(poly & f,ring r)
     14{
    1415  poly p=f;
    1516  kBucket_pt erg_bucket= kBucketCreate(r);
    1617  kBucketInit(erg_bucket,NULL,0 /*pLength(P.p)*/);
    17   while(p){
     18  while(p)
     19  {
    1820    poly next=pNext(p);
    1921    pNext(p)=NULL;
     
    2123    int i;
    2224    int max=rVar(r);
    23     for(i=1;i<=max;i++){
     25    for(i=1;i<=max;i++)
     26    {
    2427      unsigned long exp=p_GetExp(p,i,r);
    2528      if(exp!=0)
    26         p_SetExp(p,i,1,r);
    27      
     29        p_SetExp(p,i,1,r);
     30
    2831    }
    2932    p_Setm(p,r);
     
    4346
    4447
    45 void do_bit_reduce(poly f, kBucket_pt bucket){
     48void do_bit_reduce(poly f, kBucket_pt bucket)
     49{
    4650    ring r=bucket->bucket_ring;
    4751    int p=rChar(r);
     
    5660            //return;
    5761        //}
    58    
     62
    5963    BOOLEAN changed=FALSE;
    6064    poly next=pNext(f);
    6165    pNext(f)=NULL;
    6266    int i;
    63     for(i=1;i<=max;i++){
     67    for(i=1;i<=max;i++)
     68    {
    6469      unsigned long exp;
    6570      while((exp=p_GetExp(f,i,r))>=p){
    66                p_SetExp(f,i,exp-p+1,r);
    67                changed=TRUE;
    68       }
    69     }
    70    
    71     if (changed) {
    72         p_Setm(f,r);
    73        
     71               p_SetExp(f,i,exp-p+1,r);
     72               changed=TRUE;
     73      }
     74    }
     75
     76    if (changed)
     77    {
     78        p_Setm(f,r);
     79
    7480        int pseudo_len=0;
    7581        kBucket_Add_q(bucket,f,&pseudo_len);
    7682        //do_bit_reduce(next,bucket);
    77     } else {
     83    }
     84    else
     85    {
    7886        //do_bit_reduce(next,bucket);
    7987        int pseudo_len=0;
    8088        kBucket_Add_q(bucket,f,&pseudo_len);
    81        
     89
    8290    }
    8391    f=next;
    8492    }
    8593}
    86 poly do_bitreduce(poly f, ring r){
     94poly do_bitreduce(poly f, ring r)
     95{
    8796  poly erg=NULL;
    8897  poly *append_to=&erg;
     
    91100  kBucket_pt bucket= kBucketCreate(r);
    92101  kBucketInit(bucket,NULL,0 /*pLength(P.p)*/);
    93   while(f!=NULL){
     102  while(f!=NULL)
     103  {
    94104    BOOLEAN changed=FALSE;
    95105    poly next=pNext(f);
     
    97107    assume(pNext(f)==NULL);
    98108    int i;
    99     for(i=1;i<=max;i++){
    100       unsigned long exp;
    101       while((exp=p_GetExp(f,i,r))>=p){
    102                p_SetExp(f,i,exp-p+1,r);
    103                changed=TRUE;
    104       }
    105     }
    106     if (changed) {
     109    for(i=1;i<=max;i++)
     110    {
     111      unsigned long exp;
     112      while((exp=p_GetExp(f,i,r))>=p)
     113      {
     114               p_SetExp(f,i,exp-p+1,r);
     115               changed=TRUE;
     116      }
     117    }
     118    if (changed)
     119    {
    107120        p_Setm(f,r);
    108121        int pseudo_len=0;
    109122        kBucket_Add_q(bucket,f,&pseudo_len);
    110     } else {
     123    }
     124    else
     125    {
    111126        (*append_to)=f;
    112127        append_to=&(pNext(f));
     
    122137    return erg;
    123138}
    124 void bit_reduce2(poly & f,ring r){
     139void bit_reduce2(poly & f,ring r)
     140{
    125141  if (f==NULL) return;
    126142  if (pNext(f)==NULL){
     
    131147    assume(pNext(f)==NULL);
    132148    int i;
    133     for(i=1;i<=max;i++){
    134       unsigned long exp;
    135       while((exp=p_GetExp(f,i,r))>=p){
    136                p_SetExp(f,i,exp-p+1,r);
    137                changed=TRUE;
     149    for(i=1;i<=max;i++)
     150    {
     151      unsigned long exp;
     152      while((exp=p_GetExp(f,i,r))>=p)
     153      {
     154               p_SetExp(f,i,exp-p+1,r);
     155               changed=TRUE;
    138156      }
    139157    }
     
    149167//   kBucketDestroy(&bucket);
    150168    f=do_bitreduce(f,r);
    151  
    152 }
    153 void bit_reduce1(poly & f,ring r){
     169
     170}
     171void bit_reduce1(poly & f,ring r)
     172{
    154173  if (f==NULL) return;
    155174
    156  
    157   if (pNext(f)==NULL){
     175
     176  if (pNext(f)==NULL)
     177  {
    158178    int p=rChar(r);
    159179    int max=rVar(r);
     
    162182    assume(pNext(f)==NULL);
    163183    int i;
    164     for(i=1;i<=max;i++){
    165       unsigned long exp;
    166       while((exp=p_GetExp(f,i,r))>=p){
    167                p_SetExp(f,i,exp-p+1,r);
    168                changed=TRUE;
     184    for(i=1;i<=max;i++)
     185    {
     186      unsigned long exp;
     187      while((exp=p_GetExp(f,i,r))>=p)
     188      {
     189               p_SetExp(f,i,exp-p+1,r);
     190               changed=TRUE;
    169191      }
    170192    }
     
    179201  kBucketClear(bucket,&f, &len);
    180202  kBucketDestroy(&bucket);
    181  
     203
    182204}
    183205// void bit_reduce_arg(poly & f,ring r){
     
    188210#endif
    189211
    190 poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r){
     212poly uni_subst_bits(poly outer_uni, poly inner_multi, ring r)
     213{
    191214  zero_ideal=idInit(0,1);
    192215  //assumes outer_uni is univariate and ordering global
    193216  int d_max=p_GetExp(outer_uni,1,r);
    194   poly* potences=(poly*) omalloc((d_max+1)*sizeof(poly));
     217  poly* potences=(poly*) omAlloc((d_max+1)*sizeof(poly));
    195218  potences[0]=p_ISet(1,r);
    196219  int i;
    197   for(i=1;i<=d_max;i++){
     220  for(i=1;i<=d_max;i++)
     221  {
    198222    potences[i]=pp_Mult_qq(potences[i-1],inner_multi,r);
    199223    bit_reduce(potences[i],r);
     
    205229
    206230
    207   while(p){
     231  while(p)
     232  {
    208233    int d=p_GetExp(p,1,r);
    209234    assume(potences[d]!=NULL); //mustn't always hold, but for most input
     
    218243
    219244  //free potences
    220   for(i=0;i<=d_max;i++){
     245  for(i=0;i<=d_max;i++)
     246  {
    221247    p_Delete(&potences[i],r);
    222248  }
  • kernel/fast_mult.cc

    r86f23e rfca87a  
    22*  Computer Algebra System SINGULAR     *
    33****************************************/
    4 /* $Id: fast_mult.cc,v 1.21 2007-01-11 10:37:51 Singular Exp $ */
     4/* $Id: fast_mult.cc,v 1.22 2009-04-30 16:57:20 Singular Exp $ */
    55#include "mod2.h"
    66#include "ring.h"
     
    1212static const int pass_option=1;
    1313static int mults=0;
    14 int Mults(){
     14int Mults()
     15{
    1516  return mults;
    1617}
    17 static void degsplit(poly p,int n,poly &p1,poly&p2, int vn, ring r){
     18static void degsplit(poly p,int n,poly &p1,poly&p2, int vn, ring r)
     19{
    1820  poly erg1_i, erg2_i;
    1921  erg1_i=NULL;
    2022  erg2_i=NULL;
    21   while(p){
    22     if(p_GetExp(p,vn,r)>=n){
    23       if (p1==NULL){
    24         p1=p;
    25       } else{
    26         pNext(erg1_i)=p;
     23  while(p)
     24  {
     25    if(p_GetExp(p,vn,r)>=n)
     26    {
     27      if (p1==NULL)
     28      {
     29        p1=p;
     30      }
     31      else
     32      {
     33        pNext(erg1_i)=p;
    2734      }
    2835      erg1_i=p;
    29     } else{
    30       if (p2==NULL){
    31         p2=p;
    32       } else{
    33         pNext(erg2_i)=p;
     36    }
     37    else
     38    {
     39      if (p2==NULL)
     40      {
     41        p2=p;
     42      }
     43      else
     44      {
     45        pNext(erg2_i)=p;
    3446      }
    3547      erg2_i=p;
     
    3749    p=pNext(p);
    3850  }
    39   if(erg2_i){
     51  if(erg2_i)
     52  {
    4053    pNext(erg2_i)=NULL;
    4154  }
    42   if (erg1_i){
     55  if (erg1_i)
     56  {
    4357    pNext(erg1_i)=NULL;
    4458  }
    45  
    46 }
    47 static void div_by_x_power_n(poly p, int n, int vn, ring r){
    48   while(p){
     59
     60}
     61static void div_by_x_power_n(poly p, int n, int vn, ring r)
     62{
     63  while(p)
     64  {
    4965    assume(p_GetExp(p,vn,r)>=n);
    5066    int e=p_GetExp(p,vn,r);
     
    5470}
    5571
    56 static poly do_unifastmult(poly f,int df,poly g,int dg, int vn, fastmultrec rec, ring r){
     72static poly do_unifastmult(poly f,int df,poly g,int dg, int vn, fastmultrec rec, ring r)
     73{
    5774  int n=1;
    5875  if ((f==NULL)||(g==NULL)) return NULL;
    5976  //int df=pGetExp(f,vn);//pFDeg(f);
    6077  //  int dg=pGetExp(g,vn);//pFDeg(g);
    61        
     78
    6279  int dm;
    63   if(df>dg){
     80  if(df>dg)
     81  {
    6482    dm=df;
    65   }else{
     83  }
     84  else
     85  {
    6686    dm=dg;
    6787  }
     
    7090      n*=2;
    7191    }
    72   if(n==1){
     92  if(n==1)
     93  {
    7394    return(pp_Mult_qq(f,g,r));
    7495  }
    75  
     96
    7697  int pot=n/2;
    7798  assume(pot*2==n);
     
    88109  degsplit(p_Copy(g,r),pot,g1,g0,vn,r);
    89110  div_by_x_power_n(g1,pot,vn,r);
    90  
     111
    91112  //p00, p11
    92113  poly p00=rec(f0,g0,r);//unifastmult(f0,g0);
     
    101122  erg=p_Add_q(erg,p_Copy(p00,r),r);
    102123
    103  
    104 
    105 
    106  
    107   if((f1!=NULL) &&(f0!=NULL) &&(g0!=NULL) && (g1!=NULL)){
     124
     125
     126
     127
     128  if((f1!=NULL) &&(f0!=NULL) &&(g0!=NULL) && (g1!=NULL))
     129  {
    108130    //if(true){
    109131    //eat up f0,f1,g0,g1
     
    114136    p_Delete(&s2,r);
    115137
    116  
     138
    117139    //eat up pbig
    118140    poly sum=pbig;
    119141    p_SetExp(factor,vn,pot,r);
    120  
     142
    121143    //eat up p00
    122144    sum=p_Add_q(sum,p_Neg(p00,r),r);
    123  
     145
    124146    //eat up p11
    125147    sum=p_Add_q(sum,p_Neg(p11,r),r);
    126148
    127  
     149
    128150    sum=p_Mult_mm(sum,factor,r);
    129151
     
    131153    //eat up sum
    132154    erg=p_Add_q(sum,erg,r);
    133   } else {
    134     //eat up f0,f1,g0,g1
     155  }
     156  else
     157  {
     158    //eat up f0,f1,g0,g1
    135159    poly s1=rec(f0,g1,r);
    136160    poly s2=rec(g0,f1,r);
     
    145169    erg=p_Add_q(erg,h,r);
    146170  }
    147  
    148  
     171
     172
    149173  p_Delete(&factor,r);
    150                  
    151                  
     174
     175
    152176
    153177  return(erg);
     
    155179
    156180// poly do_unifastmult_buckets(poly f,poly g){
    157    
    158  
     181
     182
    159183
    160184
     
    163187//   int df=pGetExp(f,1);//pFDeg(f);
    164188//     int dg=pGetExp(g,1);//pFDeg(g);
    165        
     189
    166190//   int dm;
    167191//   if(df>dg){
     
    195219//   degsplit(pCopy(g),pot,g1,g0);
    196220//   div_by_x_power_n(g1,pot);
    197  
     221
    198222//   //p00
    199223//   //p11
    200224//   poly p00=unifastmult(f0,g0);
    201225//   poly p11=unifastmult(f1,g1);
    202  
     226
    203227
    204228
    205229
    206230//   //eat up f0,f1,g0,g1
    207 //   poly pbig=unifastmult(pAdd(f0,f1),pAdd(g0,g1)); 
     231//   poly pbig=unifastmult(pAdd(f0,f1),pAdd(g0,g1));
    208232//   poly factor=pOne();//pCopy(erg_mult);
    209233//   pSetExp(factor,1,n);
     
    224248//   kBucket_Add_q(erg_bucket,pMult_mm(pNeg(p11),factor),&pseudo_len);
    225249
    226  
     250
    227251//   pseudo_len=0;
    228252
    229  
     253
    230254//   pDelete(&factor);
    231255
     
    238262// }
    239263
    240 static inline int max(int a, int b){
     264static inline int max(int a, int b)
     265{
    241266  return (a>b)? a:b;
    242267}
    243 static inline int min(int a, int b){
     268static inline int min(int a, int b)
     269{
    244270  return (a>b)? b:a;
    245271}
    246 poly unifastmult(poly f,poly g, ring r){
     272poly unifastmult(poly f,poly g, ring r)
     273{
    247274  int vn=1;
    248275  if((f==NULL)||(g==NULL)) return NULL;
     
    261288}
    262289
    263 poly multifastmult(poly f, poly g, ring r){
     290poly multifastmult(poly f, poly g, ring r)
     291{
    264292  mults++;
    265293  if((f==NULL)||(g==NULL)) return NULL;
     
    273301  int can_dg=0;
    274302  int can_crit=0;
    275   for(i=1;i<=rVar(r);i++){
     303  for(i=1;i<=rVar(r);i++)
     304  {
    276305    poly p;
    277306    int df=0;
     
    279308    //max min max Strategie
    280309    p=f;
    281     while(p){
     310    while(p)
     311    {
    282312      df=max(df,p_GetExp(p,i,r));
    283313      p=pNext(p);
    284314    }
    285     if(df>can_crit){
     315    if(df>can_crit)
     316    {
    286317      p=g;
    287       while(p){
    288         dg=max(dg,p_GetExp(p,i,r));
    289         p=pNext(p);
     318      while(p)
     319      {
     320        dg=max(dg,p_GetExp(p,i,r));
     321        p=pNext(p);
    290322      }
    291323      int crit=min(df,dg);
    292       if (crit>can_crit){
    293         can_crit=crit;
    294         can_i=i;
    295         can_df=df;
    296         can_dg=dg;
     324      if (crit>can_crit)
     325      {
     326        can_crit=crit;
     327        can_i=i;
     328        can_df=df;
     329        can_dg=dg;
    297330      }
    298331    }
     
    307340    }
    308341}
    309 poly pFastPower(poly f, int n, ring r){
     342poly pFastPower(poly f, int n, ring r)
     343{
    310344  if (n==1) return f;
    311345  if (n==0) return p_ISet(1,r);
     
    313347  int i_max=1;
    314348  int pot_max=0;
    315   while(i_max*2<=n){
     349  while(i_max*2<=n)
     350  {
    316351    i_max*=2;
    317352    pot_max++;
    318353  }
    319354  int field_size=pot_max+1;
    320   int* int_pot_array=(int*) omalloc(field_size*sizeof(int));
    321   poly* pot_array=(poly*) omalloc(field_size*sizeof(poly));
     355  int* int_pot_array=(int*) omAlloc(field_size*sizeof(int));
     356  poly* pot_array=(poly*) omAlloc(field_size*sizeof(poly));
    322357  int i;
    323358  int pot=1;
    324359  //initializing int_pot
    325   for(i=0;i<field_size;i++){
     360  for(i=0;i<field_size;i++)
     361  {
    326362    int_pot_array[i]=pot;
    327363    pot*=2;
     
    329365  //calculating pot_array
    330366  pot_array[0]=f; //do not delete it
    331   for(i=1;i<field_size;i++){
     367  for(i=1;i<field_size;i++)
     368  {
    332369    poly p=pot_array[i-1];
    333370    if(rVar(r)==1)
     
    336373      pot_array[i]=pp_Mult_qq(p,p,r);
    337374  }
    338  
     375
    339376
    340377
     
    349386//       assume(work_n<2*int_pot_array[i]);
    350387//       if(int_pot_array[i]<=work_n){
    351 //      work_n-=int_pot_array[i];
    352 //      poly prod=multifastmult(erg,pot_array[i],r);
    353 //      pDelete(&erg);
    354 //      erg=prod;
     388//         work_n-=int_pot_array[i];
     389//         poly prod=multifastmult(erg,pot_array[i],r);
     390//         pDelete(&erg);
     391//         erg=prod;
    355392//       }
    356393
    357394//       if(i!=0) pDelete(&pot_array[i]);
    358395//   }
    359  
    360  
    361   for(i=field_size-1;i>=0;i--){
     396
     397
     398  for(i=field_size-1;i>=0;i--)
     399  {
    362400
    363401      assume(work_n<2*int_pot_array[i]);
    364       if(int_pot_array[i]<=work_n){
    365         work_n-=int_pot_array[i];
    366         int_pot_array[i]=1;
     402      if(int_pot_array[i]<=work_n)
     403      {
     404        work_n-=int_pot_array[i];
     405        int_pot_array[i]=1;
    367406      }
    368407      else int_pot_array[i]=0;
    369    
    370   }
    371   for(i=0;i<field_size;i++){
    372     if(int_pot_array[i]==1){
     408
     409  }
     410  for(i=0;i<field_size;i++)
     411  {
     412    if(int_pot_array[i]==1)
     413    {
    373414      poly prod;
    374415      if(rVar(r)==1)
    375         prod=multifastmult(erg,pot_array[i],r);
     416        prod=multifastmult(erg,pot_array[i],r);
    376417      else
    377         prod=pp_Mult_qq(erg,pot_array[i],r);
     418        prod=pp_Mult_qq(erg,pot_array[i],r);
    378419      pDelete(&erg);
    379420      erg=prod;
     
    443484}
    444485static void buildTermAndAdd(int n,number* facult,poly* f_terms,int* exp,int f_len,kBucket_pt erg_bucket,ring r, number coef, poly & zw, poly tmp, poly** term_pot){
    445  
     486
    446487  int i;
    447488  //  poly term=p_Init(r);
     
    454495//       n_Delete(&trash,r);
    455496//     }
    456    
     497
    457498//   }
    458499//   number coef=n_IntDiv(facult[n],denom,r);   //right function here?
     
    466507      ///poly term=p_Copy(f_terms[i],r);
    467508      poly term=term_pot[i][exp[i]];
    468         //tmp;
    469         //p_ExpVectorCopy(term,f_terms[i],r);
    470         //p_SetCoeff(term, n_Copy(p_GetCoeff(f_terms[i],r),r),r);
    471        
     509        //tmp;
     510        //p_ExpVectorCopy(term,f_terms[i],r);
     511        //p_SetCoeff(term, n_Copy(p_GetCoeff(f_terms[i],r),r),r);
     512
    472513      //term->next=NULL;
    473      
     514
    474515      //p_MonPowerMB(term, exp[i],r);
    475516      p_MonMultMB(erg,term,r);
    476517      //p_Delete(&term,r);
    477518    }
    478    
     519
    479520  }
    480521  int pseudo_len=1;
     
    487528static void MC_iterate(poly f, int n, ring r, int f_len,number* facult, int* exp,poly* f_terms,kBucket_pt erg_bucket,int pos,int sum, number coef, poly & zw, poly tmp, poly** term_pot){
    488529  int i;
    489  
    490   if (pos<f_len-1){
     530
     531  if (pos<f_len-1)
     532  {
    491533    poly zw_l=NULL;
    492534    number new_coef;
    493     for(i=0;i<=n-sum;i++){
     535    for(i=0;i<=n-sum;i++)
     536    {
    494537      exp[pos]=i;
    495       if(i==0){
    496         new_coef=n_Copy(coef,r);
    497       }
    498       else {
    499         number old=new_coef;
    500         number old_rest=n_Init(n-sum-(i-1),r);
    501         new_coef=n_Mult(new_coef,old_rest,r);
    502         n_Delete(&old_rest,r);
    503         n_Delete(&old,r);
    504         number i_number=n_Init(i,r);
    505         old=new_coef;
    506         new_coef=n_IntDiv(new_coef,i_number,r);
    507         n_Delete(&old,r);
    508         n_Delete(&i_number,r);
    509       }
    510       //new_coef is
     538      if(i==0)
     539      {
     540        new_coef=n_Copy(coef,r);
     541      }
     542      else
     543      {
     544        number old=new_coef;
     545        number old_rest=n_Init(n-sum-(i-1),r);
     546        new_coef=n_Mult(new_coef,old_rest,r);
     547        n_Delete(&old_rest,r);
     548        n_Delete(&old,r);
     549        number i_number=n_Init(i,r);
     550        old=new_coef;
     551        new_coef=n_IntDiv(new_coef,i_number,r);
     552        n_Delete(&old,r);
     553        n_Delete(&i_number,r);
     554      }
     555      //new_coef is
    511556      //(n                          )
    512557      //(exp[0]..exp[pos] 0 0 0 rest)
    513558      poly zw_real=NULL;
    514559      MC_iterate(f, n, r, f_len,facult, exp,f_terms,erg_bucket,pos+1,sum+i,new_coef,zw_real,tmp,term_pot);
    515       if (pos==f_len-2){
    516         //get first small polys
    517        
    518         zw_real->next=zw_l;
    519         zw_l=zw_real;
     560      if (pos==f_len-2)
     561      {
     562        //get first small polys
     563
     564        zw_real->next=zw_l;
     565        zw_l=zw_real;
    520566      }
    521567      //n_Delete(& new_coef,r);
    522568    }
    523569    n_Delete(&new_coef,r);
    524     if (pos==f_len-2){
     570    if (pos==f_len-2)
     571    {
    525572      int len=n-sum+1;
    526573      kBucket_Add_q(erg_bucket,zw_l,&len);
     
    528575    return;
    529576  }
    530   if(pos==f_len-1){
     577  if(pos==f_len-1)
     578  {
    531579    i=n-sum;
    532580    exp[pos]=i;
     
    537585  assume(pos<=f_len-1);
    538586}
    539 poly pFastPowerMC(poly f, int n, ring r){
     587poly pFastPowerMC(poly f, int n, ring r)
     588{
    540589  //only char=0
    541  
     590
    542591  if(rChar(r)!=0)
    543592    Werror("Char not 0, pFastPowerMC not implemented for this case");
     
    547596    Werror("not implemented for so small lenght of f, recursion fails");
    548597  //  number null_number=n_Init(0,r);
    549   number* facult=(number*) omalloc((n+1)*sizeof(number));
     598  number* facult=(number*) omAlloc((n+1)*sizeof(number));
    550599  facult[0]=n_Init(1,r);
    551600  int i;
    552   for(i=1;i<=n;i++){
     601  for(i=1;i<=n;i++)
     602  {
    553603    number this_n=n_Init(i,r);
    554604    facult[i]=n_Mult(this_n,facult[i-1],r);
     
    561611  kBucketInit(erg_bucket,NULL,0);
    562612  const int f_len=pLength(f);
    563   int* exp=(int*)omalloc(f_len*sizeof(int));
     613  int* exp=(int*)omAlloc(f_len*sizeof(int));
    564614  //poly f_terms[f_len];
    565   poly* f_terms=(poly*)omalloc(f_len*sizeof(poly));
    566   poly** term_potences=(poly**) omalloc(f_len*sizeof(poly*));
    567  
     615  poly* f_terms=(poly*)omAlloc(f_len*sizeof(poly));
     616  poly** term_potences=(poly**) omAlloc(f_len*sizeof(poly*));
     617
    568618  poly f_iter=f;
    569   for(i=0;i<f_len;i++){
     619  for(i=0;i<f_len;i++)
     620  {
    570621    f_terms[i]=f_iter;
    571622    f_iter=pNext(f_iter);
    572623  }
    573   for(i=0;i<f_len;i++){
    574     term_potences[i]=(poly*)omalloc((n+1)*sizeof(poly));
     624  for(i=0;i<f_len;i++)
     625  {
     626    term_potences[i]=(poly*)omAlloc((n+1)*sizeof(poly));
    575627    term_potences[i][0]=p_ISet(1,r);
    576628    int j;
     
    589641
    590642
    591  
     643
    592644  //free res
    593  
     645
    594646  //free facult
    595   for(i=0;i<=n;i++){
     647  for(i=0;i<=n;i++)
     648  {
    596649    n_Delete(&facult[i],r);
    597650  }
    598651  int i2;
    599   for (i=0;i<f_len;i++){
    600     for(i2=0;i2<=n;i2++){
     652  for (i=0;i<f_len;i++)
     653  {
     654    for(i2=0;i2<=n;i2++)
     655    {
    601656      p_Delete(&term_potences[i][i2],r);
    602657    }
    603658    omfree(term_potences[i]);
    604    
     659
    605660  }
    606661  omfree(term_potences);
Note: See TracChangeset for help on using the changeset viewer.