Changeset 498648 in git for factory/cf_chinese.cc


Ignore:
Timestamp:
Jun 27, 2011, 4:20:53 PM (12 years ago)
Author:
Martin Lee <martinlee84@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', '00e2e9c41af3fde1273eb3633f4c0c7c3db2579d')
Children:
29179092d0c3ba3d252b203cd763be600dd7b096
Parents:
2ae57ff78cd82da1abf9ba52505c9ea78709e89c
Message:
rational reconstruction via NTL


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

Legend:

Unmodified
Added
Removed
  • factory/cf_chinese.cc

    r2ae57f r498648  
    2020#include "cf_iter.h"
    2121
     22#ifdef HAVE_NTL
     23#include "NTLconvert.h"
     24#endif
    2225
    2326//{{{ void chineseRemainder ( const CanonicalForm & x1, const CanonicalForm & q1, const CanonicalForm & x2, const CanonicalForm & q2, CanonicalForm & xnew, CanonicalForm & qnew )
     
    199202        if ( c.inCoeffDomain())
    200203        {
    201           result += power( x, i.exp() ) * Farey_n(c,q);
     204#ifdef HAVE_NTL
     205          if (c.inZ() && isOn (SW_USE_NTL))
     206          {
     207            ZZ NTLc= convertFacCF2NTLZZ (c);
     208            bool lessZero= (sign (NTLc) == -1);
     209            if (lessZero)
     210              negate (NTLc, NTLc);
     211            ZZ NTLq= convertFacCF2NTLZZ (q);
     212            ZZ bound;
     213            SqrRoot (bound, NTLq/2);
     214            ZZ NTLnum, NTLden;
     215            if (ReconstructRational (NTLnum, NTLden, NTLc, NTLq, bound, bound))
     216            {
     217              if (lessZero)
     218                negate (NTLnum, NTLnum);
     219              CanonicalForm num= convertNTLZZX2CF (to_ZZX (NTLnum), Variable (1));
     220              CanonicalForm den= convertNTLZZX2CF (to_ZZX (NTLden), Variable (1));
     221              On (SW_RATIONAL);
     222              result += power (x, i.exp())*(num/den);
     223              Off (SW_RATIONAL);
     224            }
     225          }
     226          else
     227#endif
     228            result += power( x, i.exp() ) * Farey_n(c,q);
    202229        }
    203230        else
Note: See TracChangeset for help on using the changeset viewer.