Changeset f613e44 in git


Ignore:
Timestamp:
Feb 25, 2009, 5:37:34 PM (15 years ago)
Author:
Viktor Levandovskyy <levandov@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', '4188d308699580d975efd0f6cca8dcb41c396f70')
Children:
14db39c727ddf950b7c8c1919e53b77d77771923
Parents:
d5f35098e5ff96b29b884a0163b8da1d417b7de6
Message:
*levandov: the beginning of pContentRat


git-svn-id: file:///usr/local/Singular/svn/trunk@11467 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
kernel
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • kernel/ratgring.cc

    rd5f3509 rf613e44  
    77 *  Author:  levandov (Viktor Levandovsky)
    88 *  Created: 8/00 - 11/00
    9  *  Version: $Id: ratgring.cc,v 1.15 2009-02-23 19:22:27 levandov Exp $
     9 *  Version: $Id: ratgring.cc,v 1.16 2009-02-25 16:37:34 levandov Exp $
    1010 *******************************************************************/
    1111#include "mod2.h"
     
    686686  }
    687687}
    688 #endif
     688
     689poly pInitContentRat_a(poly ph)
     690// for rat coefficients in K(x1,..xN)
     691{
     692
     693  // init array of RatLeadCoeffs
     694  //  poly p_GetCoeffRat(poly p, int ishift, ring r);
     695
     696  poly *C = (poly *)omAlloc0((pLength(ph)+1)*sizeof(poly));  //rat coeffs
     697  poly *LM = (poly *)omAlloc0((pLength(ph)+1)*sizeof(poly));  // rat lead terms
     698  int *D = (int *)omAlloc0((pLength(ph)+1)*sizeof(int));  //degrees of coeffs
     699  int *L = (int *)omAlloc0((pLength(ph)+1)*sizeof(int));  //lengths of coeffs
     700  int k = 0;
     701  poly p = ph;
     702  int HasConstantCoef = 0;
     703  int mintdeg = pTotaldegree(p);
     704  int minlen = pLength(p);
     705  while (p!=NULL)
     706  {
     707    LM[k] = p_HeadRat(p, currRing->real_var_start, currRing);
     708    C[k] = p_GetCoeffRat(p, currRing->real_var_start, currRing);
     709    D[k] =  pTotaldegree(C[k]);
     710    mintdeg = si_min(mintdeg,D[k]);
     711    L[k] = pLength(C[k]);
     712    minlen = si_min(minlen,L[k]);
     713    if (pIsConstant(C[k]))
     714    {
     715      // C[k] = const, so the content will be numerical
     716      HasConstantCoef = 1;
     717      // smth like goto cleanup and return(pContent(p));
     718    }
     719    p_LmDeleteAndNextRat(&p, currRing->real_var_start, currRing);
     720    k++;
     721  }
     722
     723  // look for 1 element of minimal degree and of minimal length
     724  int *DD = (int *)omAlloc0((k+1)*sizeof(int));  //minimal degrees
     725  k--;
     726  int dd = 0; int i;
     727  int mindeglen = pLength(p); // expensive?
     728  int pmindeglen;
     729  for(i=0; i<=k; i++)
     730  {
     731    if (D[i] == mintdeg)
     732    {
     733      //      DD[dd] = i;
     734      //      dd++;
     735      mindeglen = si_min(mindeglen,L[i]);
     736      if (L[i] == mindeglen)
     737      {
     738        pmindeglen = i;
     739      }
     740    }
     741  }
     742  poly d = C[pmindeglen];
     743  // there are dd>=1 mindeg elements
     744  // and pmideglen is the coordinate of one of the smallest among them
     745
     746  //  poly g = singclap_gcd(p_Copy(p,r),p_Copy(q,r));
     747  //  return naGcd(d,d2,currRing);
     748
     749  // adjoin pContentRat here?
     750
     751}
     752
     753// void pContentRat(poly ph)
     754// {
     755// #ifdef HAVE_RINGS
     756//   if (rField_is_Ring(currRing))
     757//   {
     758//     if ((ph!=NULL) && rField_has_Units(currRing))
     759//     {
     760//       number k = nGetUnit(pGetCoeff(ph));
     761//       if (!nIsOne(k))
     762//       {
     763//         number tmpGMP = k;
     764//         k = nInvers(k);
     765//         nDelete(&tmpGMP);
     766//         poly h = pNext(ph);
     767//         pSetCoeff(ph, nMult(pGetCoeff(ph), k));
     768//         while (h != NULL)
     769//         {
     770//           pSetCoeff(h, nMult(pGetCoeff(h), k));
     771//           pIter(h);
     772//         }
     773//       }
     774//       nDelete(&k);
     775//     }
     776//     return;
     777//   }
     778// #endif
     779//   number h,d;
     780//   poly p;
     781
     782//   if(TEST_OPT_CONTENTSB) return;
     783//   if(pNext(ph)==NULL)
     784//   {
     785//     pSetCoeff(ph,nInit(1));
     786//   }
     787//   else
     788//   {
     789//     nNormalize(pGetCoeff(ph));
     790//     if(!nGreaterZero(pGetCoeff(ph))) ph = pNeg(ph);
     791//     if (rField_is_Q())
     792//     {
     793//       h=pInitContent(ph);
     794//       p=ph;
     795//     }
     796//     else if ((rField_is_Extension())
     797//     && ((rPar(currRing)>1)||(currRing->minpoly==NULL)))
     798//     {
     799//       h=pInitContent_a(ph);
     800//       p=ph;
     801//     }
     802//     else
     803//     {
     804//       h=nCopy(pGetCoeff(ph));
     805//       p = pNext(ph);
     806//     }
     807//     while (p!=NULL)
     808//     {
     809//       nNormalize(pGetCoeff(p));
     810//       d=nGcd(h,pGetCoeff(p),currRing);
     811//       nDelete(&h);
     812//       h = d;
     813//       if(nIsOne(h))
     814//       {
     815//         break;
     816//       }
     817//       pIter(p);
     818//     }
     819//     p = ph;
     820//     //number tmp;
     821//     if(!nIsOne(h))
     822//     {
     823//       while (p!=NULL)
     824//       {
     825//         //d = nDiv(pGetCoeff(p),h);
     826//         //tmp = nIntDiv(pGetCoeff(p),h);
     827//         //if (!nEqual(d,tmp))
     828//         //{
     829//         //  StringSetS("** div0:");nWrite(pGetCoeff(p));StringAppendS("/");
     830//         //  nWrite(h);StringAppendS("=");nWrite(d);StringAppendS(" int:");
     831//         //  nWrite(tmp);Print(StringAppendS("\n"));
     832//         //}
     833//         //nDelete(&tmp);
     834//         d = nIntDiv(pGetCoeff(p),h);
     835//         pSetCoeff(p,d);
     836//         pIter(p);
     837//       }
     838//     }
     839//     nDelete(&h);
     840// #ifdef HAVE_FACTORY
     841//     if ( (nGetChar() == 1) || (nGetChar() < 0) ) /* Q[a],Q(a),Zp[a],Z/p(a) */
     842//     {
     843//       singclap_divide_content(ph);
     844//       if(!nGreaterZero(pGetCoeff(ph))) ph = pNeg(ph);
     845//     }
     846// #endif
     847//     if (rField_is_Q_a())
     848//     {
     849//       number hzz = nlInit(1);
     850//       h = nlInit(1);
     851//       p=ph;
     852//       while (p!=NULL)
     853//       { // each monom: coeff in Q_a
     854//         lnumber c_n_n=(lnumber)pGetCoeff(p);
     855//         napoly c_n=c_n_n->z;
     856//         while (c_n!=NULL)
     857//         { // each monom: coeff in Q
     858//           d=nlLcm(hzz,pGetCoeff(c_n),currRing->algring);
     859//           n_Delete(&hzz,currRing->algring);
     860//           hzz=d;
     861//           pIter(c_n);
     862//         }
     863//         c_n=c_n_n->n;
     864//         while (c_n!=NULL)
     865//         { // each monom: coeff in Q
     866//           d=nlLcm(h,pGetCoeff(c_n),currRing->algring);
     867//           n_Delete(&h,currRing->algring);
     868//           h=d;
     869//           pIter(c_n);
     870//         }
     871//         pIter(p);
     872//       }
     873//       /* hzz contains the 1/lcm of all denominators in c_n_n->z*/
     874//       /* h contains the 1/lcm of all denominators in c_n_n->n*/
     875//       number htmp=nlInvers(h);
     876//       number hzztmp=nlInvers(hzz);
     877//       number hh=nlMult(hzz,h);
     878//       nlDelete(&hzz,currRing->algring);
     879//       nlDelete(&h,currRing->algring);
     880//       number hg=nlGcd(hzztmp,htmp,currRing->algring);
     881//       nlDelete(&hzztmp,currRing->algring);
     882//       nlDelete(&htmp,currRing->algring);
     883//       h=nlMult(hh,hg);
     884//       nlDelete(&hg,currRing->algring);
     885//       nlDelete(&hh,currRing->algring);
     886//       nlNormalize(h);
     887//       if(!nlIsOne(h))
     888//       {
     889//         p=ph;
     890//         while (p!=NULL)
     891//         { // each monom: coeff in Q_a
     892//           lnumber c_n_n=(lnumber)pGetCoeff(p);
     893//           napoly c_n=c_n_n->z;
     894//           while (c_n!=NULL)
     895//           { // each monom: coeff in Q
     896//             d=nlMult(h,pGetCoeff(c_n));
     897//             nlNormalize(d);
     898//             nlDelete(&pGetCoeff(c_n),currRing->algring);
     899//             pGetCoeff(c_n)=d;
     900//             pIter(c_n);
     901//           }
     902//        c_n=c_n_n->n;
     903//           while (c_n!=NULL)
     904//           { // each monom: coeff in Q
     905//             d=nlMult(h,pGetCoeff(c_n));
     906//             nlNormalize(d);
     907//             nlDelete(&pGetCoeff(c_n),currRing->algring);
     908//             pGetCoeff(c_n)=d;
     909//             pIter(c_n);
     910//           }
     911//           pIter(p);
     912//         }
     913//       }
     914//       nlDelete(&h,currRing->algring);
     915//     }
     916//   }
     917// }
     918
     919#endif
  • kernel/ratgring.h

    rd5f3509 rf613e44  
    44*  Computer Algebra System SINGULAR     *
    55****************************************/
    6 /* $Id: ratgring.h,v 1.8 2009-02-23 19:22:27 levandov Exp $ */
     6/* $Id: ratgring.h,v 1.9 2009-02-25 16:37:34 levandov Exp $ */
    77/*
    88* ABSTRACT additional defines etc for --with-plural
     
    111111*/
    112112int redRat (poly* h,poly *reducer, int *red_length,int rl, int ishift, ring r);
     113
     114// Content stuff
     115
     116poly pInitContentRat_a(poly ph);
     117void pContentRat(poly ph);
     118
    113119#endif /* HAVE_PLURAL */
    114120#endif
Note: See TracChangeset for help on using the changeset viewer.