2929#endif
3030
3131#include "bits.h"
32+ #include "ntt.h"
3233#include "div.h"
3334#include "static_assert.h"
3435
3536#define BIGDECIMAL_VERSION "4.0.1"
3637
37- #if SIZEOF_DECDIG == 4
38- #define USE_NTT_MULTIPLICATION 1
39- #include "ntt.h"
4038#define NTT_MULTIPLICATION_THRESHOLD 100
4139#define NEWTON_RAPHSON_DIVISION_THRESHOLD 200
42- #endif
43-
4440#define SIGNED_VALUE_MAX INTPTR_MAX
4541#define SIGNED_VALUE_MIN INTPTR_MIN
4642#define MUL_OVERFLOW_SIGNED_VALUE_P (a , b ) MUL_OVERFLOW_SIGNED_INTEGER_P(a, b, SIGNED_VALUE_MIN, SIGNED_VALUE_MAX)
@@ -3279,7 +3275,6 @@ BigDecimal_vpmult(VALUE self, VALUE v) {
32793275 return c .bigdecimal ;
32803276}
32813277
3282- #if SIZEOF_DECDIG == 4
32833278VALUE
32843279BigDecimal_nttmult (VALUE self , VALUE v ) {
32853280 BDVALUE a ,b ,c ;
@@ -3295,7 +3290,6 @@ BigDecimal_nttmult(VALUE self, VALUE v) {
32953290 RB_GC_GUARD (b .bigdecimal );
32963291 return c .bigdecimal ;
32973292}
3298- #endif
32993293
33003294#endif /* BIGDECIMAL_USE_VP_TEST_METHODS */
33013295
@@ -3670,9 +3664,7 @@ Init_bigdecimal(void)
36703664 rb_define_method (rb_cBigDecimal , "vpdivd_newton" , BigDecimal_vpdivd_newton , 2 );
36713665 rb_define_method (rb_cBigDecimal , "newton_raphson_inverse" , BigDecimal_newton_raphson_inverse , 1 );
36723666 rb_define_method (rb_cBigDecimal , "vpmult" , BigDecimal_vpmult , 1 );
3673- #ifdef USE_NTT_MULTIPLICATION
36743667 rb_define_method (rb_cBigDecimal , "nttmult" , BigDecimal_nttmult , 1 );
3675- #endif
36763668#endif /* BIGDECIMAL_USE_VP_TEST_METHODS */
36773669
36783670#define ROUNDING_MODE (i , name , value ) \
@@ -4956,13 +4948,11 @@ VpMult(Real *c, Real *a, Real *b)
49564948 VpSetSign (c , VpGetSign (a ) * VpGetSign (b )); /* set sign */
49574949 if (!AddExponent (c , b -> exponent )) return 0 ;
49584950
4959- #ifdef USE_NTT_MULTIPLICATION
49604951 if (b -> Prec >= NTT_MULTIPLICATION_THRESHOLD ) {
49614952 ntt_multiply ((uint32_t )a -> Prec , (uint32_t )b -> Prec , a -> frac , b -> frac , c -> frac );
49624953 c -> Prec = a -> Prec + b -> Prec ;
49634954 goto Cleanup ;
49644955 }
4965- #endif
49664956
49674957 carry = 0 ;
49684958 nc = ind_c = MxIndAB ;
@@ -5059,13 +5049,11 @@ VpDivd(Real *c, Real *r, Real *a, Real *b)
50595049
50605050 if (word_a > word_r || word_b + word_c - 2 >= word_r ) goto space_error ;
50615051
5062- #ifdef USE_NTT_MULTIPLICATION
50635052 // Newton-Raphson division requires multiplication to be faster than O(n^2)
50645053 if (word_c >= NEWTON_RAPHSON_DIVISION_THRESHOLD && word_b >= NEWTON_RAPHSON_DIVISION_THRESHOLD ) {
50655054 VpDivdNewton (c , r , a , b );
50665055 goto Exit ;
50675056 }
5068- #endif
50695057
50705058 for (i = 0 ; i < word_a ; ++ i ) r -> frac [i ] = a -> frac [i ];
50715059 for (i = word_a ; i < word_r ; ++ i ) r -> frac [i ] = 0 ;
0 commit comments