gmp 0.5.23-x86-mingw32 → 0.5.41-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +13 -0
 - data/FEATURES.html +145 -2
 - data/README.rdoc +70 -68
 - data/benchmark/multiply.fnl +47 -0
 - data/ext/extconf.rb +4 -0
 - data/ext/gmp.so +0 -0
 - data/ext/gmpf.c +1 -0
 - data/ext/gmpz.c +302 -4
 - data/ext/ruby_gmp.h +10 -4
 - data/manual.pdf +0 -0
 - data/manual.tex +84 -61
 - data/test/tc_f_precision.rb +1 -1
 - data/test/tc_hashes.rb +2 -0
 - data/test/tc_logical_roots.rb +2 -0
 - data/test/tc_mpfr_constants.rb +2 -0
 - data/test/tc_mpfr_functions.rb +2 -0
 - data/test/tc_mpfr_random.rb +2 -0
 - data/test/tc_mpfr_rounding.rb +2 -0
 - data/test/tc_q.rb +2 -0
 - data/test/tc_q_basic.rb +2 -0
 - data/test/tc_random.rb +2 -0
 - data/test/tc_sgn_neg_abs.rb +2 -0
 - data/test/tc_swap.rb +2 -0
 - data/test/tc_z.rb +2 -2
 - data/test/tc_z_addmul.rb +2 -0
 - data/test/tc_z_basic.rb +2 -0
 - data/test/tc_z_exponentiation.rb +3 -1
 - data/test/tc_z_functional_mappings.rb +100 -0
 - data/test/tc_z_gcd_lcm_invert.rb +2 -0
 - data/test/tc_z_jac_leg_rem.rb +2 -0
 - data/test/tc_zerodivisionexceptions.rb +3 -1
 - data/test/unit_tests.rb +5 -4
 - metadata +6 -4
 
    
        data/CHANGELOG
    CHANGED
    
    | 
         @@ -1,3 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            0.5.41:
         
     | 
| 
      
 2 
     | 
    
         
            +
              * Added first five sets of Functional Mappings. These will be the primary new features
         
     | 
| 
      
 3 
     | 
    
         
            +
                of 0.6.
         
     | 
| 
      
 4 
     | 
    
         
            +
              * First Functional Mappings: GMP::Z.add, .addmul, .submul, .divexact, .lcm, .sub, .mul,
         
     | 
| 
      
 5 
     | 
    
         
            +
                .mul_2exp, .cdiv_q_2exp, .cdiv_r_2exp, .fdiv_q_2exp, .fdiv_r_2exp, .tdiv_q_2exp,
         
     | 
| 
      
 6 
     | 
    
         
            +
                .tdiv_r_2exp, .neg, .abs, .sqrt, .nextprime, .com
         
     | 
| 
      
 7 
     | 
    
         
            +
              * Added hopeful support for the Rubinius Ruby interpreter and VM! All tests pass in
         
     | 
| 
      
 8 
     | 
    
         
            +
                Rubinius 1.1.0, but full support won't be added until the release and inspection of
         
     | 
| 
      
 9 
     | 
    
         
            +
                Rubinius 1.1.1. Tested on 64-bit OS X 10.6 and 64-bit Linux 2.6.35.
         
     | 
| 
      
 10 
     | 
    
         
            +
              * Unit test results: 114 tests, 16203 assertions, 0 failures, 0 errors
         
     | 
| 
      
 11 
     | 
    
         
            +
              * Unit test results: 114 tests, 16190 assertions, 0 failures, 0 errors (MPFR 2.4.2)
         
     | 
| 
      
 12 
     | 
    
         
            +
              * Unit test results:  95 tests,  4925 assertions, 0 failures, 0 errors (w/o MPFR)
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
       1 
14 
     | 
    
         
             
            0.5.23:
         
     | 
| 
       2 
15 
     | 
    
         
             
              * Added MPFR method GMP::F.can_round? (mpfr_can_round), not tested.
         
     | 
| 
       3 
16 
     | 
    
         
             
              * MPFR const_ functions now accept an optional rounding mode and precision.
         
     | 
    
        data/FEATURES.html
    CHANGED
    
    | 
         @@ -18,6 +18,10 @@ body { 
     | 
|
| 
       18 
18 
     | 
    
         
             
              margin-bottom: 32px;
         
     | 
| 
       19 
19 
     | 
    
         
             
            }
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
            #mpzfm-grid {
         
     | 
| 
      
 22 
     | 
    
         
            +
              margin-bottom: 32px;
         
     | 
| 
      
 23 
     | 
    
         
            +
            }
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
       21 
25 
     | 
    
         
             
            #mpq-grid {
         
     | 
| 
       22 
26 
     | 
    
         
             
              margin-bottom: 32px;
         
     | 
| 
       23 
27 
     | 
    
         
             
            }
         
     | 
