Typedefs | Functions
clapsing.h File Reference

Go to the source code of this file.

Typedefs

typedef polyrec * poly
 
typedef ip_smatrixmatrix
 

Functions

poly singclap_gcd (poly f, poly g, const ring r)
 destroys f and g More...
 
poly singclap_gcd_r (poly f, poly g, const ring r)
 
poly singclap_gcd_and_divide (poly &f, poly &g, const ring r)
 clears denominators of f and g, divides by gcd(f,g) More...
 
poly singclap_resultant (poly f, poly g, poly x, const ring r)
 
BOOLEAN singclap_extgcd (poly f, poly g, poly &res, poly &pa, poly &pb, const ring r)
 
poly singclap_pdivide (poly f, poly g, const ring r)
 
void singclap_divide_content (poly f, const ring r)
 
ideal singclap_factorize (poly f, intvec **v, int with_exps, const ring r)
 
ideal singclap_sqrfree (poly f, intvec **v, int with_exps, const ring r)
 
matrix singntl_HNF (matrix A, const ring r)
 
intvecsingntl_HNF (intvec *A)
 
matrix singntl_LLL (matrix A, const ring r)
 
intvecsingntl_LLL (intvec *A)
 
ideal singclap_absFactorize (poly f, ideal &mipos, intvec **exps, int &n, const ring r)
 
matrix singclap_irrCharSeries (ideal I, const ring r)
 
char * singclap_neworder (ideal I, const ring r)
 
poly singclap_det (const matrix m, const ring r)
 
int singclap_det_i (intvec *m, const ring r)
 
number singclap_det_bi (bigintmat *m, const coeffs cf)
 
number nChineseRemainder (number *x, number *q, int rl, const coeffs r)
 

Typedef Documentation

typedef ip_smatrix* matrix

Definition at line 20 of file clapsing.h.

typedef polyrec* poly

Definition at line 16 of file clapsing.h.

Function Documentation

number nChineseRemainder ( number *  x,
number *  q,
int  rl,
const coeffs  r 
)
ideal singclap_absFactorize ( poly  f,
ideal &  mipos,
intvec **  exps,
int &  n,
const ring  r 
)

Definition at line 1762 of file clapsing.cc.

1763 {
1764  p_Test(f, r);
1765 
1766  ideal res=NULL;
1767 
1768  int offs = rPar(r);
1769  if (f==NULL)
1770  {
1771  res= idInit (1, 1);
1772  mipos= idInit (1, 1);
1773  mipos->m[0]= convFactoryPSingTrP (Variable (offs), r); //overkill
1774  (*exps)=new intvec (1);
1775  (**exps)[0]= 1;
1776  numFactors= 0;
1777  return res;
1778  }
1780 
1781  bool isRat= isOn (SW_RATIONAL);
1782  if (!isRat)
1783  On (SW_RATIONAL);
1784 
1785  CFAFList absFactors= absFactorize (F);
1786 
1787  int n= absFactors.length();
1788  *exps=new intvec (n);
1789 
1790  res= idInit (n, 1);
1791 
1792  mipos= idInit (n, 1);
1793 
1794  Variable x= Variable (offs);
1795  Variable alpha;
1796  int i= 0;
1797  numFactors= 0;
1798  int count;
1799  CFAFListIterator iter= absFactors;
1800  CanonicalForm lead= iter.getItem().factor();
1801  if (iter.getItem().factor().inCoeffDomain())
1802  {
1803  i++;
1804  iter++;
1805  }
1806  for (; iter.hasItem(); iter++, i++)
1807  {
1808  (**exps)[i]= iter.getItem().exp();
1809  alpha= iter.getItem().minpoly().mvar();
1810  if (iter.getItem().minpoly().isOne())
1811  lead /= power (bCommonDen (iter.getItem().factor()), iter.getItem().exp());
1812  else
1813  lead /= power (power (bCommonDen (iter.getItem().factor()), degree (iter.getItem().minpoly())), iter.getItem().exp());
1814  res->m[i]= convFactoryPSingTrP (replacevar (iter.getItem().factor()*bCommonDen (iter.getItem().factor()), alpha, x), r);
1815  if (iter.getItem().minpoly().isOne())
1816  {
1817  count= iter.getItem().exp();
1818  mipos->m[i]= convFactoryPSingTrP (x,r);
1819  }
1820  else
1821  {
1822  count= iter.getItem().exp()*degree (iter.getItem().minpoly());
1823  mipos->m[i]= convFactoryPSingTrP (replacevar (iter.getItem().minpoly(), alpha, x), r);
1824  }
1825  if (!iter.getItem().minpoly().isOne())
1826  prune (alpha);
1827  numFactors += count;
1828  }
1829  if (!isRat)
1830  Off (SW_RATIONAL);
1831 
1832  (**exps)[0]= 1;
1833  res->m[0]= convFactoryPSingTrP (lead, r);
1834  mipos->m[0]= convFactoryPSingTrP (x, r);
1835  return res;
1836 }
int status int void size_t count
Definition: si_signals.h:59
CanonicalForm power(const CanonicalForm &f, int n)
exponentiation
void Off(int sw)
switches
f
Definition: cfModGcd.cc:4022
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:547
factory's class for variables
Definition: variable.h:32
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
CFFListIterator iter
Definition: facAbsBiFact.cc:54
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
factory's main class
Definition: canonicalform.h:75
Variable alpha
Definition: facAbsBiFact.cc:52
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
bool isOn(int sw)
switches
void On(int sw)
switches
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
void prune(Variable &alpha)
Definition: variable.cc:261
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
#define p_Test(p, r)
Definition: p_polys.h:160
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
#define NULL
Definition: omList.c:10
T & getItem() const
Definition: ftmpl_list.cc:431
Variable x
Definition: cfModGcd.cc:4023
int degree(const CanonicalForm &f)
CFAFList absFactorize(const CanonicalForm &G)
absolute factorization of a multivariate poly over Q
Definition: facAbsFact.cc:267
CanonicalForm replacevar(const CanonicalForm &, const Variable &, const Variable &)
CanonicalForm replacevar ( const CanonicalForm & f, const Variable & x1, const Variable & x2 ) ...
Definition: cf_ops.cc:271
poly singclap_det ( const matrix  m,
const ring  r 
)

Definition at line 1579 of file clapsing.cc.

1580 {
1581  int r=m->rows();
1582  if (r!=m->cols())
1583  {
1584  Werror("det of %d x %d matrix",r,m->cols());
1585  return NULL;
1586  }
1587  poly res=NULL;
1588  CFMatrix M(r,r);
1589  int i,j;
1590  for(i=r;i>0;i--)
1591  {
1592  for(j=r;j>0;j--)
1593  {
1594  M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s);
1595  }
1596  }
1597  res= convFactoryPSingP( determinant(M,r),s ) ;
1598  Off(SW_RATIONAL);
1599  return res;
1600 }
int & rows()
Definition: matpol.h:24
const CanonicalForm int s
Definition: facAbsFact.cc:55
void Off(int sw)
switches
poly res
Definition: myNF.cc:322
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
int i
Definition: cfEzgcd.cc:123
int & cols()
Definition: matpol.h:25
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
CanonicalForm determinant(const CFMatrix &M, int n)
Definition: cf_linsys.cc:222
polyrec * poly
Definition: hilb.h:10
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define MATELEM(mat, i, j)
Definition: matpol.h:29
number singclap_det_bi ( bigintmat m,
const coeffs  cf 
)

Definition at line 1620 of file clapsing.cc.

1621 {
1622  assume(m->basecoeffs()==cf);
1623  CFMatrix M(m->rows(),m->cols());
1624  int i,j;
1625  BOOLEAN setchar=TRUE;
1626  for(i=m->rows();i>0;i--)
1627  {
1628  for(j=m->cols();j>0;j--)
1629  {
1630  M(i,j)=n_convSingNFactoryN(BIMATELEM(*m,i,j),setchar,cf);
1631  setchar=FALSE;
1632  }
1633  }
1634  number res=n_convFactoryNSingN( determinant(M,m->rows()),cf ) ;
1635  return res;
1636 }
#define FALSE
Definition: auxiliary.h:140
number n_convFactoryNSingN(const CanonicalForm n, const coeffs r)
Definition: numbers.cc:560
#define TRUE
Definition: auxiliary.h:144
CanonicalForm n_convSingNFactoryN(number n, BOOLEAN setChar, const coeffs r)
Definition: numbers.cc:565
poly res
Definition: myNF.cc:322
#define M
Definition: sirandom.c:24
int j
Definition: myNF.cc:70
#define assume(x)
Definition: mod2.h:405
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: bigintmat.h:147
#define BIMATELEM(M, I, J)
Definition: bigintmat.h:136
int rows() const
Definition: bigintmat.h:148
CanonicalForm cf
Definition: cfModGcd.cc:4024
coeffs basecoeffs() const
Definition: bigintmat.h:149
CanonicalForm determinant(const CFMatrix &M, int n)
Definition: cf_linsys.cc:222
int BOOLEAN
Definition: auxiliary.h:131
int singclap_det_i ( intvec m,
const ring  r 
)

Definition at line 1602 of file clapsing.cc.

