Changeset a5d9313 in git for kernel/clapsing.cc


Ignore:
Timestamp:
Apr 13, 2005, 6:38:10 PM (19 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b52e66d4fefb16e3d45544260d89f4f400225ff2
Parents:
c3aa450764b8bf858d17c6300167912f9a0ab03f
Message:
*hannes: bug 36


git-svn-id: file:///usr/local/Singular/svn/trunk@7816 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/clapsing.cc

    rc3aa45 ra5d9313  
    33*  Computer Algebra System SINGULAR     *
    44****************************************/
    5 // $Id: clapsing.cc,v 1.5 2005-03-30 13:17:08 Singular Exp $
     5// $Id: clapsing.cc,v 1.6 2005-04-13 16:38:10 Singular Exp $
    66/*
    77* ABSTRACT: interface between Singular and factory
     
    663663}
    664664
     665int singclap_factorize_retry;
     666extern int si_factor_reminder;
     667
    665668ideal singclap_factorize ( poly f, intvec ** v , int with_exps)
    666669{
     
    738741  CFFList L;
    739742  number N=NULL;
    740   number NN=NULL;
     743  CanonicalForm T_F(0);
    741744  number old_lead_coeff=nCopy(pGetCoeff(f));
    742745
     
    748751      //if (f!=NULL) // already tested at start of routine
    749752      {
    750         number n0=nCopy(pGetCoeff(f));
    751         if (with_exps==0)
    752           N=nCopy(n0);
    753         pCleardenom(f);
    754         NN=nDiv(n0,pGetCoeff(f));
    755         nDelete(&n0);
    756         if (with_exps==0)
    757         {
    758           nDelete(&N);
    759           N=nCopy(NN);
    760         }
     753        pCleardenom_n(f,N);
    761754      }
    762755    }
    763756    CanonicalForm F( convSingPClapP( f ) );
     757    T_F=F;
    764758    if (nGetChar()==0) /* Q */
    765759    {
     
    781775    setCharacteristic( c, primepower(c) );
    782776    CanonicalForm F( convSingGFClapGF( f ) );
     777    T_F=F;
    783778    if (F.isUnivariate())
    784779    {
     
    796791    if (rField_is_Q_a()) setCharacteristic( 0 );
    797792    else                 setCharacteristic( -nGetChar() );
     793    pCleardenom_n(f,N);
    798794    if (currRing->minpoly!=NULL)
    799795    {
     
    801797      Variable a=rootOf(mipo);
    802798      CanonicalForm F( convSingAPClapAP( f,a ) );
     799      T_F=F;
    803800      L.insert(F);
    804801      if (rField_is_Zp_a() && F.isUnivariate())
     
    809806      {
    810807        CanonicalForm G( convSingTrPClapP( f ) );
     808        T_F=G;
    811809#ifdef HAVE_LIBFAC_P
    812810        if (rField_is_Q_a())
     
    835833    {
    836834      CanonicalForm F( convSingTrPClapP( f ) );
     835      T_F=F;
    837836      if (rField_is_Q_a())
    838837      {
     
    861860    int n = L.length();
    862861    CFFListIterator J=L;
     862    CanonicalForm T=1;
     863    for ( ; J.hasItem(); J++ )
     864    {
     865      int T_e = J.getItem().exp();
     866      while(T_e>0)  { T *= J.getItem().factor(); T_e--; }
     867    }
     868    T_F-=T;
     869    if (!T_F.isZero())
     870    {
     871      poly T_F_conv=pOne();
     872      J=L;
     873      for ( ; J.hasItem(); J++ )
     874      {
     875        poly p;
     876        int T_e = J.getItem().exp();
     877        if (rField_is_Zp() || rField_is_Q())           /* Q, Fp */
     878          p=( convClapPSingP( J.getItem().factor() ));
     879        else if (rField_is_Extension())     /* Q(a), Fp(a) */
     880        {
     881          if (currRing->minpoly==NULL)
     882            p=( convClapPSingTrP( J.getItem().factor() ));
     883          else
     884            p=( convClapAPSingAP( J.getItem().factor() ));
     885        }
     886        while(T_e>0)  { T_F_conv=pMult(T_F_conv,pCopy(p)); T_e--; }
     887        pDelete(&p);
     888      }
     889      number n_T=pGetCoeff(T_F_conv);
     890      number n_f=pGetCoeff(f);
     891      poly n_f_m=pMult_nn(pCopy(f),n_T);
     892      T_F_conv=pMult_nn(T_F_conv,n_f);
     893      T_F_conv=pSub(T_F_conv,n_f_m);
     894      if ((T_F_conv!=NULL) && (singclap_factorize_retry<1))
     895      {
     896        singclap_factorize_retry++;
     897        if( si_factor_reminder) Print("problem with factorize, retrying\n");
     898      #ifdef FEHLER_FACTORIZE
     899        Print("Problem....:");pWrite(f);
     900        J=L;
     901        for ( ; J.hasItem(); J++ )
     902        {
     903          if (rField_is_Zp() || rField_is_Q())           /* Q, Fp */
     904            pWrite0( convClapPSingP( J.getItem().factor() ));
     905          else if (rField_is_Extension())     /* Q(a), Fp(a) */
     906          {
     907            if (currRing->minpoly==NULL)
     908              pWrite0( convClapPSingTrP( J.getItem().factor() ));
     909            else
     910              pWrite0( convClapAPSingAP( J.getItem().factor() ));
     911          }
     912          Print(" exp: %d\n", J.getItem().exp());
     913        }
     914        Print("mult:");
     915        if (rField_is_Zp() || rField_is_Q())           /* Q, Fp */
     916          pWrite( convClapPSingP( T ));
     917        else if (rField_is_Extension())     /* Q(a), Fp(a) */
     918        {
     919          if (currRing->minpoly==NULL)
     920            pWrite( convClapPSingTrP( T ));
     921          else
     922            pWrite( convClapAPSingAP( T ));
     923        }
     924        Print("diff: sing:"); pWrite(T_F_conv);
     925        Print("diff: factory:");
     926        if (rField_is_Zp() || rField_is_Q())           /* Q, Fp */
     927          pWrite( convClapPSingP( T_F ));
     928        else if (rField_is_Extension())     /* Q(a), Fp(a) */
     929        {
     930          if (currRing->minpoly==NULL)
     931            pWrite( convClapPSingTrP( T_F ));
     932          else
     933            pWrite( convClapAPSingAP( T_F ));
     934        }
     935      #endif
     936        ideal T_i=singclap_factorize ( f, v , with_exps);
     937        if (N!=NULL) nDelete(&N);
     938        pDelete(&T_F_conv);
     939        return T_i;
     940      }
     941    }
     942    J=L;
    863943    int j=0;
    864944    if (with_exps!=1)
     
    892972    {
    893973      pMult_nn(res->m[0],N);
    894       nDelete(&N);
    895       N=NULL;
    896974    }
    897975    // delete constants
     
    9681046  if (res==NULL)
    9691047    WerrorS( feNotImplemented );
    970   if (NN!=NULL)
    971   {
     1048  if (N!=NULL)
     1049  {
     1050    number NN=nInvers(N);
    9721051    pMult_nn(f,NN);
    9731052    nDelete(&NN);
    974   }
    975   if (N!=NULL)
    976   {
    9771053    nDelete(&N);
    9781054  }
Note: See TracChangeset for help on using the changeset viewer.