Changeset a8d220b in git for factory/cf_chinese.cc


Ignore:
Timestamp:
Jul 3, 2020, 9:46:31 AM (4 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
b287470827373f8b355e6acb8f830baa5b3e88d1
Parents:
3801735313555d3e7900ceb38636374dc2183a76
Message:
factory: Farey via FLINT
File:
1 edited

Legend:

Unmodified
Added
Removed
  • factory/cf_chinese.cc

    r380173 ra8d220b  
    1818#ifdef HAVE_NTL
    1919#include "NTLconvert.h"
     20#endif
     21
     22#ifdef HAVE_FLINT
     23#include "FLINTconvert.h"
    2024#endif
    2125
     
    159163}
    160164
    161 #ifndef HAVE_NTL
     165#if 0
    162166CanonicalForm Farey_n (CanonicalForm N, const CanonicalForm P)
    163167//"USAGE:  Farey_n (N,P); P, N number;
     
    203207    CanonicalForm c;
    204208    CFIterator i;
    205 #ifdef HAVE_NTL
     209#ifdef HAVE_FLINT
     210   fmpz_t FLINTq;
     211   fmpz_init(FLINTq);
     212   convertCF2Fmpz(FLINTq,q);
     213   fmpz_t FLINTc;
     214   fmpz_init(FLINTc);
     215   fmpq_t FLINTres;
     216   fmpq_init(FLINTres);
     217#elif defined(HAVE_NTL)
    206218    ZZ NTLq= convertFacCF2NTLZZ (q);
    207219    ZZ bound;
     
    213225        if ( c.inCoeffDomain())
    214226        {
    215 #ifdef HAVE_NTL
     227#ifdef HAVE_FLINT
     228          if (c.inZ())
     229          {
     230             convertCF2Fmpz(FLINTc,c);
     231             fmpq_reconstruct_fmpz(FLINTres,FLINTc,FLINTq);
     232             result += power (x, i.exp())*(convertFmpq2CF(FLINTres));
     233          }
     234#elif defined(HAVE_NTL)
    216235          if (c.inZ())
    217236          {
     
    232251            }
    233252          }
     253#endif
    234254          else
    235255            result += power( x, i.exp() ) * Farey(c,q);
    236 #else
    237           if (c.inZ())
    238             result += power( x, i.exp() ) * Farey_n(c,q);
    239           else
    240             result += power( x, i.exp() ) * Farey(c,q);
    241 #endif
    242256        }
    243257        else
     
    245259    }
    246260    if (is_rat) On(SW_RATIONAL);
     261#ifdef HAVE_FLINT
     262    fmpq_clear(FLINTres);
     263    fmpz_clear(FLINTc);
     264    fmpz_clear(FLINTq);
     265#endif
    247266    return result;
    248267}
Note: See TracChangeset for help on using the changeset viewer.