1603 {
1604 // assume( r == currRing ); // Anything else is not guaranted to work!
1605 
1606  setCharacteristic( 0 ); // ?
1607  CFMatrix M(m->rows(),m->cols());
1608  int i,j;
1609  for(i=m->rows();i>0;i--)
1610  {
1611  for(j=m->cols();j>0;j--)
1612  {
1613  M(i,j)=IMATELEM(*m,i,j);
1614  }
1615  }
1616  int res= convFactoryISingI( determinant(M,m->rows()) ) ;
1617  return res;
1618 }
void setCharacteristic(int c)
Definition: cf_char.cc:23
poly res
Definition: myNF.cc:322
#define M
Definition: sirandom.c:24
int convFactoryISingI(const CanonicalForm &f)
Definition: clapconv.cc:114
int j
Definition: myNF.cc:70
int i
Definition: cfEzgcd.cc:123
int cols() const
Definition: intvec.h:87
int rows() const
Definition: intvec.h:88
CanonicalForm determinant(const CFMatrix &M, int n)
Definition: cf_linsys.cc:222
#define IMATELEM(M, I, J)
Definition: intvec.h:77
void singclap_divide_content ( poly  f,
const ring  r 
)

Definition at line 599 of file clapsing.cc.

600 {
601  if ( f==NULL )
602  {
603  return;
604  }
605  else if ( pNext( f ) == NULL )
606  {
607  p_SetCoeff( f, n_Init( 1, r->cf ), r );
608  return;
609  }
610  else
611  {
612  if ( rField_is_Q_a(r) )
613  setCharacteristic( 0 );
614  else if ( rField_is_Zp_a(r) )
616  else
617  return; /* not implemented*/
618 
619  CFList L;
620  CanonicalForm g, h;
621  poly p = pNext(f);
622 
623  // first attemp: find 2 smallest g:
624 
625  number g1=pGetCoeff(f);
626  number g2=pGetCoeff(p); // p==pNext(f);
627  pIter(p);
628  int sz1=n_Size(g1, r->cf);
629  int sz2=n_Size(g2, r->cf);
630  if (sz1>sz2)
631  {
632  number gg=g1;
633  g1=g2; g2=gg;
634  int sz=sz1;
635  sz1=sz2; sz2=sz;
636  }
637  while (p!=NULL)
638  {
639  int n_sz=n_Size(pGetCoeff(p),r->cf);
640  if (n_sz<sz1)
641  {
642  sz2=sz1;
643  g2=g1;
644  g1=pGetCoeff(p);
645  sz1=n_sz;
646  if (sz1<=3) break;
647  }
648  else if(n_sz<sz2)
649  {
650  sz2=n_sz;
651  g2=pGetCoeff(p);
652  sz2=n_sz;
653  }
654  pIter(p);
655  }
656  g = convSingPFactoryP( NUM(((fraction)g1)), r->cf->extRing );
657  g = gcd( g, convSingPFactoryP( NUM(((fraction)g2)) , r->cf->extRing));
658 
659  // second run: gcd's
660 
661  p = f;
662  while ( (p != NULL) && (g != 1) && ( g != 0))
663  {
664  h = convSingPFactoryP( NUM(((fraction)pGetCoeff(p))), r->cf->extRing );
665  pIter( p );
666 
667  g = gcd( g, h );
668 
669  L.append( h );
670  }
671  if (( g == 1 ) || (g == 0))
672  {
673  // pTest(f);
674  return;
675  }
676  else
677  {
679  for ( i = L, p = f; i.hasItem(); i++, p=pNext(p) )
680  {
681  fraction c=(fraction)pGetCoeff(p);
682  p_Delete(&(NUM(c)),r->cf->extRing); // 2nd arg used to be nacRing
683  NUM(c)=convFactoryPSingP( i.getItem() / g, r->cf->extRing );
684  //nTest((number)c);
685  //#ifdef LDEBUG
686  //number cn=(number)c;
687  //StringSetS(""); nWrite(nt); StringAppend(" ==> ");
688  //nWrite(cn);PrintS(StringEndS("\n")); // NOTE/TODO: use StringAppendS("\n"); omFree(s);
689  //#endif
690  }
691  }
692  // pTest(f);
693  }
694 }
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:478
return P p
Definition: myNF.cc:203
f
Definition: cfModGcd.cc:4022
static FORCE_INLINE number n_Init(long i, const coeffs r)
a number representing i in the given coeff field/ring r
Definition: coeffs.h:539
int rChar(ring r)
Definition: ring.cc:684
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
void setCharacteristic(int c)
Definition: cf_char.cc:23
#define pIter(p)
Definition: monomials.h:44
const ring r
Definition: syzextra.cc:208
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
int i
Definition: cfEzgcd.cc:123
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
T & getItem() const
Definition: ftmpl_list.cc:431
int gcd(int a, int b)
Definition: walkSupport.cc:839
#define pNext(p)
Definition: monomials.h:43
void append(const T &)
Definition: ftmpl_list.cc:256
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
static FORCE_INLINE int n_Size(number n, const coeffs r)
return a non-negative measure for the complexity of n; return 0 only when n represents zero; (used fo...
Definition: coeffs.h:571
BOOLEAN singclap_extgcd ( poly  f,
poly  g,
poly res,
poly pa,
poly pb,
const ring  r 
)

Definition at line 460 of file clapsing.cc.

461 {
462  // for now there is only the possibility to handle univariate
463  // polynomials over
464  // Q and Fp ...
465  res=NULL;pa=NULL;pb=NULL;
467  if ( rField_is_Q(r) || rField_is_Zp(r) )
468  {
471  CanonicalForm FpG=F+G;
472  if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
473  //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
474  {
475  Off(SW_RATIONAL);
476  WerrorS("not univariate");
477  return TRUE;
478  }
479  CanonicalForm Fa,Gb;
480  On(SW_RATIONAL);
481  res=convFactoryPSingP( extgcd( F, G, Fa, Gb ),r );
482  pa=convFactoryPSingP(Fa,r);
483  pb=convFactoryPSingP(Gb,r);
484  Off(SW_RATIONAL);
485  }
486  // and over Q(a) / Fp(a)
487  else if ( r->cf->extRing!=NULL )
488  {
489  if (rField_is_Q_a(r)) setCharacteristic( 0 );
490  else setCharacteristic( rChar(r) );
491  CanonicalForm Fa,Gb;
492  if (r->cf->extRing->qideal!=NULL)
493  {
494  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
495  r->cf->extRing);
496  Variable a=rootOf(mipo);
498  G( convSingAPFactoryAP( g,a,r ) );
499  CanonicalForm FpG=F+G;
500  if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
501  //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
502  {
503  WerrorS("not univariate");
504  return TRUE;
505  }
506  res= convFactoryAPSingAP( extgcd( F, G, Fa, Gb ),r );
507  pa=convFactoryAPSingAP(Fa,r);
508  pb=convFactoryAPSingAP(Gb,r);
509  prune (a);
510  }
511  else
512  {
514  CanonicalForm FpG=F+G;
515  if (!(FpG.isUnivariate()|| FpG.inCoeffDomain()))
516  //if (!F.isUnivariate() || !G.isUnivariate() || F.mvar()!=G.mvar())
517  {
518  Off(SW_RATIONAL);
519  WerrorS("not univariate");
520  return TRUE;
521  }
522  res= convFactoryPSingTrP( extgcd( F, G, Fa, Gb ), r );
523  pa=convFactoryPSingTrP(Fa, r);
524  pb=convFactoryPSingTrP(Gb, r);
525  }
526  Off(SW_RATIONAL);
527  }
528  else
529  {
531  return TRUE;
532  }
533 #ifndef SING_NDEBUG
534  // checking the result of extgcd:
535  poly dummy;
536  dummy=p_Sub(p_Add_q(pp_Mult_qq(f,pa,r),pp_Mult_qq(g,pb,r),r),p_Copy(res,r),r);
537  if (dummy!=NULL)
538  {
539  PrintS("extgcd( ");p_Write(f,r);p_Write0(g,r);PrintS(" )\n");
540  PrintS("extgcd( ");p_Write(f,r);p_Write0(g,r);PrintS(" )\n");
541  p_Delete(&dummy,r);
542  }
543 #endif
544  return FALSE;
545 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
bool inCoeffDomain() const
CanonicalForm extgcd(const CanonicalForm &f, const CanonicalForm &g, CanonicalForm &a, CanonicalForm &b)
CanonicalForm extgcd ( const CanonicalForm & f, const CanonicalForm & g, CanonicalForm & a...
Definition: cfUnivarGcd.cc:173
#define FALSE
Definition: auxiliary.h:140
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: variable.h:32
int rChar(ring r)
Definition: ring.cc:684
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
#define TRUE
Definition: auxiliary.h:144
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static TreeM * G
Definition: janet.cc:38
poly p_Sub(poly p1, poly p2, const ring r)
Definition: p_polys.cc:1901
void setCharacteristic(int c)
Definition: cf_char.cc:23
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
static poly pp_Mult_qq(poly p, poly q, const ring r)
Definition: p_polys.h:1075
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
void PrintS(const char *s)
Definition: reporter.cc:294
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
bool isUnivariate() const
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
void p_Write0(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:196
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
void p_Write(poly p, ring lmRing, ring tailRing)
Definition: polys0.cc:206
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
static poly p_Add_q(poly p, poly q, const ring r)
Definition: p_polys.h:884
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition: cf_defs.h:30
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
ideal singclap_factorize ( poly  f,
intvec **  v,
int  with_exps,
const ring  r 
)

Definition at line 784 of file clapsing.cc.

786 {
787  p_Test(f,r);
788 #ifdef FACTORIZE2_DEBUG
789  printf("singclap_factorize, degree %ld\n",p_Totaldegree(f,r));
790 #endif
791  // with_exps: 3,1 return only true factors, no exponents
792  // 2 return true factors and exponents
793  // 0 return coeff, factors and exponents
794  BOOLEAN save_errorreported=errorreported;
795 
796  ideal res=NULL;
797 
798  // handle factorize(0) =========================================
799  if (f==NULL)
800  {
801  res=idInit(1,1);
802  if (with_exps!=1)
803  {
804  (*v)=new intvec(1);
805  (**v)[0]=1;
806  }
807  return res;
808  }
809  // handle factorize(mon) =========================================
810  if (pNext(f)==NULL)
811  {
812  int i=0;
813  int n=0;
814  int e;
815  for(i=rVar(r);i>0;i--) if(p_GetExp(f,i,r)!=0) n++;
816  if (with_exps==0) n++; // with coeff
817  res=idInit(si_max(n,1),1);
818  switch(with_exps)
819  {
820  case 0: // with coef & exp.
821  res->m[0]=p_NSet(n_Copy(pGetCoeff(f),r->cf),r);
822  // no break
823  case 2: // with exp.
824  (*v)=new intvec(si_max(1,n));
825  (**v)[0]=1;
826  // no break
827  case 1: ;
828 #ifdef TEST
829  default: ;
830 #endif
831  }
832  if (n==0)
833  {
834  res->m[0]=p_One(r);
835  // (**v)[0]=1; is already done
836  }
837  else
838  {
839  for(i=rVar(r);i>0;i--)
840  {
841  e=p_GetExp(f,i,r);
842  if(e!=0)
843  {
844  n--;
845  poly p=p_One(r);
846  p_SetExp(p,i,1,r);
847  p_Setm(p,r);
848  res->m[n]=p;
849  if (with_exps!=1) (**v)[n]=e;
850  }
851  }
852  }
853  p_Delete(&f,r);
854  return res;
855  }
856  //PrintS("S:");p_Write(f,r);PrintLn();
857  // use factory/libfac in general ==============================
858  Off(SW_RATIONAL);
860  CFFList L;
861  number N=NULL;
862  number NN=NULL;
863  number old_lead_coeff=n_Copy(pGetCoeff(f), r->cf);
864 
865  Variable a;
866  if (!rField_is_Zp(r) && !rField_is_Zp_a(r)) /* Q, Q(a) */
867  {
868  //if (f!=NULL) // already tested at start of routine
869  {
870  number n0=n_Copy(pGetCoeff(f),r->cf);
871  if (with_exps==0)
872  N=n_Copy(n0,r->cf);
873  p_Cleardenom(f, r);
874  //after here f should not have a denominator!!
875  //PrintS("S:");p_Write(f,r);PrintLn();
876  NN=n_Div(n0,pGetCoeff(f),r->cf);
877  n_Delete(&n0,r->cf);
878  if (with_exps==0)
879  {
880  n_Delete(&N,r->cf);
881  N=n_Copy(NN,r->cf);
882  }
883  }
884  }
885  else if (rField_is_Zp_a(r))
886  {
887  //if (f!=NULL) // already tested at start of routine
889  {
890  number n0=n_Copy(pGetCoeff(f),r->cf);
891  if (with_exps==0)
892  N=n_Copy(n0,r->cf);
893  p_Norm(f,r);
894  p_Cleardenom(f, r);
895  NN=n_Div(n0,pGetCoeff(f),r->cf);
896  n_Delete(&n0,r->cf);
897  if (with_exps==0)
898  {
899  n_Delete(&N,r->cf);
900  N=n_Copy(NN,r->cf);
901  }
902  }
903  }
904  if (rField_is_Q(r) || rField_is_Zp(r))
905  {
908  L = factorize( F );
909  }
910  // and over Q(a) / Fp(a)
911  else if (r->cf->extRing!=NULL)
912  {
913  if (rField_is_Q_a (r)) setCharacteristic (0);
914  else setCharacteristic( rChar(r) );
915  if (r->cf->extRing->qideal!=NULL)
916  {
917  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
918  r->cf->extRing);
919  a=rootOf(mipo);
920  CanonicalForm F( convSingAPFactoryAP( f, a, r ) );
921  if (rField_is_Zp_a(r))
922  {
923  L = factorize( F, a );
924  }
925  else
926  {
927  // over Q(a)
928  L= factorize (F, a);
929  }
930  }
931  else
932  {
934  L = factorize( F );
935  }
936  }
937  else
938  {
939  goto notImpl;
940  }
941  {
942  poly ff=p_Copy(f,r); // a copy for the retry stuff
943  // the first factor should be a constant
944  if ( ! L.getFirst().factor().inCoeffDomain() )
945  L.insert(CFFactor(1,1));
946  // convert into ideal
947  int n = L.length();
948  if (n==0) n=1;
949  CFFListIterator J=L;
950  int j=0;
951  if (with_exps!=1)
952  {
953  if ((with_exps==2)&&(n>1))
954  {
955  n--;
956  J++;
957  }
958  *v = new intvec( n );
959  }
960  res = idInit( n ,1);
961  for ( ; J.hasItem(); J++, j++ )
962  {
963  if (with_exps!=1) (**v)[j] = J.getItem().exp();
964  if (rField_is_Zp(r) || rField_is_Q(r)) /* Q, Fp */
965  {
966  //count_Factors(res,*v,f, j, convFactoryPSingP( J.getItem().factor() );
967  res->m[j] = convFactoryPSingP( J.getItem().factor(),r );
968  }
969 #if 0
970  else if (rField_is_GF())
971  res->m[j] = convFactoryGFSingGF( J.getItem().factor() );
972 #endif
973  else if (r->cf->extRing!=NULL) /* Q(a), Fp(a) */
974  {
975 #ifndef SING_NDEBUG
976  intvec *w=NULL;
977  if (v!=NULL) w=*v;
978 #endif
979  if (r->cf->extRing->qideal==NULL)
980  {
981 #ifdef SING_NDEBUG
982  res->m[j]= convFactoryPSingTrP( J.getItem().factor(),r );
983 #else
984  if(!count_Factors(res,w,j,ff,convFactoryPSingTrP( J.getItem().factor(),r ),r))
985  {
986  if (w!=NULL)
987  (*w)[j]=1;
988  res->m[j]=p_One(r);
989  }
990 #endif
991  }
992  else
993  {
994 #ifdef SING_NDEBUG
995  res->m[j]= convFactoryAPSingAP( J.getItem().factor(),r );
996 #else
997  if (!count_Factors(res,w,j,ff,convFactoryAPSingAP( J.getItem().factor(),r ),r))
998  {
999  if (w!=NULL)
1000  (*w)[j]=1;
1001  res->m[j]=p_One(r);
1002  }
1003 #endif
1004  }
1005  }
1006  }
1007  if (r->cf->extRing!=NULL)
1008  if (r->cf->extRing->qideal!=NULL)
1009  prune (a);
1010 #ifndef SING_NDEBUG
1011  if ((r->cf->extRing!=NULL) && (!p_IsConstantPoly(ff,r)))
1012  {
1015  {
1016  int jj;
1017 #ifdef FACTORIZE2_DEBUG
1018  printf("factorize_retry\n");
1019 #endif
1020  intvec *ww=NULL;
1021  id_Test(res,r);
1022  ideal h=singclap_factorize ( ff, &ww , with_exps, r );
1023  id_Test(h,r);
1024  int l=(*v)->length();
1025  (*v)->resize(l+ww->length());
1026  for(jj=0;jj<ww->length();jj++)
1027  (**v)[jj+l]=(*ww)[jj];
1028  delete ww;
1029  ideal hh=idInit(IDELEMS(res)+IDELEMS(h),1);
1030  for(jj=IDELEMS(res)-1;jj>=0;jj--)
1031  {
1032  hh->m[jj]=res->m[jj];
1033  res->m[jj]=NULL;
1034  }
1035  for(jj=IDELEMS(h)-1;jj>=0;jj--)
1036  {
1037  hh->m[jj+IDELEMS(res)]=h->m[jj];
1038  h->m[jj]=NULL;
1039  }
1040  id_Delete(&res,r);
1041  id_Delete(&h,r);
1042  res=hh;
1043  id_Test(res,r);
1044  ff=NULL;
1045  }
1046  else
1047  {
1048  WarnS("problem with factorize");
1049 #if 0
1050  pWrite(ff);
1051  idShow(res);
1052 #endif
1053  id_Delete(&res,r);
1054  res=idInit(2,1);
1055  res->m[0]=p_One(r);
1056  res->m[1]=ff; ff=NULL;
1057  }
1058  }
1059 #endif
1060  p_Delete(&ff,r);
1061  if (N!=NULL)
1062  {
1063  p_Mult_nn(res->m[0],N,r);
1064  n_Delete(&N,r->cf);
1065  N=NULL;
1066  }
1067  // delete constants
1068  if (res!=NULL)
1069  {
1070  int i=IDELEMS(res)-1;
1071  int j=0;
1072  for(;i>=0;i--)
1073  {
1074  if ((res->m[i]!=NULL)
1075  && (pNext(res->m[i])==NULL)
1076  && (p_IsConstant(res->m[i],r)))
1077  {
1078  if (with_exps!=0)
1079  {
1080  p_Delete(&(res->m[i]),r);
1081  if ((v!=NULL) && ((*v)!=NULL))
1082  (**v)[i]=0;
1083  j++;
1084  }
1085  else if (i!=0)
1086  {
1087  while ((v!=NULL) && ((*v)!=NULL) && ((**v)[i]>1))
1088  {
1089  res->m[0]=p_Mult_q(res->m[0],p_Copy(res->m[i],r),r);
1090  (**v)[i]--;
1091  }
1092  res->m[0]=p_Mult_q(res->m[0],res->m[i],r);
1093  res->m[i]=NULL;
1094  if ((v!=NULL) && ((*v)!=NULL))
1095  (**v)[i]=1;
1096  j++;
1097  }
1098  }
1099  }
1100  if (j>0)
1101  {
1102  idSkipZeroes(res);
1103  if ((v!=NULL) && ((*v)!=NULL))
1104  {
1105  intvec *w=*v;
1106  int len=IDELEMS(res);
1107  *v = new intvec( len );
1108  for (i=0,j=0;i<si_min(w->length(),len);i++)
1109  {
1110  if((*w)[i]!=0)
1111  {
1112  (**v)[j]=(*w)[i]; j++;
1113  }
1114  }
1115  delete w;
1116  }
1117  }
1118  if (res->m[0]==NULL)
1119  {
1120  res->m[0]=p_One(r);
1121  }
1122  }
1123  }
1124  if (rField_is_Q_a(r) && (r->cf->extRing->qideal!=NULL))
1125  {
1126  int i=IDELEMS(res)-1;
1127  int stop=1;
1128  if (with_exps!=0) stop=0;
1129  for(;i>=stop;i--)
1130  {
1131  p_Norm(res->m[i],r);
1132  }
1133  if (with_exps==0) p_SetCoeff(res->m[0],old_lead_coeff,r);
1134  else n_Delete(&old_lead_coeff,r->cf);
1135  }
1136  else
1137  n_Delete(&old_lead_coeff,r->cf);
1138  errorreported=save_errorreported;
1139 notImpl:
1140  if (res==NULL)
1142  if (NN!=NULL)
1143  {
1144  n_Delete(&NN,r->cf);
1145  }
1146  if (N!=NULL)
1147  {
1148  n_Delete(&N,r->cf);
1149  }
1150  if (f!=NULL) p_Delete(&f,r);
1151  //PrintS("......S\n");
1152  return res;
1153 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:478
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
return P p
Definition: myNF.cc:203
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: variable.h:32
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1448
#define id_Test(A, lR)
Definition: simpleideals.h:80
int rChar(ring r)
Definition: ring.cc:684
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
void id_Delete(ideal *h, ring r)
deletes an ideal/module/matrix
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
int length() const
Definition: intvec.h:86
static long p_Totaldegree(poly p, const ring r)
Definition: p_polys.h:1435
void pWrite(poly p)
Definition: polys.h:279
void WerrorS(const char *s)
Definition: feFopen.cc:24
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:470
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3565
void insert(const T &)
Definition: ftmpl_list.cc:193
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
#define WarnS
Definition: emacs.cc:81
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
void setCharacteristic(int c)
Definition: cf_char.cc:23
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
void idShow(const ideal id, const ring lmRing, const ring tailRing, const int debugPrint)
Definition: simpleideals.cc:60
poly res
Definition: myNF.cc:322
BOOLEAN count_Factors(ideal I, intvec *v, int j, poly &f, poly fac, const ring r)
Definition: clapsing.cc:696
CFFList factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
Definition: cf_factor.cc:390
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
poly p_One(const ring r)
Definition: p_polys.cc:1318
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:465
int j
Definition: myNF.cc:70
static BOOLEAN p_IsConstant(const poly p, const ring r)
Definition: p_polys.h:1784
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
T getFirst() const
Definition: ftmpl_list.cc:279
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:902
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
#define IDELEMS(i)
Definition: simpleideals.h:24
void idSkipZeroes(ideal ide)
gives an ideal/module the minimal possible size
#define p_Test(p, r)
Definition: p_polys.h:160
short errorreported
Definition: feFopen.cc:23
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
const Variable & v
< [in] a sqrfree bivariate poly
Definition: facBivar.h:37
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:615
T & getItem() const
Definition: ftmpl_list.cc:431
const CanonicalForm & w
Definition: facAbsFact.cc:55
static BOOLEAN p_IsConstantPoly(const poly p, const ring r)
Definition: p_polys.h:1798
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
int singclap_factorize_retry
Definition: clapsing.cc:782
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
ideal singclap_factorize(poly f, intvec **v, int with_exps, const ring r)
Definition: clapsing.cc:784
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition: cf_defs.h:30
static Poly * h
Definition: janet.cc:978
int BOOLEAN
Definition: auxiliary.h:131
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2682
static poly p_Mult_q(poly p, poly q, const ring r)
Definition: p_polys.h:1025
int l
Definition: cfEzgcd.cc:94
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
poly singclap_gcd ( poly  f,
poly  g,
const ring  r 
)

destroys f and g

Definition at line 287 of file clapsing.cc.

288 {
289  poly res=NULL;
290 
291  if (f!=NULL) p_Cleardenom(f, r);
292  if (g!=NULL) p_Cleardenom(g, r);
293  else return f; // g==0 => gcd=f (but do a p_Cleardenom)
294  if (f==NULL) return g; // f==0 => gcd=g (but do a p_Cleardenom)
295 
296  res=singclap_gcd_r(f,g,r);
297  p_Delete(&f, r);
298  p_Delete(&g, r);
299  return res;
300 }
poly singclap_gcd_r(poly f, poly g, const ring r)
Definition: clapsing.cc:52
f
Definition: cfModGcd.cc:4022
g
Definition: cfModGcd.cc:4031
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define NULL
Definition: omList.c:10
polyrec * poly
Definition: hilb.h:10
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2682
poly singclap_gcd_and_divide ( poly f,
poly g,
const ring  r 
)

clears denominators of f and g, divides by gcd(f,g)

Definition at line 150 of file clapsing.cc.

151 {
152  poly res=NULL;
153 
154  if (g == NULL)
155  {
156  res= f;
157  f=p_One (r);
158  return res;
159  }
160  if (f==NULL)
161  {
162  res= g;
163  g=p_One (r);
164  return res;
165  }
166 
167  Off(SW_RATIONAL);
168  CanonicalForm F,G,GCD;
169  if (rField_is_Q(r) || (rField_is_Zp(r)))
170  {
171  bool b1=isOn(SW_USE_EZGCD_P);
173  F=convSingPFactoryP( f,r );
174  G=convSingPFactoryP( g,r );
175  GCD=gcd(F,G);
176  if (!GCD.isOne())
177  {
178  p_Delete(&f,r);
179  p_Delete(&g,r);
180  if (getCharacteristic() == 0)
181  On (SW_RATIONAL);
182  F /= GCD;
183  G /= GCD;
184  if (getCharacteristic() == 0)
185  {
186  CanonicalForm denF= bCommonDen (F);
187  CanonicalForm denG= bCommonDen (G);
188  G *= denG;
189  F *= denF;
190  Off (SW_RATIONAL);
191  CanonicalForm gcddenFdenG= gcd (denG, denF);
192  denG /= gcddenFdenG;
193  denF /= gcddenFdenG;
194  On (SW_RATIONAL);
195  G *= denF;
196  F *= denG;
197  }
198  f=convFactoryPSingP( F, r);
199  g=convFactoryPSingP( G, r);
200  }
201  res=convFactoryPSingP( GCD , r);
202  if (!b1) Off (SW_USE_EZGCD_P);
203  }
204  // and over Q(a) / Fp(a)
205  else if ( r->cf->extRing )
206  {
207  if ( rField_is_Q_a(r)) setCharacteristic( 0 );
208  else setCharacteristic( rChar(r) );
209  if (r->cf->extRing->qideal!=NULL)
210  {
211  bool b1=isOn(SW_USE_QGCD);
212  if ( rField_is_Q_a(r) ) On(SW_USE_QGCD);
213  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
214  r->cf->extRing);
215  Variable a=rootOf(mipo);
216  F=( convSingAPFactoryAP( f,a,r ) );
217  G=( convSingAPFactoryAP( g,a,r ) );
218  GCD=gcd(F,G);
219  if (!GCD.isOne())
220  {
221  p_Delete(&f,r);
222  p_Delete(&g,r);
223  if (getCharacteristic() == 0)
224  On (SW_RATIONAL);
225  F /= GCD;
226  G /= GCD;
227  if (getCharacteristic() == 0)
228  {
229  CanonicalForm denF= bCommonDen (F);
230  CanonicalForm denG= bCommonDen (G);
231  G *= denG;
232  F *= denF;
233  Off (SW_RATIONAL);
234  CanonicalForm gcddenFdenG= gcd (denG, denF);
235  denG /= gcddenFdenG;
236  denF /= gcddenFdenG;
237  On (SW_RATIONAL);
238  G *= denF;
239  F *= denG;
240  }
241  f= convFactoryAPSingAP( F,r );
242  g= convFactoryAPSingAP( G,r );
243  }
244  res= convFactoryAPSingAP( GCD,r );
245  prune (a);
246  if (!b1) Off(SW_USE_QGCD);
247  }
248  else
249  {
250  F=( convSingTrPFactoryP( f,r ) );
251  G=( convSingTrPFactoryP( g,r ) );
252  GCD=gcd(F,G);
253  if (!GCD.isOne())
254  {
255  p_Delete(&f,r);
256  p_Delete(&g,r);
257  if (getCharacteristic() == 0)
258  On (SW_RATIONAL);
259  F /= GCD;
260  G /= GCD;
261  if (getCharacteristic() == 0)
262  {
263  CanonicalForm denF= bCommonDen (F);
264  CanonicalForm denG= bCommonDen (G);
265  G *= denG;
266  F *= denF;
267  Off (SW_RATIONAL);
268  CanonicalForm gcddenFdenG= gcd (denG, denF);
269  denG /= gcddenFdenG;
270  denF /= gcddenFdenG;
271  On (SW_RATIONAL);
272  G *= denF;
273  F *= denG;
274  }
275  f= convFactoryPSingTrP( F,r );
276  g= convFactoryPSingTrP( G,r );
277  }
278  res= convFactoryPSingTrP( GCD,r );
279  }
280  }
281  else
283  Off(SW_RATIONAL);
284  return res;
285 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: variable.h:32
static const int SW_USE_EZGCD_P
set to 1 to use EZGCD over F_q
Definition: cf_defs.h:34
int rChar(ring r)
Definition: ring.cc:684
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static TreeM * G
Definition: janet.cc:38
void setCharacteristic(int c)
Definition: cf_char.cc:23
int getCharacteristic()
Definition: cf_char.cc:51
CF_NO_INLINE bool isOne() const
CF_INLINE bool CanonicalForm::isOne, isZero () const.
Definition: cf_inline.cc:354
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1318
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
bool isOn(int sw)
switches
void On(int sw)
switches
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
CanonicalForm bCommonDen(const CanonicalForm &f)
CanonicalForm bCommonDen ( const CanonicalForm & f )
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
int gcd(int a, int b)
Definition: walkSupport.cc:839
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:40
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
poly singclap_gcd_r ( poly  f,
poly  g,
const ring  r 
)

Definition at line 52 of file clapsing.cc.

53 {
54  poly res=NULL;
55 
56  assume(f!=NULL);
57  assume(g!=NULL);
58 
59  if(pNext(f)==NULL && pNext(g)==NULL)
60  {
61  poly p=p_One(r);
62  for(int i=rVar(r);i>0;i--)
64  if (rField_is_Ring(r))
65  {
66  number c = p_GetCoeff(f,r);
67  number d = p_GetCoeff(g,r);
68  p_SetCoeff(p,n_Gcd(c,d,r->cf),r);
69  }
70  p_Setm(p,r);
71  return p;
72 #if 0
73  else
74  {
75  poly h=g;
76  for(int i=rVar(r);i>0;i--)
77  p_SetExp(p,i,p_GetExp(f,i,r),r);
78  while(h!=NULL)
79  {
80  for(int i=rVar(r);i>0;i--)
81  p_SetExp(p,i,si_min(p_GetExp(p,i,r),p_GetExp(h,i,r)),r);
82  pIter(h);
83  }
84  p_Setm(p,r);
85  return p;
86  }
87 #endif
88  }
89 #if 0
90  else if (pNext(g)==NULL)
91  {
92  poly p=p_One(r);
93  poly h=f;
94  for(int i=rVar(r);i>0;i--)
95  p_SetExp(p,i,p_GetExp(g,i,r),r);
96  if (rField_is_Ring(r))
97  {
98  number c = p_GetCoeff(f,r);
99  number d = p_GetCoeff(g,r);
100  p_SetCoeff(p,n_Gcd(c,d,r->cf),r);
101  }
102  while(h!=NULL)
103  {
104  for(int i=rVar(r);i>0;i--)
105  p_SetExp(p,i,si_min(p_GetExp(p,i,r),p_GetExp(h,i,r)),r);
106  pIter(h);
107  }
108  p_Setm(p,r);
109  return p;
110  }
111 #endif
112 
113  Off(SW_RATIONAL);
115  {
118  res=convFactoryPSingP( gcd( F, G ) , r);
119  }
120  // and over Q(a) / Fp(a)
121  else if ( r->cf->extRing!=NULL )
122  {
123  if ( rField_is_Q_a(r)) setCharacteristic( 0 );
124  else setCharacteristic( rChar(r) );
125  if (r->cf->extRing->qideal!=NULL)
126  {
127  bool b1=isOn(SW_USE_QGCD);
128  if ( rField_is_Q_a(r) ) On(SW_USE_QGCD);
129  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
130  r->cf->extRing);
131  Variable a=rootOf(mipo);
133  G( convSingAPFactoryAP( g,a,r ) );
134  res= convFactoryAPSingAP( gcd( F, G ),r );
135  prune (a);
136  if (!b1) Off(SW_USE_QGCD);
137  }
138  else
139  {
141  res= convFactoryPSingTrP( gcd( F, G ),r );
142  }
143  }
144  else
146  Off(SW_RATIONAL);
147  return res;
148 }
static FORCE_INLINE number n_Gcd(number a, number b, const coeffs r)
in Z: return the gcd of &#39;a&#39; and &#39;b&#39; in Z/nZ, Z/2^kZ: computed as in the case Z in Z/pZ...
Definition: coeffs.h:685
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
static int si_min(const int a, const int b)
Definition: auxiliary.h:167
return P p
Definition: myNF.cc:203
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: variable.h:32
int rChar(ring r)
Definition: ring.cc:684
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static TreeM * G
Definition: janet.cc:38
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
void setCharacteristic(int c)
Definition: cf_char.cc:23
#define pIter(p)
Definition: monomials.h:44
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
poly p_One(const ring r)
Definition: p_polys.cc:1318
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:465
#define assume(x)
Definition: mod2.h:405
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
bool isOn(int sw)
switches
void On(int sw)
switches
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
static BOOLEAN rField_is_Ring(const ring r)
Definition: ring.h:437
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
int gcd(int a, int b)
Definition: walkSupport.cc:839
static const int SW_USE_QGCD
set to 1 to use Encarnacion GCD over Q(a)
Definition: cf_defs.h:40
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:434
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
#define p_GetCoeff(p, r)
Definition: monomials.h:57
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
static Poly * h
Definition: janet.cc:978
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
matrix singclap_irrCharSeries ( ideal  I,
const ring  r 
)

Definition at line 1398 of file clapsing.cc.

1399 {
1400  if (idIs0(I)) return mpNew(1,1);
1401 
1402  // for now there is only the possibility to handle polynomials over
1403  // Q and Fp ...
1404  matrix res=NULL;
1405  int i;
1406  Off(SW_RATIONAL);
1408  CFList L;
1409  ListCFList LL;
1410  if (rField_is_Q(r) || rField_is_Zp(r))
1411  {
1413  for(i=0;i<IDELEMS(I);i++)
1414  {
1415  poly p=I->m[i];
1416  if (p!=NULL)
1417  {
1418  p=p_Copy(p,r);
1419  p_Cleardenom(p, r);
1420  L.append(convSingPFactoryP(p,r));
1421  }
1422  }
1423  }
1424  // and over Q(a) / Fp(a)
1425  else if (nCoeff_is_transExt (r->cf))
1426  {
1428  for(i=0;i<IDELEMS(I);i++)
1429  {
1430  poly p=I->m[i];
1431  if (p!=NULL)
1432  {
1433  p=p_Copy(p,r);
1434  p_Cleardenom(p, r);
1436  }
1437  }
1438  }
1439  else
1440  {
1442  return res;
1443  }
1444 
1445  // a very bad work-around --- FIX IT in libfac
1446  // should be fixed as of 2001/6/27
1447  int tries=0;
1448  int m,n;
1450  loop
1451  {
1452  LL=irrCharSeries(L);
1453  m= LL.length(); // Anzahl Zeilen
1454  n=0;
1455  for ( LLi = LL; LLi.hasItem(); LLi++ )
1456  {
1457  n = si_max(LLi.getItem().length(),n);
1458  }
1459  if ((m!=0) && (n!=0)) break;
1460  tries++;
1461  if (tries>=5) break;
1462  }
1463  if ((m==0) || (n==0))
1464  {
1465  Warn("char_series returns %d x %d matrix from %d input polys (%d)",
1466  m,n,IDELEMS(I)+1,LL.length());
1467  iiWriteMatrix((matrix)I,"I",2,r,0);
1468  m=si_max(m,1);
1469  n=si_max(n,1);
1470  }
1471  res=mpNew(m,n);
1472  CFListIterator Li;
1473  for ( m=1, LLi = LL; LLi.hasItem(); LLi++, m++ )
1474  {
1475  for (n=1, Li = LLi.getItem(); Li.hasItem(); Li++, n++)
1476  {
1477  if (rField_is_Q(r) || rField_is_Zp(r))
1478  MATELEM(res,m,n)=convFactoryPSingP(Li.getItem(),r);
1479  else
1480  MATELEM(res,m,n)=convFactoryPSingTrP(Li.getItem(),r);
1481  }
1482  }
1483  Off(SW_RATIONAL);
1484  return res;
1485 }
void Off(int sw)
switches
loop
Definition: myNF.cc:98
return P p
Definition: myNF.cc:203
int rChar(ring r)
Definition: ring.cc:684
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
ListCFList irrCharSeries(const CFList &PS)
irreducible characteristic series
Definition: cfCharSets.cc:568
void WerrorS(const char *s)
Definition: feFopen.cc:24
void setCharacteristic(int c)
Definition: cf_char.cc:23
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
void iiWriteMatrix(matrix im, const char *n, int dim, const ring r, int spaces)
set spaces to zero by default
Definition: matpol.cc:739
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
int m
Definition: cfEzgcd.cc:119
void On(int sw)
switches
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:919
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
#define IDELEMS(i)
Definition: simpleideals.h:24
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
matrix mpNew(int r, int c)
create a r x c zero-matrix
Definition: matpol.cc:48
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
T & getItem() const
Definition: ftmpl_list.cc:431
void append(const T &)
Definition: ftmpl_list.cc:256
polyrec * poly
Definition: hilb.h:10
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition: cf_defs.h:30
BOOLEAN idIs0(ideal h)
returns true if h is the zero ideal
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2682
#define MATELEM(mat, i, j)
Definition: matpol.h:29
#define Warn
Definition: emacs.cc:80
char* singclap_neworder ( ideal  I,
const ring  r 
)

Definition at line 1487 of file clapsing.cc.

1488 {
1489  int i;
1490  Off(SW_RATIONAL);
1492  CFList L;
1493  if (rField_is_Q(r) || rField_is_Zp(r))
1494  {
1496  for(i=0;i<IDELEMS(I);i++)
1497  {
1498  poly p=I->m[i];
1499  if (p!=NULL)
1500  {
1501  p=p_Copy(p,r);
1502  p_Cleardenom(p, r);
1503  L.append(convSingPFactoryP(p,r));
1504  }
1505  }
1506  }
1507  // and over Q(a) / Fp(a)
1508  else if (nCoeff_is_transExt (r->cf))
1509  {
1511  for(i=0;i<IDELEMS(I);i++)
1512  {
1513  poly p=I->m[i];
1514  if (p!=NULL)
1515  {
1516  p=p_Copy(p,r);
1517  p_Cleardenom(p, r);
1519  }
1520  }
1521  }
1522  else
1523  {
1525  return NULL;
1526  }
1527 
1528  List<int> IL=neworderint(L);
1529  ListIterator<int> Li;
1530  StringSetS("");
1531  Li = IL;
1532  int offs=rPar(r);
1533  int* mark=(int*)omAlloc0((rVar(r)+offs)*sizeof(int));
1534  int cnt=rVar(r)+offs;
1535  loop
1536  {
1537  if(! Li.hasItem()) break;
1538  BOOLEAN done=TRUE;
1539  i=Li.getItem()-1;
1540  mark[i]=1;
1541  if (i<offs)
1542  {
1543  done=FALSE;
1544  //StringAppendS(r->parameter[i]);
1545  }
1546  else
1547  {
1548  StringAppendS(r->names[i-offs]);
1549  }
1550  Li++;
1551  cnt--;
1552  if(cnt==0) break;
1553  if (done) StringAppendS(",");
1554  }
1555  for(i=0;i<rVar(r)+offs;i++)
1556  {
1557  BOOLEAN done=TRUE;
1558  if(mark[i]==0)
1559  {
1560  if (i<offs)
1561  {
1562  done=FALSE;
1563  //StringAppendS(r->parameter[i]);
1564  }
1565  else
1566  {
1567  StringAppendS(r->names[i-offs]);
1568  }
1569  cnt--;
1570  if(cnt==0) break;
1571  if (done) StringAppendS(",");
1572  }
1573  }
1574  char * s=StringEndS();
1575  if (s[strlen(s)-1]==',') s[strlen(s)-1]='\0';
1576  return s;
1577 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
std::pair< int, int > mark
void Off(int sw)
switches
loop
Definition: myNF.cc:98
#define FALSE
Definition: auxiliary.h:140
return P p
Definition: myNF.cc:203
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:547
int rChar(ring r)
Definition: ring.cc:684
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
#define TRUE
Definition: auxiliary.h:144
void WerrorS(const char *s)
Definition: feFopen.cc:24
char * StringEndS()
Definition: reporter.cc:151
void setCharacteristic(int c)
Definition: cf_char.cc:23
static poly p_Copy(poly p, const ring r)
returns a copy of p
Definition: p_polys.h:811
const ring r
Definition: syzextra.cc:208
IntList neworderint(const CFList &PolyList)
Definition: cfCharSets.cc:88
void StringSetS(const char *st)
Definition: reporter.cc:128
void StringAppendS(const char *st)
Definition: reporter.cc:107
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
static FORCE_INLINE BOOLEAN nCoeff_is_transExt(const coeffs r)
TRUE iff r represents a transcendental extension field.
Definition: coeffs.h:919
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
#define IDELEMS(i)
Definition: simpleideals.h:24
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
T & getItem() const
Definition: ftmpl_list.cc:431
void append(const T &)
Definition: ftmpl_list.cc:256
polyrec * poly
Definition: hilb.h:10
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition: cf_defs.h:30
int BOOLEAN
Definition: auxiliary.h:131
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2682
#define omAlloc0(size)
Definition: omAllocDecl.h:211
poly singclap_pdivide ( poly  f,
poly  g,
const ring  r 
)

Definition at line 547 of file clapsing.cc.

548 {
549  poly res=NULL;
550  On(SW_RATIONAL);
551  if (rField_is_Zp(r) || rField_is_Q(r))
552  {
555  res = convFactoryPSingP( F / G,r );
556  }
557  else if (rField_is_Ring_Z(r))
558  {
559  Off(SW_RATIONAL);
562  res = convFactoryPSingP( F / G,r );
563  }
564  else if (r->cf->extRing!=NULL)
565  {
566  if (rField_is_Q_a(r)) setCharacteristic( 0 );
567  else setCharacteristic( rChar(r) );
568  if (r->cf->extRing->qideal!=NULL)
569  {
570  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
571  r->cf->extRing);
572  Variable a=rootOf(mipo);
574  G( convSingAPFactoryAP( g,a,r ) );
575  res= convFactoryAPSingAP( F / G, r );
576  prune (a);
577  }
578  else
579  {
581  res= convFactoryPSingTrP( F / G,r );
582  }
583  }
584 #if 0 // not yet working
585  else if (rField_is_GF())
586  {
587  //Print("GF(%d^%d)\n",nfCharP,nfMinPoly[0]);
588  setCharacteristic( nfCharP,nfMinPoly[0], currRing->parameter[0][0] );
589  CanonicalForm F( convSingGFFactoryGF( f ) ), G( convSingGFFactoryGF( g ) );
590  res = convFactoryGFSingGF( F / G );
591  }
592 #endif
593  else
595  Off(SW_RATIONAL);
596  return res;
597 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: variable.h:32
int rChar(ring r)
Definition: ring.cc:684
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:470
static TreeM * G
Definition: janet.cc:38
void setCharacteristic(int c)
Definition: cf_char.cc:23
poly res
Definition: myNF.cc:322
ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
Definition: polys.cc:12
const ring r
Definition: syzextra.cc:208
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
static BOOLEAN rField_is_Ring_Z(const ring r)
Definition: ring.h:434
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
int nfMinPoly[16]
Definition: ffields.cc:580
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
poly singclap_resultant ( poly  f,
poly  g,
poly  x,
const ring  r 
)

Definition at line 317 of file clapsing.cc.

318 {
319  poly res=NULL;
320  int i=p_IsPurePower(x, r);
321  if (i==0)
322  {
323  WerrorS("3rd argument must be a ring variable");
324  goto resultant_returns_res;
325  }
326  if ((f==NULL) || (g==NULL))
327  goto resultant_returns_res;
328  // for now there is only the possibility to handle polynomials over
329  // Q and Fp ...
330  if (rField_is_Zp(r) || rField_is_Q(r))
331  {
332  Variable X(i);
335  res=convFactoryPSingP( resultant( F, G, X),r );
336  Off(SW_RATIONAL);
337  goto resultant_returns_res;
338  }
339  // and over Q(a) / Fp(a)
340  else if (r->cf->extRing!=NULL)
341  {
342  if (rField_is_Q_a(r)) setCharacteristic( 0 );
343  else setCharacteristic( rChar(r) );
344  Variable X(i+rPar(r));
345  if (r->cf->extRing->qideal!=NULL)
346  {
347  //Variable X(i);
348  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
349  r->cf->extRing);
350  Variable a=rootOf(mipo);
352  G( convSingAPFactoryAP( g,a,r ) );
353  res= convFactoryAPSingAP( resultant( F, G, X ),r );
354  prune (a);
355  }
356  else
357  {
358  //Variable X(i+rPar(currRing));
359  number nf,ng;
361  int ef,eg;
362  ef=pGetExp_Var(f,i,r);
363  eg=pGetExp_Var(g,i,r);
365  res= convFactoryPSingTrP( resultant( F, G, X ),r );
366  if ((nf!=NULL)&&(!n_IsOne(nf,r->cf)))
367  {
368  number n=n_Invers(nf,r->cf);
369  while(eg>0)
370  {
371  res=p_Mult_nn(res,n,r);
372  eg--;
373  }
374  n_Delete(&n,r->cf);
375  }
376  n_Delete(&nf,r->cf);
377  if ((ng!=NULL)&&(!n_IsOne(ng,r->cf)))
378  {
379  number n=n_Invers(ng,r->cf);
380  while(ef>0)
381  {
382  res=p_Mult_nn(res,n,r);
383  ef--;
384  }
385  n_Delete(&n,r->cf);
386  }
387  n_Delete(&ng,r->cf);
388  }
389  Off(SW_RATIONAL);
390  goto resultant_returns_res;
391  }
392  else
394 resultant_returns_res:
395  p_Delete(&f,r);
396  p_Delete(&g,r);
397  p_Delete(&x,r);
398  return res;
399 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
static FORCE_INLINE BOOLEAN n_IsOne(number n, const coeffs r)
TRUE iff &#39;n&#39; represents the one element.
Definition: coeffs.h:469
f
Definition: cfModGcd.cc:4022
static int rPar(const ring r)
(r->cf->P)
Definition: ring.h:547
factory&#39;s class for variables
Definition: variable.h:32
int rChar(ring r)
Definition: ring.cc:684
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
g
Definition: cfModGcd.cc:4031
void WerrorS(const char *s)
Definition: feFopen.cc:24
static TreeM * G
Definition: janet.cc:38
void setCharacteristic(int c)
Definition: cf_char.cc:23
void p_Cleardenom_n(poly ph, const ring r, number &c)
Definition: p_polys.cc:2826
Definition: gnumpfl.cc:60
poly res
Definition: myNF.cc:322
const ring r
Definition: syzextra.cc:208
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
static FORCE_INLINE number n_Invers(number a, const coeffs r)
return the multiplicative inverse of &#39;a&#39;; raise an error if &#39;a&#39; is not invertible ...
Definition: coeffs.h:565
int i
Definition: cfEzgcd.cc:123
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:902
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
int pGetExp_Var(poly p, int i, const ring r)
Definition: clapsing.cc:303
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
int p_IsPurePower(const poly p, const ring r)
return i, if head depends only on var(i)
Definition: p_polys.cc:1224
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
Variable x
Definition: cfModGcd.cc:4023
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
CanonicalForm resultant(const CanonicalForm &f, const CanonicalForm &g, const Variable &x)
CanonicalForm resultant ( const CanonicalForm & f, const CanonicalForm & g, const Variable & x ) ...
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
ideal singclap_sqrfree ( poly  f,
intvec **  v,
int  with_exps,
const ring  r 
)

Definition at line 1155 of file clapsing.cc.

1156 {
1157  p_Test(f,r);
1158 #ifdef FACTORIZE2_DEBUG
1159  printf("singclap_sqrfree, degree %d\n",pTotaldegree(f));
1160 #endif
1161  // with_exps: 3,1 return only true factors, no exponents
1162  // 2 return true factors and exponents
1163  // 0 return coeff, factors and exponents
1164  BOOLEAN save_errorreported=errorreported;
1165 
1166  ideal res=NULL;
1167 
1168  // handle factorize(0) =========================================
1169  if (f==NULL)
1170  {
1171  res=idInit(1,1);
1172  if (with_exps!=1 && with_exps!=3)
1173  {
1174  (*v)=new intvec(1);
1175  (**v)[0]=1;
1176  }
1177  return res;
1178  }
1179  // handle factorize(mon) =========================================
1180  if (pNext(f)==NULL)
1181  {
1182  int i=0;
1183  int n=0;
1184  int e;
1185  for(i=rVar(r);i>0;i--) if(p_GetExp(f,i,r)!=0) n++;
1186  if (with_exps==0 || with_exps==3) n++; // with coeff
1187  res=idInit(si_max(n,1),1);
1188  switch(with_exps)
1189  {
1190  case 0: // with coef & exp.
1191  res->m[0]=p_NSet(n_Copy(pGetCoeff(f),r->cf),r);
1192  // no break
1193  case 3: // with coef & exp.
1194  res->m[0]=p_NSet(n_Copy(pGetCoeff(f),r->cf),r);
1195  // no break
1196  case 2: // with exp.
1197  (*v)=new intvec(si_max(1,n));
1198  (**v)[0]=1;
1199  // no break
1200  case 1: ;
1201  #ifdef TEST
1202  default: ;
1203  #endif
1204  }
1205  res->m[0]=p_NSet(n_Copy(pGetCoeff(f),r->cf),r);
1206  if (n==0)
1207  {
1208  res->m[0]=p_One(r);
1209  // (**v)[0]=1; is already done
1210  }
1211  else
1212  {
1213  for(i=rVar(r);i>0;i--)
1214  {
1215  e=p_GetExp(f,i,r);
1216  if(e!=0)
1217  {
1218  n--;
1219  poly p=p_One(r);
1220  p_SetExp(p,i,1,r);
1221  p_Setm(p,r);
1222  res->m[n]=p;
1223  if (with_exps!=1) (**v)[n]=e;
1224  }
1225  }
1226  }
1227  p_Delete(&f,r);
1228  return res;
1229  }
1230  //PrintS("S:");pWrite(f);PrintLn();
1231  // use factory/libfac in general ==============================
1232  Off(SW_RATIONAL);
1234  CFFList L;
1235  number N=NULL;
1236  number NN=NULL;
1237  number old_lead_coeff=n_Copy(pGetCoeff(f), r->cf);
1238  Variable a;
1239 
1240  if (!rField_is_Zp(r) && !rField_is_Zp_a(r)) /* Q, Q(a) */
1241  {
1242  //if (f!=NULL) // already tested at start of routine
1243  number n0=n_Copy(pGetCoeff(f),r->cf);
1244  if (with_exps==0 || with_exps==3)
1245  N=n_Copy(n0,r->cf);
1246  p_Cleardenom(f, r);
1247  //after here f should not have a denominator!!
1248  //PrintS("S:");p_Write(f,r);PrintLn();
1249  NN=n_Div(n0,pGetCoeff(f),r->cf);
1250  n_Delete(&n0,r->cf);
1251  if (with_exps==0 || with_exps==3)
1252  {
1253  n_Delete(&N,r->cf);
1254  N=n_Copy(NN,r->cf);
1255  }
1256  }
1257  else if (rField_is_Zp_a(r))
1258  {
1259  //if (f!=NULL) // already tested at start of routine
1260  if (singclap_factorize_retry==0)
1261  {
1262  number n0=n_Copy(pGetCoeff(f),r->cf);
1263  if (with_exps==0 || with_exps==3)
1264  N=n_Copy(n0,r->cf);
1265  p_Norm(f,r);
1266  p_Cleardenom(f, r);
1267  NN=n_Div(n0,pGetCoeff(f),r->cf);
1268  n_Delete(&n0,r->cf);
1269  if (with_exps==0 || with_exps==3)
1270  {
1271  n_Delete(&N,r->cf);
1272  N=n_Copy(NN,r->cf);
1273  }
1274  }
1275  }
1276  if (rField_is_Q(r) || rField_is_Zp(r))
1277  {
1280  L = sqrFree( F );
1281  }
1282  else if (r->cf->extRing!=NULL)
1283  {
1284  if (rField_is_Q_a (r)) setCharacteristic (0);
1285  else setCharacteristic( rChar(r) );
1286  if (r->cf->extRing->qideal!=NULL)
1287  {
1288  CanonicalForm mipo=convSingPFactoryP(r->cf->extRing->qideal->m[0],
1289  r->cf->extRing);
1290  a=rootOf(mipo);
1291  CanonicalForm F( convSingAPFactoryAP( f, a, r ) );
1292  L= sqrFree (F);
1293  }
1294  else
1295  {
1297  L = sqrFree( F );
1298  }
1299  }
1300  #if 0
1301  else if (rField_is_GF())
1302  {
1303  int c=rChar(r);
1304  setCharacteristic( c, primepower(c) );
1305  CanonicalForm F( convSingGFFactoryGF( f ) );
1306  if (F.isUnivariate())
1307  {
1308  L = factorize( F );
1309  }
1310  else
1311  {
1312  goto notImpl;
1313  }
1314  }
1315  #endif
1316  else
1317  {
1318  goto notImpl;
1319  }
1320  {
1321  // convert into ideal
1322  int n = L.length();
1323  if (n==0) n=1;
1324  CFFListIterator J=L;
1325  int j=0;
1326  if (with_exps!=1)
1327  {
1328  if ((with_exps==2)&&(n>1))
1329  {
1330  n--;
1331  J++;
1332  }
1333  *v = new intvec( n );
1334  }
1335  else if (L.getFirst().factor().inCoeffDomain() && with_exps!=3)
1336  {
1337  n--;
1338  J++;
1339  }
1340  res = idInit( n ,1);
1341  for ( ; J.hasItem(); J++, j++ )
1342  {
1343  if (with_exps!=1 && with_exps!=3) (**v)[j] = J.getItem().exp();
1344  if (rField_is_Zp(r) || rField_is_Q(r))
1345  res->m[j] = convFactoryPSingP( J.getItem().factor(),r );
1346  else if (r->cf->extRing!=NULL) /* Q(a), Fp(a) */
1347  {
1348  if (r->cf->extRing->qideal==NULL)
1349  res->m[j]=convFactoryPSingTrP( J.getItem().factor(),r );
1350  else
1351  res->m[j]=convFactoryAPSingAP( J.getItem().factor(),r );
1352  }
1353  }
1354  if (res->m[0]==NULL)
1355  {
1356  res->m[0]=p_One(r);
1357  }
1358  if (N!=NULL)
1359  {
1360  p_Mult_nn(res->m[0],N,r);
1361  n_Delete(&N,r->cf);
1362  N=NULL;
1363  }
1364  }
1365  if (r->cf->extRing!=NULL)
1366  if (r->cf->extRing->qideal!=NULL)
1367  prune (a);
1368  if (rField_is_Q_a(r) && (r->cf->extRing->qideal!=NULL))
1369  {
1370  int i=IDELEMS(res)-1;
1371  int stop=1;
1372  if (with_exps!=0 || with_exps==3) stop=0;
1373  for(;i>=stop;i--)
1374  {
1375  p_Norm(res->m[i],r);
1376  }
1377  if (with_exps==0 || with_exps==3) p_SetCoeff(res->m[0],old_lead_coeff,r);
1378  else n_Delete(&old_lead_coeff,r->cf);
1379  }
1380  else
1381  n_Delete(&old_lead_coeff,r->cf);
1382  p_Delete(&f,r);
1383  errorreported=save_errorreported;
1384 notImpl:
1385  if (res==NULL)
1387  if (NN!=NULL)
1388  {
1389  n_Delete(&NN,r->cf);
1390  }
1391  if (N!=NULL)
1392  {
1393  n_Delete(&N,r->cf);
1394  }
1395  return res;
1396 }
const poly a
Definition: syzextra.cc:212
CanonicalForm convSingAPFactoryAP(poly p, const Variable &a, const ring r)
Definition: clapconv.cc:120
void Off(int sw)
switches
static BOOLEAN rField_is_Zp_a(const ring r)
Definition: ring.h:478
return P p
Definition: myNF.cc:203
f
Definition: cfModGcd.cc:4022
factory&#39;s class for variables
Definition: variable.h:32
poly p_NSet(number n, const ring r)
returns the poly representing the number n, destroys n
Definition: p_polys.cc:1448
int rChar(ring r)
Definition: ring.cc:684
static short rVar(const ring r)
#define rVar(r) (r->N)
Definition: ring.h:540
CanonicalForm convSingTrPFactoryP(poly p, const ring r)
Definition: clapconv.cc:288
poly convFactoryPSingTrP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:324
static BOOLEAN rField_is_Q_a(const ring r)
Definition: ring.h:488
factory&#39;s main class
Definition: canonicalform.h:75
void WerrorS(const char *s)
Definition: feFopen.cc:24
static BOOLEAN rField_is_GF(const ring r)
Definition: ring.h:470
void p_Norm(poly p1, const ring r)
Definition: p_polys.cc:3565
static number & pGetCoeff(poly p)
return an alias to the leading coefficient of p assumes that p != NULL NOTE: not copy ...
Definition: monomials.h:51
static number p_SetCoeff(poly p, number n, ring r)
Definition: p_polys.h:401
void setCharacteristic(int c)
Definition: cf_char.cc:23
poly res
Definition: myNF.cc:322
CFFList factorize(const CanonicalForm &f, bool issqrfree=false)
factorization over or
Definition: cf_factor.cc:390
const ring r
Definition: syzextra.cc:208
Definition: intvec.h:16
const CanonicalForm CFMap CFMap & N
Definition: cfEzgcd.cc:49
poly p_One(const ring r)
Definition: p_polys.cc:1318
static long p_GetExp(const poly p, const unsigned long iBitmask, const int VarOffset)
get a single variable exponent : the integer VarOffset encodes:
Definition: p_polys.h:465
int j
Definition: myNF.cc:70
static long pTotaldegree(poly p)
Definition: polys.h:253
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
const char feNotImplemented[]
Definition: reporter.cc:54
static const int SW_RATIONAL
set to 1 for computations over Q
Definition: cf_defs.h:28
void On(int sw)
switches
static int si_max(const int a, const int b)
Definition: auxiliary.h:166
T getFirst() const
Definition: ftmpl_list.cc:279
int length() const
Definition: ftmpl_list.cc:273
int i
Definition: cfEzgcd.cc:123
static poly p_Mult_nn(poly p, number n, const ring r)
Definition: p_polys.h:902
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
void prune(Variable &alpha)
Definition: variable.cc:261
#define IDELEMS(i)
Definition: simpleideals.h:24
#define p_Test(p, r)
Definition: p_polys.h:160
short errorreported
Definition: feFopen.cc:23
static BOOLEAN rField_is_Zp(const ring r)
Definition: ring.h:455
static void p_Delete(poly *p, const ring r)
Definition: p_polys.h:850
ideal idInit(int idsize, int rank)
initialise an ideal / module
Definition: simpleideals.cc:38
static unsigned long p_SetExp(poly p, const unsigned long e, const unsigned long iBitmask, const int VarOffset)
set a single variable exponent : VarOffset encodes the position in p->exp
Definition: p_polys.h:484
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
static FORCE_INLINE number n_Copy(number n, const coeffs r)
return a copy of &#39;n&#39;
Definition: coeffs.h:452
static FORCE_INLINE number n_Div(number a, number b, const coeffs r)
return the quotient of &#39;a&#39; and &#39;b&#39;, i.e., a/b; raises an error if &#39;b&#39; is not invertible in r exceptio...
Definition: coeffs.h:615
T & getItem() const
Definition: ftmpl_list.cc:431
#define pNext(p)
Definition: monomials.h:43
static void p_Setm(poly p, const ring r)
Definition: p_polys.h:436
int singclap_factorize_retry
Definition: clapsing.cc:782
static FORCE_INLINE void n_Delete(number *p, const coeffs r)
delete &#39;p&#39;
Definition: coeffs.h:456
poly convFactoryAPSingAP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:155
polyrec * poly
Definition: hilb.h:10
static const int SW_SYMMETRIC_FF
set to 1 for symmetric representation over F_q
Definition: cf_defs.h:30
int BOOLEAN
Definition: auxiliary.h:131
poly p_Cleardenom(poly p, const ring r)
Definition: p_polys.cc:2682
CFFList sqrFree(const CanonicalForm &f, bool sort=false)
squarefree factorization
Definition: cf_factor.cc:757
Variable rootOf(const CanonicalForm &mipo, char name)
returns a symbolic root of polynomial with name name Use it to define algebraic variables ...
Definition: variable.cc:162
matrix singntl_HNF ( matrix  A,
const ring  r 
)

Definition at line 1639 of file clapsing.cc.

1640 {
1641  int r=m->rows();
1642  if (r!=m->cols())
1643  {
1644  Werror("HNF of %d x %d matrix",r,m->cols());
1645  return NULL;
1646  }
1647 
1648  matrix res=mp_New(r,r);
1649 
1650  if (rField_is_Q(s))
1651  {
1652 
1653  CFMatrix M(r,r);
1654  int i,j;
1655  for(i=r;i>0;i--)
1656  {
1657  for(j=r;j>0;j--)
1658  {
1659  M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s );
1660  }
1661  }
1662  CFMatrix *MM=cf_HNF(M);
1663  for(i=r;i>0;i--)
1664  {
1665  for(j=r;j>0;j--)
1666  {
1667  MATELEM(res,i,j)=convFactoryPSingP((*MM)(i,j),s);
1668  }
1669  }
1670  delete MM;
1671  }
1672  return res;
1673 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
poly res
Definition: myNF.cc:322
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
static matrix mp_New(int r, int c)
Definition: matpol.h:35
CFMatrix * cf_HNF(CFMatrix &A)
The input matrix A is an n x m matrix of rank m (so n >= m), and D is a multiple of the determinant o...
Definition: cf_hnf.cc:38
#define NULL
Definition: omList.c:10
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
void Werror(const char *fmt,...)
Definition: reporter.cc:199
#define MATELEM(mat, i, j)
Definition: matpol.h:29
intvec* singntl_HNF ( intvec A)

Definition at line 1675 of file clapsing.cc.

1676 {
1677  int r=m->rows();
1678  if (r!=m->cols())
1679  {
1680  Werror("HNF of %d x %d matrix",r,m->cols());
1681  return NULL;
1682  }
1683  setCharacteristic( 0 );
1684  CFMatrix M(r,r);
1685  int i,j;
1686  for(i=r;i>0;i--)
1687  {
1688  for(j=r;j>0;j--)
1689  {
1690  M(i,j)=IMATELEM(*m,i,j);
1691  }
1692  }
1693  CFMatrix *MM=cf_HNF(M);
1694  intvec *mm=ivCopy(m);
1695  for(i=r;i>0;i--)
1696  {
1697  for(j=r;j>0;j--)
1698  {
1699  IMATELEM(*mm,i,j)=convFactoryISingI((*MM)(i,j));
1700  }
1701  }
1702  delete MM;
1703  return mm;
1704 }
intvec * ivCopy(const intvec *o)
Definition: intvec.h:141
void setCharacteristic(int c)
Definition: cf_char.cc:23
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int convFactoryISingI(const CanonicalForm &f)
Definition: clapconv.cc:114
Definition: intvec.h:16
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
CFMatrix * cf_HNF(CFMatrix &A)
The input matrix A is an n x m matrix of rank m (so n >= m), and D is a multiple of the determinant o...
Definition: cf_hnf.cc:38
#define NULL
Definition: omList.c:10
#define IMATELEM(M, I, J)
Definition: intvec.h:77
void Werror(const char *fmt,...)
Definition: reporter.cc:199
matrix singntl_LLL ( matrix  A,
const ring  r 
)

Definition at line 1706 of file clapsing.cc.

1707 {
1708  int r=m->rows();
1709  int c=m->cols();
1710  matrix res=mp_New(r,c);
1711  if (rField_is_Q(s))
1712  {
1713  CFMatrix M(r,c);
1714  int i,j;
1715  for(i=r;i>0;i--)
1716  {
1717  for(j=c;j>0;j--)
1718  {
1719  M(i,j)=convSingPFactoryP(MATELEM(m,i,j),s);
1720  }
1721  }
1722  CFMatrix *MM=cf_LLL(M);
1723  for(i=r;i>0;i--)
1724  {
1725  for(j=c;j>0;j--)
1726  {
1727  MATELEM(res,i,j)=convFactoryPSingP((*MM)(i,j),s);
1728  }
1729  }
1730  delete MM;
1731  }
1732  return res;
1733 }
const CanonicalForm int s
Definition: facAbsFact.cc:55
poly res
Definition: myNF.cc:322
CFMatrix * cf_LLL(CFMatrix &A)
performs LLL reduction.
Definition: cf_hnf.cc:48
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int j
Definition: myNF.cc:70
poly convFactoryPSingP(const CanonicalForm &f, const ring r)
Definition: clapconv.cc:41
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
static BOOLEAN rField_is_Q(const ring r)
Definition: ring.h:461
static matrix mp_New(int r, int c)
Definition: matpol.h:35
CanonicalForm convSingPFactoryP(poly p, const ring r)
Definition: clapconv.cc:88
#define MATELEM(mat, i, j)
Definition: matpol.h:29
intvec* singntl_LLL ( intvec A)

Definition at line 1735 of file clapsing.cc.

1736 {
1737  int r=m->rows();
1738  int c=m->cols();
1739  setCharacteristic( 0 );
1740  CFMatrix M(r,c);
1741  int i,j;
1742  for(i=r;i>0;i--)
1743  {
1744  for(j=c;j>0;j--)
1745  {
1746  M(i,j)=IMATELEM(*m,i,j);
1747  }
1748  }
1749  CFMatrix *MM=cf_LLL(M);
1750  intvec *mm=ivCopy(m);
1751  for(i=r;i>0;i--)
1752  {
1753  for(j=c;j>0;j--)
1754  {
1755  IMATELEM(*mm,i,j)=convFactoryISingI((*MM)(i,j));
1756  }
1757  }
1758  delete MM;
1759  return mm;
1760 }
intvec * ivCopy(const intvec *o)
Definition: intvec.h:141
void setCharacteristic(int c)
Definition: cf_char.cc:23
CFMatrix * cf_LLL(CFMatrix &A)
performs LLL reduction.
Definition: cf_hnf.cc:48
#define M
Definition: sirandom.c:24
const ring r
Definition: syzextra.cc:208
int convFactoryISingI(const CanonicalForm &f)
Definition: clapconv.cc:114
Definition: intvec.h:16
int j
Definition: myNF.cc:70
int m
Definition: cfEzgcd.cc:119
int i
Definition: cfEzgcd.cc:123
#define IMATELEM(M, I, J)
Definition: intvec.h:77