Changeset 529fa4 in git


Ignore:
Timestamp:
May 11, 2011, 7:18:28 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd25190065115c859833252500a64cfb7b11e3a50')
Children:
6137945778b99e12da0ed42de11464a71e637602
Parents:
686f468cd2868ccd3c847dc0cd0b1417fc7fb0e1
git-author:
Hans Schoenemann <hannes@mathematik.uni-kl.de>2011-05-11 19:18:28+02:00
git-committer:
Mohamed Barakat <mohamed.barakat@rwth-aachen.de>2011-11-09 12:36:06+01:00
Message:
add: nChineseRemainder/idChineseRemainder
Location:
libpolys
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • libpolys/coeffs/coeffs.h

    r686f46 r529fa4  
    281281static inline BOOLEAN n_GreaterZero(number n, const coeffs r)
    282282{ assume(r != NULL); assume(r->cfGreaterZero!=NULL); return r->cfGreaterZero(n,r); }
    283 // cfGreater?
     283static inline BOOLEAN n_Greater(number a, number b, const coeffs r)
     284{ assume(r != NULL); assume(r->cfGreater!=NULL); return r->cfGreater(a,b,r); }
    284285
    285286#ifdef HAVE_RINGS
  • libpolys/polys/clapsing.cc

    r686f46 r529fa4  
    13561356#endif
    13571357#endif
     1358
     1359number   nChineseRemainder(number *x, number *q,int rl, const coeffs r)
     1360// elemenst in the array are x[0..(rl-1)], q[0..(rl-1)]
     1361{
     1362#ifdef HAVE_FACTORY
     1363  if (r->type!=n_Q)
     1364  { Werror("nChineseRemainder only for integers"); return NULL; }
     1365  setCharacteristic( 0 ); // only in char 0
     1366  CFArray X(rl), Q(rl);
     1367  int i;
     1368  for(i=rl-1;i>=0;i--)
     1369  {
     1370    X[i]=r->convSingNFactoryN(x[i],FALSE,r); // may be larger MAX_INT
     1371    Q[i]=r->convSingNFactoryN(q[i],FALSE,r); // may be larger MAX_INT
     1372  }
     1373  CanonicalForm xnew,qnew;
     1374  chineseRemainder(X,Q,xnew,qnew);
     1375  number n=r->convFactoryNSingN(xnew,r);
     1376  number p=r->convFactoryNSingN(qnew,r);
     1377  number p2=n_IntDiv(p,n_Init(2, r),r);
     1378  if (n_Greater(n,p2,r))
     1379  {
     1380     number n2=n_Sub(n,p,r);
     1381     n_Delete(&n,r);
     1382     n=n2;
     1383  }
     1384  n_Delete(&p,r);
     1385  n_Delete(&p2,r);
     1386  return n;
     1387#else
     1388  WerrorS("not implemented");
     1389  return n_Init(0,r);
     1390#endif
     1391}
  • libpolys/polys/clapsing.h

    r686f46 r529fa4  
    6262*/
    6363
    64 number   nlChineseRemainder(number *x, number *q,int rl);
     64number   nChineseRemainder(number *x, number *q,int rl, const coeffs r);
    6565
    6666#endif /* INCL_FACTORYSING_H */
  • libpolys/polys/simpleideals.cc

    r686f46 r529fa4  
    2424#include "simpleideals.h"
    2525#include "sbuckets.h"
     26#include "clapsing.h"
    2627
    2728omBin sip_sideal_bin = omGetSpecBin(sizeof(sip_sideal));
     
    16981699*/
    16991700#ifdef HAVE_FACTORY
    1700 #if 0
    17011701ideal id_ChineseRemainder(ideal *xx, number *q, int rl, const ring R)
    17021702{
     
    17361736      }
    17371737       
    1738       number n=nlChineseRemainder(x,q,rl); // kernel/clapconv.cc
     1738      number n=nChineseRemainder(x,q,rl, R->cf);
    17391739
    17401740      for(j=rl-1;j>=0;j--)
     
    17421742        x[j]=NULL; // nlInit(0...) takes no memory
    17431743      }
    1744       if (nlIsZero(n, R->cf)) p_Delete(&h, R);
     1744      if (n_IsZero(n, R->cf)) p_Delete(&h, R);
    17451745      else
    17461746      {
     
    17571757  return result;
    17581758}
    1759 #endif
    17601759#endif
    17611760
Note: See TracChangeset for help on using the changeset viewer.