Changeset f7ed7d in git


Ignore:
Timestamp:
Apr 19, 2013, 3:38:53 PM (11 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'spielwiese', '17f1d200f27c5bd38f5dfc6e8a0879242279d1d8')
Children:
4553b124a4bec0578e5f5f8d00c2d61d8464a7d6
Parents:
17a7106fdd1564dd01cf087f4bccde563274952e
git-author:
Martin Lee <martinlee84@web.de>2013-04-19 15:38:53+02:00
git-committer:
Martin Lee <martinlee84@web.de>2013-05-02 11:42:39+02:00
Message:
chg: convenient way to call absBiFact (i.e. handling of ring changes) via
     absBiFactorize
TODO: may be handle Gerhard's special output for absPrimDec
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/absfact.lib

    r17a710 rf7ed7d  
    609609}
    610610
     611proc absBiFactorize(poly p, list #)
     612{
     613  int dblevel = printlevel - voice + 2;
     614  dbprint(dblevel,"Entering absfact.lib::absBiFactorize with ",p);
     615  def MP = basering;
     616  int i;
     617  if (char(MP) != 0)
     618  {
     619    ERROR("// absfact.lib::absBiFactorize is only implemented for "+
     620          "characteristic 0");
     621  }
     622  if(minpoly!=0)
     623  {
     624    ERROR("// absfact.lib::absBiFactorize is not implemented for algebraic "
     625          +"extensions");
     626  }
     627
     628  int n = nvars(MP);
     629  int pa=npars(MP);
     630  list lMP= ringlist(MP);
     631  intvec vv,vk;
     632  for(i=1;i<=n;i++){vv[i]=1;}
     633  vk=vv,1;
     634
     635  //if the basering has parameters, add the parameters to the variables
     636  //takes care about coefficients and possible denominators
     637  if(pa>0)
     638  {
     639    poly qh=cleardenom(p);
     640    if (p==0)
     641    {
     642      number cok=0;
     643    }
     644    else
     645    {
     646      number cok=leadcoef(p)/leadcoef(qh);
     647    }
     648    p=qh;
     649    string sp;
     650    for(i=1;i<=npars(basering);i++)
     651    {
     652      sp=string(par(i));
     653      sp=sp[2..size(sp)-1];
     654      lMP[2][n+i]=sp;
     655      vv=vv,1;
     656    }
     657    lMP[1]=0;
     658    n=n+npars(MP);
     659  }
     660
     661  // MPz is obtained by adding the new variable @z to MP
     662  // ordering is wp(1...1)
     663  // All the above subroutines work in MPz
     664  string newvar;
     665  if(size(#)>0)
     666  {
     667    if(typeof(#[1])=="string")
     668    {
     669      newvar=#[1];
     670    }
     671    else
     672    {
     673      newvar = "a";
     674    }
     675  }
     676  else
     677  {
     678    newvar = "a";
     679  }
     680  if (newvar=="a")
     681  {
     682    if(belongTo(newvar, lMP[2])||defined(a)){newvar = "b";}
     683    if(belongTo(newvar, lMP[2])||defined(b)){newvar = "c";}
     684    if(belongTo(newvar, lMP[2])||defined(c)){newvar = "@c";}
     685    while(belongTo(newvar, lMP[2]))
     686    {
     687       newvar = "@" + newvar;
     688    }
     689  }
     690
     691  // create ring with extra parameter `newvar` for output:
     692  setring(MP);
     693  list Lout=ringlist(MP);
     694  if(!pa)
     695  {
     696    list Lpar=list(char(MP),list(newvar),list(list("lp",intvec(1))),ideal(0));
     697  }
     698  else
     699  {
     700    list Lpar=Lout[1];
     701    Lpar[2][size(Lpar[2])+1]=newvar;
     702    vv=Lpar[3][1][2];
     703    vv=vv,1;
     704    Lpar[3][1][2]=vv;
     705  }
     706  Lout[1]=Lpar;
     707  def MPo=ring(Lout);
     708  setring(MPo);
     709
     710  poly p=imap(MP,p);
     711
     712  if (size (variables (p)) > 2)
     713  {
     714    ERROR("// absfact.lib::absBiFactorize is not implemented for polynomials "
     715          +"with more than 2 variables");
     716  }
     717
     718  // special treatment in the homogeneous case, dropping one variable
     719  // by substituting the first variable by 1
     720  int ho=homog(p);
     721  if(ho)
     722  {
     723    int dh=deg(p);
     724    p=subst(p,var(1),1);
     725    int di=deg(p);
     726  }
     727
     728  MPo;
     729  list tmpf=absBiFact (p);
     730
     731  // the homogeneous case, homogenizing the result
     732  // the new variable has to have degree 0
     733  // need to change the ring
     734  if(ho)
     735  {
     736    list ll=ringlist(MPo);
     737    vv[size(vv)]=0;
     738    ll[3][1][2]=vv;
     739    def MPhelp=ring(ll);
     740    setring(MPhelp);
     741    list tmpf=imap(MPo,tmpf);
     742    for(i=2;i<=size(tmpf[1]);i++)
     743    {
     744      tmpf[1][i]=homog(tmpf[1][i],var(1));
     745    }
     746    if(dh>di)
     747    {
     748      tmpf[1][size(tmpf[1])+1]=var(1);
     749      tmpf[2][size(tmpf[2])+1]=dh-di;
     750      tmpf[3][size(tmpf[3])+1]=par(npars(MPo));
     751      tmpf[4]= tmpf[4]+dh-di;
     752    }
     753    setring(MPo);
     754    tmpf=imap(MPhelp,tmpf);
     755  }
     756
     757  // if we want the output as string
     758  if(size(#)>0)
     759  {
     760    if(typeof(#[1])=="int")
     761    {
     762      if(#[1]==77)
     763      {  // undocumented feature for Gerhard's absPrimdecGTZ
     764        if (size(tmpf[1])<2){ list abs_fac = list(var(n+1),poly(1)); }
     765        else
     766        {
     767          list abs_fac= tmpf[3][2];
     768          abs_fac= abs_fac, tmpf[1][2];
     769          for (i= 3; i <= size(tmpf[1]); i++)
     770          {
     771            abs_fac=abs_fac,tmpf[3][i];
     772            abs_fac=abs_fac,tmpf[1][i];
     773          }
     774        }
     775        abs_fac=abs_fac,newvar;
     776        return(string(abs_fac)); //TODO muss ich Parameter zu Variable machen
     777      }
     778    }
     779  }
     780
     781  list absolute_factors= tmpf;
     782  export absolute_factors;
     783  setring(MP);
     784
     785  dbprint( printlevel-voice+3,"
     786// 'absFactorize' created a ring, in which a list absolute_factors (the
     787// absolute factors) is stored.
     788// To access the list of absolute factors, type (if the name S was assigned
     789// to the return value):
     790        setring(S); absolute_factors; ");
     791  return(MPo);
     792}
     793
     794
    611795/*
    612796  ring r=0,(x,t),dp;
Note: See TracChangeset for help on using the changeset viewer.