Anomaly in mpn_sqrtrem and mpn_rottrem

Torbjörn Granlund tg at gmplib.org
Thu May 28 07:17:11 UTC 2015


Paul Zimmermann has pointed out to us that mpn_rootrem is sometimes
faster than mpn_sqrtrem, specifically when not requesting the remainder.

When requesting the remainder we have anomalous behaviour too, but in
the other "direction":

          mpn_sqrtrem mpn_rootrem.2 mpn_rootrem.3
1              #38.84       2161.80       2459.40
2             #125.42       2419.00       2878.00
3             #352.65       2721.25       2907.75
4             #301.31       2812.50       3454.33
5             #531.16       3080.75       3445.67
7             #595.18       3408.67       3851.00
9             #954.00       4050.33       3908.33
12            #836.83       4125.00       4325.33
16           #1168.00       4586.00       5189.00
22           #1710.17       5333.00       5565.00
30           #2333.40       6166.00       6711.50
42           #3556.33       7698.50       8360.50
58           #4607.33      10684.00      12585.00
81           #7675.00      13746.00      16511.00
113         #10920.00      19760.00      24908.00
158         #16435.00      27297.00      35592.00
221         #26308.00      41151.00      54227.00
309         #42636.00      65637.00      85184.00
432         #71155.00     105516.00     136874.00
604        #117906.00     175414.00     220812.00
845        #205120.00     388529.00     363189.00

Surely, we could make mpn_rootrem run faster, in particular for small
arguments.  But also for large arguments, 2x slowdown seems like a lot.

-- 
Torbjörn
Please encrypt, key id 0xC8601622


More information about the gmp-devel mailing list