Пример #1
0
poly* SAtensor(boolean alt,_index m,poly* p)
{ _index n,r=Lierank(grp); poly** adams,** q,* result;
  if (m==0) return poly_one(r);  else if (m==1) return p;

  adams=alloc_array(poly*,m+1); 
  for (n=1; n<=m; ++n) adams[n]=Adams(n,p);
  q=alloc_array(poly*,m+1);
  q[0]=poly_one(r);
  for (n=1; n<=m; ++n)
  { 
    { _index i; q[n]=Tensor(p,q[n-1]); /* the initial term of the summation */
      for (i=2; i<=n; ++i) q[n] =
        Add_pol_pol(q[n],Tensor(adams[i],q[n-i]),alt&&i%2==0);
    }
    
    { _index i; bigint* big_n=entry2bigint(n);  setshared(big_n);
      for (i=0; i<q[n]->nrows; ++i)
      { bigint** cc= &q[n]->coef[i]
             ,* c= (clrshared(*cc),isshared(*cc)) ? copybigint(*cc,NULL) : *cc;
        *cc=divq(c,big_n); setshared(*cc);
        
        { if (c->size != 0)
            error("Internal error (SAtensor): remainder from %ld.\n" ,(long)n);
          freemem(c);
        }
      }
      clrshared(big_n); freemem(big_n);
    }
  }
  result=q[m];
{ for (n=1; n<=m; ++n) freepol(adams[n]); } freearr(adams);
{ for (n=0; n<m; ++n)  freepol(q[n]); } freearr(q);
 return result;
}
Пример #2
0
poly* Plethysm(entry* lambda,_index l,_index n,poly* p)
{ if (n==0) return poly_one(Lierank(grp));  else if (n==1) return p;

  { _index i,j;
    poly* sum= poly_null(Lierank(grp)),**adams=alloc_array(poly*,n+1);
    poly* chi_lambda=MN_char(lambda,l);
    for (i=1; i<=n; ++i) { adams[i]=Adams(i,p); setshared(adams[i]); }
    
    for (i=0;i<chi_lambda->nrows;i++)
    { entry* mu=chi_lambda->elm[i]; poly* prod=adams[mu[0]],*t;
      for (j=1; j<n && mu[j]>0; ++j)
        { t=prod; prod=Tensor(t,adams[mu[j]]); freepol(t); }
      sum= Addmul_pol_pol_bin(sum,prod,mult(chi_lambda->coef[i],Classord(mu,n)));
    }
    freemem(chi_lambda);
    setshared(p); /* protect |p|; it coincides with |adams[1]| */
    for (i=1; i<=n; ++i)
      { clrshared(adams[i]); freepol(adams[i]); }  freearr(adams);
  clrshared(p);

    
    { bigint* fac_n=fac(n);  setshared(fac_n); /* used repeatedly */
      for (i=0; i<sum->nrows; ++i)
      { bigint** cc= &sum->coef[i]
             ,* c= (clrshared(*cc),isshared(*cc)) ? copybigint(*cc,NULL) : *cc;
        *cc=divq(c,fac_n); setshared(*cc);
        if (c->size!=0) error("Internal error (plethysm).\n");  else freemem(c);
      }
      clrshared(fac_n); freemem(fac_n);
    }
    return sum;
  }
}
Пример #3
0
void wt_ins(entry* wt, bigint* c, boolean neg)
{   if (c->size==0) {
        freemem(c);
        return;
    }
    {   lie_Index i=searchterm(sorted,wt);
        if (i>=0)
        {   clrshared(sorted->coef[i]);
            sorted->coef[i]= (neg ? sub : add)(sorted->coef[i],c);
            setshared(sorted->coef[i]);
        }
        else

        {   poly** acc= neg ? &neg_acc : &pos_acc;
            lie_Index i=(*acc)->nrows;
            if (i==(*acc)->rowsize)
            {   sorted=Add_pol_pol(sorted,*acc,neg);
                *acc=mkpoly(Max(sorted->nrows,ACCMIN),sorted->ncols);
                i=0;
            }
            copyrow(wt,(*acc)->elm[i],sorted->ncols);
            (*acc)->coef[i++]=c;
            setshared(c);
            (*acc)->nrows=i;
        }
    }
}
Пример #4
0
void freep(poly* addr)
{ index j;
  for (j=0; j<addr->nrows; j++)
  { object c=(object) addr->coef[j];
    assert(isshared(c)); clrshared(c); freemem(c);
  }
  freemem(addr);
}
Пример #5
0
poly* Reduce_pol(poly* p)
{ entry** expon=p->elm; bigint** coef=p->coef; lie_Index t=0,f=0,len=p->ncols;
  heap_sort_p(p,cmpfn);
    /* don't exclude cases~$<2$: we must catch $0$-polynomials */
  while (++f<p->nrows)
    if (coef[f]->size==0) clrshared(coef[f]); /* drop term with zero coef */
    else if (eqrow(expon[f],expon[t],len)) /* equal exponents: add coef's */
    { clrshared(coef[t]); clrshared(coef[f]);
      coef[t]=add(coef[t],coef[f]); setshared(coef[t]);
    }
    else /* now term at f replaces one at t as discriminating term */
    { if (coef[t]->size) t++; else clrshared(coef[t]); /* keep if nonzero */
      swap_terms(expon,coef,t,f); /* move term, preserve row separateness */
    }
  if (p->nrows!=0)
    /* |p| mights have no terms at all (e.g. from |alt_dom|). */
    if (coef[t]->size) t++; else clrshared(coef[t]); /* handle final term */
  else *coef=copybigint(null,NULL); /* safer not to introduce aliasing */
  if ((p->nrows=t)==0) /* then must keep last term; coef is cleared */
  { lie_Index i; p->nrows=1; setshared(*coef); /* |*coef| was |0| but not shared */
    for (i=0; i<len; i++) expon[0][i]=0; /* clear first exponent as well */
  }
  setsorted(p); return p;
}