Shared toom evaluation functions

bodrato at mail.dm.unipi.it bodrato at mail.dm.unipi.it
Mon Nov 16 16:36:16 CET 2009


> nisse at lysator.liu.se (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:
http://gmplib.org:8000/gmp/rev/3d7ed913d375

> 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:

mpn_add_n(plus,plus,minus,n);
mpn_rsblsh1_n(minus,plus,minus,n);

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

But it obviously is not the fastest way :-)

Regards,
Marco

-- 
http://bodrato.it/



More information about the gmp-devel mailing list