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; } }
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; }
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; } } }
poly* From_Part_p (poly* p) { _index i,j,n_rows=p->nrows,n=p->ncols; poly* result=mkpoly(n_rows,n-1); entry** lambda=p->elm; entry** res=result->elm; for (i=0; i<n_rows; ++i) { result->coef[i]=p->coef[i]; setshared(p->coef[i]); /* copy coefficient */ for (j=0; j<n-1; ++j) res[i][j]=lambda[i][j]-lambda[i][j+1]; } return Reduce_pol(result); }
poly* To_Part_p (poly* p) { _index i,n_rows=p->nrows,n=p->ncols; entry** wt=p->elm; poly* result=mkpoly(n_rows,n+1); entry** lambda=result->elm; for (i=0; i<n_rows; ++i) { _index j=n; entry sum=0; result->coef[i]=p->coef[i]; setshared(p->coef[i]); while (lambda[i][j]=sum, --j>=0) sum+=wt[i][j]; } return Reduce_pol(result); }
poly *pol_mul_pol_mat(poly *a, matrix *b) { poly *m; int i; if (a->ncols != b->nrows) error("Number variables arg1 unequal number of rows arg2 .\n"); m = mkpoly(a->nrows,b->ncols); mulmatmatelm(a->elm,b->elm,m->elm,a->nrows,a->ncols,b->ncols); for (i=0;i<m->nrows;i++) { m->coef[i] = a->coef[i]; setshared(m->coef[i]); } return m; }
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; }
poly* alt_Wsum(poly* p) { lie_Index i,k=0,r=p->ncols; poly* result; entry** res,*rho=mkintarray(r); p=Alt_dom(p); for (i=0; i<r; ++i) rho[i]=1; for (i=0; i<p->nrows; ++i) add_xrow_to(p->elm[i],1,rho,r); result=mkpoly(p->nrows*bigint2entry(Worder(grp)),r); res=result->elm; for (i=0; i<p->nrows; ++i) { lie_Index j,l; matrix* orbit=Weyl_orbit(p->elm[i],NULL); entry** x=orbit->elm; bigint* c=p->coef[i],* min_c=sub(null,c); for (j=0; j<orbit->nrows; ++j) { subrow(*x,rho,res[k],r); l=make_dominant(*x++)%2; result->coef[k]= l ? min_c : c; setshared(result->coef[k]); ++k; } freemem(orbit); } freearr(rho); assert(k==result->nrows); return result; /* not sorted, but rows are unique */ }
poly* Adjoint(object grp) { _index i,j,r=Lierank(grp) ,n=type_of(grp)==SIMPGRP ? 1: grp->g.ncomp+(grp->g.toraldim!=0); poly* adj= mkpoly(n,r); for (i=0; i<n; ++i) { adj->coef[i]=one; for (j=0; j<r; ++j) adj->elm[i][j]=0; } if (type_of(grp)==SIMPGRP) set_simp_adjoint(adj->elm[0],&grp->s); else { _index offs=0; simpgrp* g; for (i=0; i<grp->g.ncomp; offs+=g->lierank,++i) set_simp_adjoint(&adj->elm[i][offs],g=Liecomp(grp,i)); if (grp->g.toraldim!=0) { adj->coef[i]=entry2bigint(grp->g.toraldim); setshared(adj->coef[i]); } } return adj; }
poly* Worbit_p(poly* p) { lie_Index i,k=0,l=0,r=p->ncols; poly* result; entry** res; p=copypoly(p); for (i=0; i<p->nrows; ++i) make_dominant(p->elm[i]); Reduce_pol(p); for (i=0; i<p->nrows; ++i) if ((l += bigint2entry(Orbitsize(p->elm[i])))<0) error ("That's too large an orbit"); result=mkpoly(l,p->ncols); res=result->elm; for (i=0; i<p->nrows; ++i) { lie_Index j; matrix* orbit=Weyl_orbit(p->elm[i],NULL); entry** x=orbit->elm; for (j=0; j<orbit->nrows; ++j) { result->coef[k]=p->coef[i]; setshared(p->coef[i]); copyrow(*x++,res[k++],r); } freemem(orbit); } assert(k==result->nrows); return result; /* not sorted, but rows are unique */ }