Shared toom evaluation functions

bodrato at bodrato at
Mon Nov 16 16:36:16 CET 2009

> nisse at (Niels Möller) writes:
>   I'm not sure I understand what the function mpn_rsblsh1_n does and why

>   Anyway, if you know what to do, you can start with
>   toom_eval_dgr3_pm2.c, which is in the tree.

I meant mpn_addlsh2_n, for toom_eval_dgr3_pm2 I did the following:

> mpn_addlsh1_n computes R = U + 2 V
> mpn_sublsh1_n computes R = U - 2 V
> mpn_rsblsh1_n computes R = 2 V - U

After computing U=(a0 + 4a2) and V=(a1 + 4a3) one needs
(U + 2V) and ABS(U - 2V)... which may be computed with sublsh1 or rsblsh1.

One question arises:
 -it is better to shift once V = 2V then compare and add_sub;
 -or make a more complicated comparison, then addlsh1 on one side and
{sub|rsb}lsh1 on the other?
Current code uses the first strategy.

Another possible use for rsblsh1 is to implement add_n_sub_n without
allocating temporaries:


computes (plus, minus) <- (minus + plus, minus - plus)

But it obviously is not the fastest way :-)



More information about the gmp-devel mailing list