| 
         @@ -138,6 +142,101 @@ Ext.onReady(function(){ 
     | 
|
| 
       138 
142 
     | 
    
         
             
                    ['GMP::Z#size',                     "mpz_size",                                "yes","yes",   "", "no"]
         
     | 
| 
       139 
143 
     | 
    
         
             
                ];
         
     | 
| 
       140 
144 
     | 
    
         | 
| 
      
 145 
     | 
    
         
            +
                var mpzFmData = [
         
     | 
| 
      
 146 
     | 
    
         
            +
                    /* method,                          function,                                manual, yard, testB, testO */
         
     | 
| 
      
 147 
     | 
    
         
            +
                    //['GMP::Z#swap',                     "mpz_swap",                                   "","yes","yes", "no"],
         
     | 
| 
      
 148 
     | 
    
         
            +
                    //['GMP::Z#to_i',                     "mpz_get_si",                              "yes","yes","yes", "no"],
         
     | 
| 
      
 149 
     | 
    
         
            +
                    //['GMP::Z#to_d',                     "mpz_get_d",                               "yes","yes","yes", "no"],
         
     | 
| 
      
 150 
     | 
    
         
            +
                    //['',                                "mpz_get_d_2exp",                           "no", "no", "no", "no"],
         
     | 
| 
      
 151 
     | 
    
         
            +
                    //['GMP::Z#to_s',                     "mpz_get_str",                             "yes","yes","yes", "no"],
         
     | 
| 
      
 152 
     | 
    
         
            +
                    ['GMP::Z.add',                      "mpz_add<br />mpz_add_ui",                  "no", "no", "no", "no"],
         
     | 
| 
      
 153 
     | 
    
         
            +
                    ['GMP::Z.sub',                      "mpz_sub<br />mpz_sub_ui<br />mpz_ui_sub",  "no", "no", "no", "no"],
         
     | 
| 
      
 154 
     | 
    
         
            +
                    ['GMP::Z.mul',                      "mpz_mul<br />mpz_mul_si<br />mpz_mul_ui",  "no", "no", "no", "no"],
         
     | 
| 
      
 155 
     | 
    
         
            +
                    ['GMP::Z.addmul',                   "mpz_addmul<br />mpz_addmul_ui",            "no", "no", "no", "no"],
         
     | 
| 
      
 156 
     | 
    
         
            +
                    ['GMP::Z.submul',                   "mpz_submul<br />mpz_submul_ui",            "no", "no", "no", "no"],
         
     | 
| 
      
 157 
     | 
    
         
            +
                    ['',                                "mpz_mul_2exp",                             "no", "no", "no", "no"],
         
     | 
| 
      
 158 
     | 
    
         
            +
                    ['',                                "mpz_neg",                                  "no", "no", "no", "no"],
         
     | 
| 
      
 159 
     | 
    
         
            +
                    ['',                                "mpz_abs",                                  "no", "no", "no", "no"],
         
     | 
| 
      
 160 
     | 
    
         
            +
                    ['GMP::Z.divexact',                 "mpz_divexact<br />mpz_divexact_ui",        "no", "no", "no", "no"],
         
     | 
| 
      
 161 
     | 
    
         
            +
                    ['',                                "mpz_tdiv_q",                               "no", "no", "no", "no"],
         
     | 
| 
      
 162 
     | 
    
         
            +
                    ['',                                "mpz_tdiv_r",                               "no", "no", "no", "no"],
         
     | 
| 
      
 163 
     | 
    
         
            +
                    ['',                                "mpz_tdiv_qr",                              "no", "no", "no", "no"],
         
     | 
| 
      
 164 
     | 
    
         
            +
                    /*['GMP::Z#tshr',                     "mpz_tdiv_q_2exp",                            "","yes", "no", "no"],
         
     | 
| 
      
 165 
     | 
    
         
            +
                    ['GMP::Z#tshrm',                    "mpz_tdiv_r_2exp",                            "", "no", "no", "no"],
         
     | 
| 
      
 166 
     | 
    
         
            +
                    ['GMP::Z#fdiv',                     "mpz_fdiv_q",                              "yes","yes","yes", "no"],
         
     | 
| 
      
 167 
     | 
    
         
            +
                    ['GMP::Z#fmod',                     "mpz_fdiv_r",                              "yes","yes","yes", "no"],
         
     | 
| 
      
 168 
     | 
    
         
            +
                    ['GMP::Z#fdivmod',                  "mpz_fdiv_rq",                              "no", "no", "no", "no"],
         
     | 
| 
      
 169 
     | 
    
         
            +
                    ['GMP::Z#fshr',                     "mpz_fdiv_q_2exp",                            "", "no", "no", "no"],
         
     | 
| 
      
 170 
     | 
    
         
            +
                    ['GMP::Z#fshrm',                    "mpz_fdiv_r_2exp",                            "", "no", "no", "no"],
         
     | 
| 
      
 171 
     | 
    
         
            +
                    ['GMP::Z#cdiv',                     "mpz_cdiv_q",                              "yes","yes","yes", "no"],
         
     | 
| 
      
 172 
     | 
    
         
            +
                    ['GMP::Z#cmod',                     "mpz_cdiv_r",                              "yes","yes","yes", "no"],
         
     | 
| 
      
 173 
     | 
    
         
            +
                    ['GMP::Z#cdivmod',                  "mpz_cdiv_qr",                              "no", "no", "no", "no"],
         
     | 
| 
      
 174 
     | 
    
         
            +
                    ['',                                "mpz_cdiv_q_2exp",                          "no", "no", "no", "no"],
         
     | 
| 
      
 175 
     | 
    
         
            +
                    ['',                                "mpz_cdiv_r_2exp",                          "no", "no", "no", "no"],
         
     | 
| 
      
 176 
     | 
    
         
            +
                    ['GMP::Z#%',                        "mpz_mod<br />mpz_mod_ui",                 "yes","yes",   "", "no"],
         
     | 
| 
      
 177 
     | 
    
         
            +
                    ['GMP::Z#divisible?',               "mpz_divisible_p<br />mpz_divisible_ui_p",  "no","yes","yes", "no"],
         
     | 
| 
      
 178 
     | 
    
         
            +
                    ['',                                "mpz_divisible_2exp_p",                     "no", "no", "no", "no"],
         
     | 
| 
      
 179 
     | 
    
         
            +
                    ['',                                "mpz_congruent_p<br />mpz_congruent_ui_p",  "no", "no", "no", "no"],
         
     | 
| 
      
 180 
     | 
    
         
            +
                    ['',                                "mpz_congruent_2exp_p",                     "no", "no", "no", "no"],
         
     | 
| 
      
 181 
     | 
    
         
            +
                    ['GMP::Z#**<br />GMP::Z.pow',       "mpz_pow_ui",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 182 
     | 
    
         
            +
                    ['GMP::Z#powmod',                   "mpz_powm<br />mpz_powm_ui",               "yes","yes",   "", "no"],
         
     | 
| 
      
 183 
     | 
    
         
            +
                    ['GMP::Z#root',                     "mpz_root",                                "yes","yes",   "", "no"],
         
     | 
| 
      
 184 
     | 
    
         
            +
                    ['',                                "mpz_rootrem",                              "no", "no", "no", "no"],
         
     | 
| 
      
 185 
     | 
    
         
            +
                    ['GMP::Z#sqrt<br />GMP::Z#sqrt!',   "mpz_sqrt",                                "yes","yes",   "", "no"],
         
     | 
| 
      
 186 
     | 
    
         
            +
                    ['GMP::Z#sqrtrem',                  "mpz_sqrtrem",                             "yes","yes",   "", "no"],
         
     | 
| 
      
 187 
     | 
    
         
            +
                    ['GMP::Z#power?',                   "mpz_perfect_power_p",                     "yes","yes",   "", "no"],
         
     | 
| 
      
 188 
     | 
    
         
            +
                    ['GMP::Z#square?',                  "mpz_perfect_square_p",                    "yes","yes",   "", "no"],
         
     | 
| 
      
 189 
     | 
    
         
            +
                    ['GMP::Z#probab_prime?',            "mpz_probab_prime_p",                      "yes","yes",   "", "no"],
         
     | 
| 
      
 190 
     | 
    
         
            +
                    ['GMP::Z#next_prime<br />' +
         
     | 
| 
      
 191 
     | 
    
         
            +
                     'GMP::Z#next_prime!',              "mpz_nextprime",                           "yes","yes",   "", "no"],*/
         
     | 
| 
      
 192 
     | 
    
         
            +
                    ['',                                "mpz_gcd<br />mpz_gcd_ui",                  "no", "no", "no", "no"],
         
     | 
| 
      
 193 
     | 
    
         
            +
                    ['',                                "mpz_gcdext",                               "no", "no", "no", "no"],
         
     | 
| 
      
 194 
     | 
    
         
            +
                    ['GMP::Z.lcm',                      "mpz_lcm<br />mpz_lcm_ui",                  "no", "no", "no", "no"],
         
     | 
| 
      
 195 
     | 
    
         
            +
                    ['',                                "mpz_invert",                               "no", "no", "no", "no"],
         
     | 
| 
      
 196 
     | 
    
         
            +
                    ['',                                "mpz_jacobi",                               "no", "no", "no", "no"],
         
     | 
| 
      
 197 
     | 
    
         
            +
                    ['',                                "mpz_legendre",                             "no", "no", "no", "no"],
         
     | 
| 
      
 198 
     | 
    
         
            +
                    /*['',                                "mpz_kronecker<br />mpz_kronecker_si<br />" +
         
     | 
| 
      
 199 
     | 
    
         
            +
                                                        "mpz_kronecker_ui<br />mpz_si_kronecker" +
         
     | 
| 
      
 200 
     | 
    
         
            +
                                                        "<br />mpz_ui_kronecker",                  "yes","yes",   "", "no"],
         
     | 
| 
      
 201 
     | 
    
         
            +
                    ['GMP::Z#remove',                   "mpz_remove",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 202 
     | 
    
         
            +
                    ['GMP::Z.fac',                      "mpz_fac_ui",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 203 
     | 
    
         
            +
                    ['',                                "mpz_bin_ui<br />mpz_bin_uiui",             "no", "no", "no", "no"],
         
     | 
| 
      
 204 
     | 
    
         
            +
                    ['GMP::Z.fib',                      "mpz_fib_ui",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 205 
     | 
    
         
            +
                    ['',                                "mpz_fib2_ui",                              "no", "no", "no", "no"],
         
     | 
| 
      
 206 
     | 
    
         
            +
                    ['',                                "mpz_lucnum_ui",                            "no", "no", "no", "no"],
         
     | 
| 
      
 207 
     | 
    
         
            +
                    ['',                                "mpz_lucnum2_ui",                           "no", "no", "no", "no"],
         
     | 
| 
      
 208 
     | 
    
         
            +
                    ['GMP::Z#==<br />GMP::Z#<=><br />' +
         
     | 
| 
      
 209 
     | 
    
         
            +
                     'GMP::Z#<<br />GMP::Z#<=<br />' +
         
     | 
| 
      
 210 
     | 
    
         
            +
                     'GMP::Z#><br />GMP::Z#>=',   "mpz_cmp<br />mpz_cmp_si<br />mpz_cmp_ui", "yes","yes",   "", "no"],
         
     | 
| 
      
 211 
     | 
    
         
            +
                    ['GMP::Z#cmpabs',                   "mpz_cmpabs",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 212 
     | 
    
         
            +
                    ['GMP::Z#sgn',                      "mpz_sgn",                                 "yes","yes",   "", "no"],
         
     | 
| 
      
 213 
     | 
    
         
            +
                    ['GMP::Z#eql?',                     "mpz_get_str",                              "no","yes",   "","n/a"],
         
     | 
| 
      
 214 
     | 
    
         
            +
                    ['GMP::Z#hash',                     "mpz_get_str",                              "no","yes",   "","n/a"],
         
     | 
| 
      
 215 
     | 
    
         
            +
                    ['GMP::Z#&',                        "mpz_and",                                 "yes","yes",   "", "no"],
         
     | 
| 
      
 216 
     | 
    
         
            +
                    ['GMP::Z#|',                        "mpz_ior",                                 "yes","yes",   "", "no"],
         
     | 
| 
      
 217 
     | 
    
         
            +
                    ['GMP::Z#^',                        "mpz_xor",                                 "yes","yes",   "", "no"],
         
     | 
| 
      
 218 
     | 
    
         
            +
                    ['GMP::Z#com<br />GMP::Z#com!',     "mpz_com",                                 "yes","yes",   "", "no"],
         
     | 
| 
      
 219 
     | 
    
         
            +
                    ['GMP::Z#popcount',                 "mpz_popcount",                            "yes","yes",   "", "no"],
         
     | 
| 
      
 220 
     | 
    
         
            +
                    ['',                                "mpz_hamdist",                              "no", "no", "no", "no"],
         
     | 
| 
      
 221 
     | 
    
         
            +
                    ['GMP::Z#scan0',                    "mpz_scan0",                               "yes","yes",   "", "no"],
         
     | 
| 
      
 222 
     | 
    
         
            +
                    ['GMP::Z#scan1',                    "mpz_scan1",                               "yes","yes",   "", "no"],
         
     | 
| 
      
 223 
     | 
    
         
            +
                    ['GMP::Z#[]=',                      "mpz_setbit<br />mpz_clrbit",              "yes","yes",   "", "no"],
         
     | 
| 
      
 224 
     | 
    
         
            +
                    ['',                                "mpz_combit",                               "no", "no", "no", "no"],
         
     | 
| 
      
 225 
     | 
    
         
            +
                    ['GMP::Z#[]',                       "mpz_tstbit",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 226 
     | 
    
         
            +
                    ['',                                "mpz_fits_ulong_p",                         "no", "no", "no", "no"],
         
     | 
| 
      
 227 
     | 
    
         
            +
                    ['',                                "mpz_fits_slong_p",                         "no", "no", "no", "no"],
         
     | 
| 
      
 228 
     | 
    
         
            +
                    ['',                                "mpz_fits_uint_p",                          "no", "no", "no", "no"],
         
     | 
| 
      
 229 
     | 
    
         
            +
                    ['',                                "mpz_fits_sint_p",                          "no", "no", "no", "no"],
         
     | 
| 
      
 230 
     | 
    
         
            +
                    ['',                                "mpz_fits_ushort_p",                        "no", "no", "no", "no"],
         
     | 
| 
      
 231 
     | 
    
         
            +
                    ['',                                "mpz_fits_sshort_p",                        "no", "no", "no", "no"],
         
     | 
| 
      
 232 
     | 
    
         
            +
                    ['GMP::Z#even?',                    "mpz_even_p",                              "yes","yes",   "", "no"],
         
     | 
| 
      
 233 
     | 
    
         
            +
                    ['GMP::Z#odd?',                     "mpz_odd_p",                               "yes","yes",   "", "no"],
         
     | 
| 
      
 234 
     | 
    
         
            +
                    ['GMP::Z#sizeinbase<br />' +
         
     | 
| 
      
 235 
     | 
    
         
            +
                     'GMP::Z#size_in_base',             "mpz_sizeinbase",                          "yes","yes",   "", "no"],
         
     | 
| 
      
 236 
     | 
    
         
            +
                    ['GMP::Z#size_in_bin',              "mpz_sizeinbase",                          "yes","yes",   "", "no"],
         
     | 
| 
      
 237 
     | 
    
         
            +
                    ['GMP::Z#size',                     "mpz_size",                                "yes","yes",   "", "no"]*/
         
     | 
| 
      
 238 
     | 
    
         
            +
                ];
         
     | 
| 
      
 239 
     | 
    
         
            +
                
         
     | 
| 
       141 
240 
     | 
    
         
             
                var mpqData = [
         
     | 
| 
       142 
241 
     | 
    
         
             
                    /* method,                          function,                                manual, yard, testB, testO */
         
     | 
| 
       143 
242 
     | 
    
         
             
                    ['GMP::Q.new',                      "mpq_init",                                   "","yes","yes", "no"],
         
     | 
| 
         @@ -262,6 +361,18 @@ Ext.onReady(function(){ 
     | 
|
| 
       262 
361 
     | 
    
         
             
                    ]
         
     | 
| 
       263 
362 
     | 
    
         
             
                });
         
     | 
| 
       264 
363 
     | 
    
         | 
| 
      
 364 
     | 
    
         
            +
                // create the MPZ Functional Mappings data store
         
     | 
| 
      
 365 
     | 
    
         
            +
                var mpzfmStore = new Ext.data.ArrayStore({
         
     | 
| 
      
 366 
     | 
    
         
            +
                    fields: [
         
     | 
| 
      
 367 
     | 
    
         
            +
                       {name: 'method'},
         
     | 
| 
      
 368 
     | 
    
         
            +
                       {name: 'function'},
         
     | 
| 
      
 369 
     | 
    
         
            +
                       {name: 'manual'},
         
     | 
| 
      
 370 
     | 
    
         
            +
                       {name: 'yard'},
         
     | 
| 
      
 371 
     | 
    
         
            +
                       {name: 'testBasic'},
         
     | 
| 
      
 372 
     | 
    
         
            +
                       {name: 'testOriginal'}
         
     | 
| 
      
 373 
     | 
    
         
            +
                    ]
         
     | 
| 
      
 374 
     | 
    
         
            +
                });
         
     | 
| 
      
 375 
     | 
    
         
            +
                
         
     | 
| 
       265 
376 
     | 
    
         
             
                // create the MPQ data store
         
     | 
| 
       266 
377 
     | 
    
         
             
                var mpqStore = new Ext.data.ArrayStore({
         
     | 
| 
       267 
378 
     | 
    
         
             
                    fields: [
         
     | 
| 
         @@ -288,6 +399,7 @@ Ext.onReady(function(){ 
     | 
|
| 
       288 
399 
     | 
    
         | 
| 
       289 
400 
     | 
    
         
             
                // manually load local data
         
     | 
| 
       290 
401 
     | 
    
         
             
                mpzStore.loadData(mpzData);
         
     | 
| 
      
 402 
     | 
    
         
            +
                mpzfmStore.loadData(mpzFmData);
         
     | 
| 
       291 
403 
     | 
    
         
             
                mpqStore.loadData(mpqData);
         
     | 
| 
       292 
404 
     | 
    
         
             
                mpfStore.loadData(mpfData);
         
     | 
| 
       293 
405 
     | 
    
         | 
| 
         @@ -320,7 +432,36 @@ Ext.onReady(function(){ 
     | 
|
| 
       320 
432 
     | 
    
         
             
                    }
         
     | 
| 
       321 
433 
     | 
    
         
             
                });
         
     | 
| 
       322 
434 
     | 
    
         | 
| 
       323 
     | 
    
         
            -
                // create the MPZ Grid
         
     | 
| 
      
 435 
     | 
    
         
            +
                // create the MPZ Functional Mappings Grid
         
     | 
| 
      
 436 
     | 
    
         
            +
                var mpzfmGrid = new Ext.grid.GridPanel({
         
     | 
| 
      
 437 
     | 
    
         
            +
                    store: mpzfmStore,
         
     | 
| 
      
 438 
     | 
    
         
            +
                    columns: [
         
     | 
| 
      
 439 
     | 
    
         
            +
                        {id:'method',header: 'Ruby method', width: 140, sortable: true, dataIndex: 'method'},
         
     | 
| 
      
 440 
     | 
    
         
            +
                        {header: 'C function',            width: 130, sortable: true, renderer: shouldExist, dataIndex: 'function'},
         
     | 
| 
      
 441 
     | 
    
         
            +
                        {header: "Doc'd in manual.pdf?",  width: 140, sortable: true, renderer: shouldYes, dataIndex: 'manual'},
         
     | 
| 
      
 442 
     | 
    
         
            +
                        {header: "Doc'd in YARD?",        width: 100, sortable: true, renderer: shouldYes, dataIndex: 'yard'},
         
     | 
| 
      
 443 
     | 
    
         
            +
                        {header: 'Basic Tests?',          width: 100, sortable: true, renderer: shouldYes, dataIndex: 'testBasic'},
         
     | 
| 
      
 444 
     | 
    
         
            +
                        {header: 'Original Tests?',       width: 100, sortable: true, renderer: shouldYes, dataIndex: 'testOriginal'}
         
     | 
| 
      
 445 
     | 
    
         
            +
                    ],
         
     | 
| 
      
 446 
     | 
    
         
            +
                    stripeRows: true,
         
     | 
| 
      
 447 
     | 
    
         
            +
                    autoExpandColumn: 'method',
         
     | 
| 
      
 448 
     | 
    
         
            +
                    height: 260,
         
     | 
| 
      
 449 
     | 
    
         
            +
                    width: 820,
         
     | 
| 
      
 450 
     | 
    
         
            +
                    title: 'GMP::Z Functional Mappings',
         
     | 
| 
      
 451 
     | 
    
         
            +
                    // config options for stateful behavior
         
     | 
| 
      
 452 
     | 
    
         
            +
                    stateful: true,
         
     | 
| 
      
 453 
     | 
    
         
            +
                    stateId: 'grid',
         
     | 
| 
      
 454 
     | 
    
         
            +
                    viewConfig: {
         
     | 
| 
      
 455 
     | 
    
         
            +
                      getRowClass: function(record, rowIndex, rp, ds){
         
     | 
| 
      
 456 
     | 
    
         
            +
                        if(record.data.method == ""){
         
     | 
| 
      
 457 
     | 
    
         
            +
                          return 'x-grid3-row-unimplemented';
         
     | 
| 
      
 458 
     | 
    
         
            +
                        }
         
     | 
| 
      
 459 
     | 
    
         
            +
                        return 'x-grid3-row';
         
     | 
| 
      
 460 
     | 
    
         
            +
                      }
         
     | 
| 
      
 461 
     | 
    
         
            +
                    }
         
     | 
| 
      
 462 
     | 
    
         
            +
                });
         
     | 
| 
      
 463 
     | 
    
         
            +
                
         
     | 
| 
      
 464 
     | 
    
         
            +
                // create the MPQ Grid
         
     | 
| 
       324 
465 
     | 
    
         
             
                var mpqGrid = new Ext.grid.GridPanel({
         
     | 
| 
       325 
466 
     | 
    
         
             
                    store: mpqStore,
         
     | 
| 
       326 
467 
     | 
    
         
             
                    columns: [
         
     | 
| 
         @@ -349,7 +490,7 @@ Ext.onReady(function(){ 
     | 
|
| 
       349 
490 
     | 
    
         
             
                    }
         
     | 
| 
       350 
491 
     | 
    
         
             
                });
         
     | 
| 
       351 
492 
     | 
    
         | 
| 
       352 
     | 
    
         
            -
                // create the  
     | 
| 
      
 493 
     | 
    
         
            +
                // create the MPF Grid
         
     | 
| 
       353 
494 
     | 
    
         
             
                var mpfGrid = new Ext.grid.GridPanel({
         
     | 
| 
       354 
495 
     | 
    
         
             
                    store: mpfStore,
         
     | 
| 
       355 
496 
     | 
    
         
             
                    columns: [
         
     | 
| 
         @@ -380,6 +521,7 @@ Ext.onReady(function(){ 
     | 
|
| 
       380 
521 
     | 
    
         | 
| 
       381 
522 
     | 
    
         
             
                // render the grid to the specified div in the page
         
     | 
| 
       382 
523 
     | 
    
         
             
                mpzGrid.render('mpz-grid');
         
     | 
| 
      
 524 
     | 
    
         
            +
                mpzfmGrid.render('mpzfm-grid');
         
     | 
| 
       383 
525 
     | 
    
         
             
                mpqGrid.render('mpq-grid');
         
     | 
| 
       384 
526 
     | 
    
         
             
                mpfGrid.render('mpf-grid');
         
     | 
| 
       385 
527 
     | 
    
         
             
            });
         
     | 
| 
         @@ -387,6 +529,7 @@ Ext.onReady(function(){ 
     | 
|
| 
       387 
529 
     | 
    
         
             
              </head>
         
     | 
| 
       388 
530 
     | 
    
         
             
              <body>
         
     | 
| 
       389 
531 
     | 
    
         
             
                <div id="mpz-grid"></div>
         
     | 
| 
      
 532 
     | 
    
         
            +
                <div id="mpzfm-grid"></div>
         
     | 
| 
       390 
533 
     | 
    
         
             
                <div id='mpq-grid'></div>
         
     | 
| 
       391 
534 
     | 
    
         
             
                <div id='mpf-grid'></div>
         
     | 
| 
       392 
535 
     | 
    
         
             
              </body>
         
     | 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -47,44 +47,48 @@ paragraph at http://gmplib.org/#WHAT : 
     | 
|
| 
       47 
47 
     | 
    
         
             
              contributors to sign paperwork where they allow us to distribute their work."
         
     | 
| 
       48 
48 
     | 
    
         | 
| 
       49 
49 
     | 
    
         
             
            Only GMP 4 or newer is supported. The following environments have been tested
         
     | 
| 
       50 
     | 
    
         
            -
            by me: gmp gem 0.5. 
     | 
| 
       51 
     | 
    
         
            -
               
     | 
| 
       52 
     | 
    
         
            -
              |    Platform                             | 
     | 
| 
       53 
     | 
    
         
            -
               
     | 
| 
       54 
     | 
    
         
            -
              | Linux (Ubuntu NR 10.04) on x86 (32-bit) | (MRI) Ruby 1.8.7 
     | 
| 
       55 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.8.7 
     | 
| 
       56 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.8.7 
     | 
| 
       57 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.1 
     | 
| 
       58 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.1 
     | 
| 
       59 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.1 
     | 
| 
       60 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.2 
     | 
| 
       61 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1. 
     | 
| 
       62 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1. 
     | 
| 
       63 
     | 
    
         
            -
               
     | 
| 
       64 
     | 
    
         
            -
              | Linux (Ubuntu 10.04) on x86_64 (64-bit) | (MRI) Ruby 1.8.7 
     | 
| 
       65 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.8.7 
     | 
| 
       66 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.1 
     | 
| 
       67 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.1 
     | 
| 
       68 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.2 
     | 
| 
       69 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9.2 
     | 
| 
       70 
     | 
    
         
            -
               
     | 
| 
       71 
     | 
    
         
            -
              | 
     | 
| 
       72 
     | 
    
         
            -
               
     | 
| 
       73 
     | 
    
         
            -
              | 
     | 
| 
       74 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1. 
     | 
| 
       75 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9. 
     | 
| 
       76 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9. 
     | 
| 
       77 
     | 
    
         
            -
               
     | 
| 
       78 
     | 
    
         
            -
              | 
     | 
| 
       79 
     | 
    
         
            -
              |                                         | ( 
     | 
| 
       80 
     | 
    
         
            -
              |                                         | ( 
     | 
| 
       81 
     | 
    
         
            -
               
     | 
| 
       82 
     | 
    
         
            -
              | 
     | 
| 
       83 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1. 
     | 
| 
       84 
     | 
    
         
            -
               
     | 
| 
       85 
     | 
    
         
            -
              | 
     | 
| 
       86 
     | 
    
         
            -
              |                                         | (MRI) Ruby 1.9. 
     | 
| 
       87 
     | 
    
         
            -
               
     | 
| 
      
 50 
     | 
    
         
            +
            by me: gmp gem 0.5.41 on:
         
     | 
| 
      
 51 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
      
 52 
     | 
    
         
            +
              |    Platform                             |        Ruby        |     GMP (MPFR)    |
         
     | 
| 
      
 53 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
      
 54 
     | 
    
         
            +
              | Linux (Ubuntu NR 10.04) on x86 (32-bit) | (MRI) Ruby 1.8.7   | GMP 4.3.1 (2.4.2) |
         
     | 
| 
      
 55 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 56 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 57 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 4.3.1 (2.4.2) |
         
     | 
| 
      
 58 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 59 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 60 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 4.3.1 (2.4.2) |
         
     | 
| 
      
 61 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 62 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 63 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
      
 64 
     | 
    
         
            +
              | Linux (Ubuntu 10.04) on x86_64 (64-bit) | (MRI) Ruby 1.8.7   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 65 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 66 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 67 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 68 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 69 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 70 
     | 
    
         
            +
              |                                         | (RBX) Rubinius 1.1 | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 71 
     | 
    
         
            +
              |                                         | (RBX) Rubinius 1.1 | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 72 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
      
 73 
     | 
    
         
            +
              | Mac OS X 10.6.4 on x86_64 (64-bit)      | (MRI) Ruby 1.8.7   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 74 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 75 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 76 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 77 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 78 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 79 
     | 
    
         
            +
              |                                         | (RBX) Rubinius 1.1 | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 80 
     | 
    
         
            +
              |                                         | (RBX) Rubinius 1.1 | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 81 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
      
 82 
     | 
    
         
            +
              | Windows 7 on x86_64 (64-bit)            | (MRI) Ruby 1.8.7   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 83 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.8.7   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 84 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 85 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 86 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 87 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.2   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 88 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
      
 89 
     | 
    
         
            +
              | Windows XP on x86 (32-bit)              | (MRI) Ruby 1.9.1   | GMP 4.3.2 (2.4.2) |
         
     | 
| 
      
 90 
     | 
    
         
            +
              |                                         | (MRI) Ruby 1.9.1   | GMP 5.0.1 (3.0.0) |
         
     | 
| 
      
 91 
     | 
    
         
            +
              +-----------------------------------------+--------------------+-------------------+
         
     | 
| 
       88 
92 
     | 
    
         | 
| 
       89 
93 
     | 
    
         
             
            =Authors
         
     | 
| 
       90 
94 
     | 
    
         | 
| 
         @@ -317,6 +321,33 @@ You can also call them as: 
     | 
|
| 
       317 
321 
     | 
    
         
             
                                         number within 0 <= rop < 1
         
     | 
| 
       318 
322 
     | 
    
         | 
| 
       319 
323 
     | 
    
         | 
| 
      
 324 
     | 
    
         
            +
            =Functional Mappings
         
     | 
| 
      
 325 
     | 
    
         
            +
             
     | 
| 
      
 326 
     | 
    
         
            +
            In order to align better with the GMP paradigms of using return arguments, I have started creating "functional mappings", singleton methods that map directly to functions in GMP. These methods take return arguments, so that passing an object to a functional mapping may change the object itself. For example:
         
     | 
| 
      
 327 
     | 
    
         
            +
             
     | 
| 
      
 328 
     | 
    
         
            +
              a = GMP::Z(0)
         
     | 
| 
      
 329 
     | 
    
         
            +
              b = GMP::Z(13)
         
     | 
| 
      
 330 
     | 
    
         
            +
              c = GMP::Z(17)
         
     | 
| 
      
 331 
     | 
    
         
            +
              GMP::Z.add(a, b, c)
         
     | 
| 
      
 332 
     | 
    
         
            +
              a  #=> 30
         
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
      
 334 
     | 
    
         
            +
            Here's a fun list of all of the functional mappings written so far:
         
     | 
| 
      
 335 
     | 
    
         
            +
             
     | 
| 
      
 336 
     | 
    
         
            +
              GMP::Z
         
     | 
| 
      
 337 
     | 
    
         
            +
                .abs          .add          .addmul       .cdiv_q_2exp  .cdiv_r_2exp  .com
         
     | 
| 
      
 338 
     | 
    
         
            +
                .divexact     .fdiv_q_2exp  .fdiv_r_2exp  .lcm          .mul          .mul_2exp
         
     | 
| 
      
 339 
     | 
    
         
            +
                .neg          .nextprime    .sqrt         .sub          .submul       .tdiv_q_2exp
         
     | 
| 
      
 340 
     | 
    
         
            +
                .tdiv_r_2exp
         
     | 
| 
      
 341 
     | 
    
         
            +
             
     | 
| 
      
 342 
     | 
    
         
            +
            =Documentation
         
     | 
| 
      
 343 
     | 
    
         
            +
             
     | 
| 
      
 344 
     | 
    
         
            +
            * This README (https://github.com/srawlins/gmp)
         
     | 
| 
      
 345 
     | 
    
         
            +
            * Loren Segal and the guys at RubyGems.org are badasses. YARDoc is here:
         
     | 
| 
      
 346 
     | 
    
         
            +
              http://rubydoc.info/gems/gmp/frames
         
     | 
| 
      
 347 
     | 
    
         
            +
            * There should be a manual.pdf at https://github.com/srawlins/gmp/blob/master/manual.pdf
         
     | 
| 
      
 348 
     | 
    
         
            +
              I spend waaay too much time working on this, but it looks very pretty.
         
     | 
| 
      
 349 
     | 
    
         
            +
            * CHANGELOG (https://github.com/srawlins/gmp/blob/master/CHANGELOG)
         
     | 
| 
      
 350 
     | 
    
         
            +
             
     | 
| 
       320 
351 
     | 
    
         
             
            =Testing
         
     | 
| 
       321 
352 
     | 
    
         | 
| 
       322 
353 
     | 
    
         
             
            Tests can be run with:
         
     | 
| 
         @@ -384,36 +415,6 @@ Right now, there are only three such plugged in ruby scripts: 
     | 
|
| 
       384 
415 
     | 
    
         | 
| 
       385 
416 
     | 
    
         
             
            <b>OOOLLLDDD... UPDATE PLZ</b>
         
     | 
| 
       386 
417 
     | 
    
         | 
| 
       387 
     | 
    
         
            -
            Results: on my little Intel Core Duo T2400 @ 1.83GHz:
         
     | 
| 
       388 
     | 
    
         
            -
              +---------------------------------------------------------+
         
     | 
| 
       389 
     | 
    
         
            -
              | GMP 4.3.1* compiled with GCC 3.4.4, I think (cygwin did |
         
     | 
| 
       390 
     | 
    
         
            -
              | it)                                                     |
         
     | 
| 
       391 
     | 
    
         
            -
              +------------+-----------+--------------------------------+
         
     | 
| 
       392 
     | 
    
         
            -
              |  test      |  GMP      |  ruby gmp gem                  |
         
     | 
| 
       393 
     | 
    
         
            -
              |  multiply  |  4660     |        2473.8  (47% overhead)  |
         
     | 
| 
       394 
     | 
    
         
            -
              |  divide    |  2744     |        2253.1  (18% overhead)  |
         
     | 
| 
       395 
     | 
    
         
            -
              |  gcd       |  1004.5   |         865.13 (14% overhead)  |
         
     | 
| 
       396 
     | 
    
         
            -
              |  rsa       |   515.49  |         506.69 ( 2% overhead)  |
         
     | 
| 
       397 
     | 
    
         
            -
              +------------+-----------+--------------------------------+
         
     | 
| 
       398 
     | 
    
         
            -
              | GMP 5.0.0 compiled with GCC 3.4.4, I think (cygwin did  |
         
     | 
| 
       399 
     | 
    
         
            -
              | it)                                                     |
         
     | 
| 
       400 
     | 
    
         
            -
              +------------+-----------+--------------------------------+
         
     | 
| 
       401 
     | 
    
         
            -
              |  test      |  GMP      |  ruby gmp gem                  |
         
     | 
| 
       402 
     | 
    
         
            -
              |  multiply  |  4905     |        2572.1  (48% overhead)  |
         
     | 
| 
       403 
     | 
    
         
            -
              |  divide    |  4873     |        3427.4  (30% overhead)  |
         
     | 
| 
       404 
     | 
    
         
            -
              |  gcd       |  1083.5   |         931.75 (14% overhead)  |
         
     | 
| 
       405 
     | 
    
         
            -
              |  rsa       |   520.20  |         506.14 ( 3% overhead)  |
         
     | 
| 
       406 
     | 
    
         
            -
              +------------+--------+-----------------------------------+
         
     | 
| 
       407 
     | 
    
         
            -
              | GMP 5.0.1 compiled with GCC 3.4.5 in MinGW              |
         
     | 
| 
       408 
     | 
    
         
            -
              +------------+-----------+--------------------------------+
         
     | 
| 
       409 
     | 
    
         
            -
              |  test      |  GMP      |  ruby gmp gem                  |
         
     | 
| 
       410 
     | 
    
         
            -
              |  multiply  |  4950     |        xxxx.x  (xx% overhead)  |
         
     | 
| 
       411 
     | 
    
         
            -
              |  divide    |  4809     |        xxxx.x  (xx% overhead)  |
         
     | 
| 
       412 
     | 
    
         
            -
              |  gcd       |  1071.3   |         xxx.xx (xx% overhead)  |
         
     | 
| 
       413 
     | 
    
         
            -
              |  rsa       |   524.96  |         xxx.xx ( x% overhead)  |
         
     | 
| 
       414 
     | 
    
         
            -
              +------------+--------+-----------------------------------+
         
     | 
| 
       415 
     | 
    
         
            -
            \* GMP 4.3.2 evaluated to almost the same benchmarks.
         
     | 
| 
       416 
     | 
    
         
            -
             
     | 
| 
       417 
418 
     | 
    
         
             
            My guess is that the increase in ruby gmp gem overhead is caused by increased
         
     | 
| 
       418 
419 
     | 
    
         
             
            efficiency in GMP; the inefficiencies of the gmp gem are relatively greater.
         
     | 
| 
       419 
420 
     | 
    
         | 
| 
         @@ -423,6 +424,7 @@ efficiency in GMP; the inefficiencies of the gmp gem are relatively greater. 
     | 
|
| 
       423 
424 
     | 
    
         
             
              #fib2, #lucnum, #lucnum2, #hamdist, #combit, #fits_x?
         
     | 
| 
       424 
425 
     | 
    
         
             
            * GMP::Q#to_s(base), GMP::F#to_s(base) (test it!)
         
     | 
| 
       425 
426 
     | 
    
         
             
            * benchmark gcdext, pi
         
     | 
| 
      
 427 
     | 
    
         
            +
            * use Rake use Rake use Rake
         
     | 
| 
       426 
428 
     | 
    
         | 
| 
       427 
429 
     | 
    
         
             
            These are inherited from Tomasz. I will go through these and see which are
         
     | 
| 
       428 
430 
     | 
    
         
             
            still relevant, and which I understand.
         
     | 
| 
         @@ -0,0 +1,47 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            require '../ext/gmp'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            multiplicands = ARGV
         
     | 
| 
      
 6 
     | 
    
         
            +
            random_state = GMP::RandState.new
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            if multiplicands.size > 1
         
     | 
| 
      
 9 
     | 
    
         
            +
              m, n = multiplicands[0].to_i, multiplicands[1].to_i
         
     | 
| 
      
 10 
     | 
    
         
            +
              x = random_state.urandomb(m)
         
     | 
| 
      
 11 
     | 
    
         
            +
              y = random_state.urandomb(n)
         
     | 
| 
      
 12 
     | 
    
         
            +
            else
         
     | 
| 
      
 13 
     | 
    
         
            +
              m = multiplicands[0].to_i
         
     | 
| 
      
 14 
     | 
    
         
            +
              x = random_state.urandomb(m)
         
     | 
| 
      
 15 
     | 
    
         
            +
              y = x
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            z = GMP::Z()
         
     | 
| 
      
 19 
     | 
    
         
            +
            #t = GMP::time { z = x * y }
         
     | 
| 
      
 20 
     | 
    
         
            +
            t = GMP::time { GMP::Z.mul(z,x,y) }
         
     | 
| 
      
 21 
     | 
    
         
            +
            iterations = (1 + (1e4 / t)).to_i
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
            if multiplicands.size > 1
         
     | 
| 
      
 24 
     | 
    
         
            +
              print "Multiplying %i-bit number with %i-bit number %i times..." % [m, n, iterations]
         
     | 
| 
      
 25 
     | 
    
         
            +
            else
         
     | 
| 
      
 26 
     | 
    
         
            +
              print "Squaring a %i-bit number %i times..." % [m, iterations]
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
            STDOUT.flush
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            t0 = GMP::cputime
         
     | 
| 
      
 31 
     | 
    
         
            +
            iterations.times do
         
     | 
| 
      
 32 
     | 
    
         
            +
              #z = x * y
         
     | 
| 
      
 33 
     | 
    
         
            +
              GMP::Z.mul(z,x,y)
         
     | 
| 
      
 34 
     | 
    
         
            +
            end
         
     | 
| 
      
 35 
     | 
    
         
            +
            ti = GMP::cputime - t0
         
     | 
| 
      
 36 
     | 
    
         
            +
              
         
     | 
| 
      
 37 
     | 
    
         
            +
            puts "done!"
         
     | 
| 
      
 38 
     | 
    
         
            +
            ops_per_sec = 1000.0 * iterations / ti
         
     | 
| 
      
 39 
     | 
    
         
            +
            f = 100.0
         
     | 
| 
      
 40 
     | 
    
         
            +
            decimals = 0
         
     | 
| 
      
 41 
     | 
    
         
            +
            while true
         
     | 
| 
      
 42 
     | 
    
         
            +
              decimals += 1
         
     | 
| 
      
 43 
     | 
    
         
            +
              break if ops_per_sec > f
         
     | 
| 
      
 44 
     | 
    
         
            +
              f = f * 0.1
         
     | 
| 
      
 45 
     | 
    
         
            +
            end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            puts "RESULT: %#{decimals}f operations per second\n" % ops_per_sec
         
     | 
    
        data/ext/extconf.rb
    CHANGED
    
    
    
        data/ext/gmp.so
    CHANGED
    
    | 
         Binary file 
     | 
    
        data/ext/gmpf.c
    CHANGED
    
    | 
         @@ -1211,6 +1211,7 @@ void init_gmpf() 
     | 
|
| 
       1211 
1211 
     | 
    
         
             
              // Float Arithmetic
         
     | 
| 
       1212 
1212 
     | 
    
         
             
              rb_define_method(cGMP_F, "-", r_gmpf_sub, 1);
         
     | 
| 
       1213 
1213 
     | 
    
         
             
              rb_define_method(cGMP_F, "/", r_gmpf_div, 1);
         
     | 
| 
      
 1214 
     | 
    
         
            +
              rb_define_alias(cGMP_F, "divide", "/");
         
     | 
| 
       1214 
1215 
     | 
    
         
             
            #ifndef MPFR
         
     | 
| 
       1215 
1216 
     | 
    
         
             
              rb_define_method(cGMP_F, "+", r_gmpf_add, 1);
         
     | 
| 
       1216 
1217 
     | 
    
         
             
              rb_define_method(cGMP_F, "*", r_gmpf_mul, 1);
         
     |