Skip to content

Commit

Permalink
chg: changed behaviour of sqrfree with optional argument 3
Browse files Browse the repository at this point in the history
(according to master)
  • Loading branch information
mmklee committed Jan 5, 2012
1 parent 0fc4c8b commit c92097b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Singular/iparith.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3151,7 +3151,7 @@ static BOOLEAN jjSQR_FREE2(leftv res, leftv u, leftv dummy)
intvec *v=NULL;
int sw=(int)(long)dummy->Data();
int fac_sw=sw;
if ((sw<0)||(sw>2)) fac_sw=1;
if (sw<0) fac_sw=1;
singclap_factorize_retry=0;
ideal f=singclap_sqrfree((poly)(u->CopyD()), &v, fac_sw, currRing);
if (f==NULL)
Expand Down
2 changes: 1 addition & 1 deletion doc/reference.doc
Original file line number Diff line number Diff line change
Expand Up @@ -6637,7 +6637,7 @@ the multiplicities (as an intvec) depending on the second argument:
May also be written with only one argument.
1: returns non-constant factors (no multiplicities).
2: returns non-constant factors and multiplicities.
3: returns the product of non-constant factors, i.e. squarefree part
3: returns the product of factors (including constant), i.e. squarefree part
@end format
@item @strong{Note:}
Not implemented for the coefficient fields real and finite fields of
Expand Down
23 changes: 13 additions & 10 deletions libpolys/polys/clapsing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ ideal singclap_sqrfree ( poly f, intvec ** v , int with_exps, const ring r)
if (f==NULL)
{
res=idInit(1,1);
if (with_exps!=1)
if (with_exps!=1 && with_exps!=3)
{
(*v)=new intvec(1);
(**v)[0]=1;
Expand All @@ -982,13 +982,16 @@ ideal singclap_sqrfree ( poly f, intvec ** v , int with_exps, const ring r)
int n=0;
int e;
for(i=rVar(r);i>0;i--) if(p_GetExp(f,i,r)!=0) n++;
if (with_exps==0) n++; // with coeff
if (with_exps==0 || with_exps==3) n++; // with coeff
res=idInit(si_max(n,1),1);
switch(with_exps)
{
case 0: // with coef & exp.
res->m[0]=p_NSet(n_Copy(pGetCoeff(f),r->cf),r);
// no break
case 3: // with coef & exp.
res->m[0]=p_NSet(n_Copy(pGetCoeff(f),r->cf),r);
// no break
case 2: // with exp.
(*v)=new intvec(si_max(1,n));
(**v)[0]=1;
Expand Down Expand Up @@ -1040,14 +1043,14 @@ ideal singclap_sqrfree ( poly f, intvec ** v , int with_exps, const ring r)
{
//if (f!=NULL) // already tested at start of routine
number n0=n_Copy(pGetCoeff(f),r->cf);
if (with_exps==0)
if (with_exps==0 || with_exps==3)
N=n_Copy(n0,r->cf);
p_Cleardenom(f, r);
//after here f should not have a denominator!!
//PrintS("S:");p_Write(f,r);PrintLn();
NN=n_Div(n0,pGetCoeff(f),r->cf);
n_Delete(&n0,r->cf);
if (with_exps==0)
if (with_exps==0 || with_exps==3)
{
n_Delete(&N,r->cf);
N=n_Copy(NN,r->cf);
Expand All @@ -1059,13 +1062,13 @@ ideal singclap_sqrfree ( poly f, intvec ** v , int with_exps, const ring r)
if (singclap_factorize_retry==0)
{
number n0=n_Copy(pGetCoeff(f),r->cf);
if (with_exps==0)
if (with_exps==0 || with_exps==3)
N=n_Copy(n0,r->cf);
p_Norm(f,r);
p_Cleardenom(f, r);
NN=n_Div(n0,pGetCoeff(f),r->cf);
n_Delete(&n0,r->cf);
if (with_exps==0)
if (with_exps==0 || with_exps==3)
{
n_Delete(&N,r->cf);
N=n_Copy(NN,r->cf);
Expand Down Expand Up @@ -1131,15 +1134,15 @@ ideal singclap_sqrfree ( poly f, intvec ** v , int with_exps, const ring r)
}
*v = new intvec( n );
}
else if (L.getFirst().factor().inCoeffDomain())
else if (L.getFirst().factor().inCoeffDomain() && with_exps!=3)
{
n--;
J++;
}
res = idInit( n ,1);
for ( ; J.hasItem(); J++, j++ )
{
if (with_exps!=1) (**v)[j] = J.getItem().exp();
if (with_exps!=1 && with_exps!=3) (**v)[j] = J.getItem().exp();
if (rField_is_Zp(r) || rField_is_Q(r))
res->m[j] = convFactoryPSingP( J.getItem().factor(),r );
else if (rField_is_Extension(r)) /* Q(a), Fp(a) */
Expand All @@ -1165,12 +1168,12 @@ ideal singclap_sqrfree ( poly f, intvec ** v , int with_exps, const ring r)
{
int i=IDELEMS(res)-1;
int stop=1;
if (with_exps!=0) stop=0;
if (with_exps!=0 || with_exps==3) stop=0;
for(;i>=stop;i--)
{
p_Norm(res->m[i],r);
}
if (with_exps==0) p_SetCoeff(res->m[0],old_lead_coeff,r);
if (with_exps==0 || with_exps==3) p_SetCoeff(res->m[0],old_lead_coeff,r);
else n_Delete(&old_lead_coeff,r->cf);
}
else
Expand Down

0 comments on commit c92097b

Please sign in to comment.