mul_mod_helper< C, void, m > Struct Template Reference

#include <modular_int.hpp>

List of all members.

Public Types

Static Public Member Functions

Static Public Attributes


Detailed Description

template<typename V>
template<typename C, nat m>
struct mmx::modulus_mul_int_preinverse< V >::mul_mod_helper< C, void, m >

Definition at line 784 of file modular_int.hpp.


Member Typedef Documentation

Definition at line 791 of file modular_int.hpp.

Definition at line 788 of file modular_int.hpp.

Definition at line 789 of file modular_int.hpp.

Definition at line 790 of file modular_int.hpp.


Member Function Documentation

static void op ( C dest,
const C src,
const C p,
C carry,
const C q,
nat  r,
nat  s,
nat  t 
) [inline, static]

Definition at line 843 of file modular_int.hpp.

References mmx::C, mul_mod_helper< C, D, m >::n, and mul_mod_helper< C, D, m >::op().

00844                                          {
00845 
00846       C a1, a0, hi_a1, hi_a0;
00847       C tmp = dest;
00848       
00849       long_mul::op (a1, a0, tmp, src);
00850       hi_a1 = a1;
00851       hi_a0 = a0;
00852       long_rshift::op (hi_a1, hi_a0, s);
00853       C b1, b0, c = 0;
00854       long_mul::op (b1, b0, hi_a0, q);
00855       if (m >= n) {if (hi_a1 != 0) b1 += q;}
00856       if (m+1 <= n) {
00857         if (t >= n)
00858           if (n >= t) b0 = b1 << (n-t); else  b0 = b1 >> (t-n);
00859         else
00860           b0 = (b0 >> t) | (b1 << (n-t));
00861       }
00862       else
00863         long_rshift::op (b1, b0, t);
00864       if (m+2 <= n) {
00865         dest = a0 - b0 * p;
00866         if (dest >= p) { dest -= p; b0++; }
00867         V::add_mod_core (dest, carry, p, c); carry = b0 + c;
00868         return;
00869       }
00870       C d1, d0;
00871       long_mul::op (d1, d0, b0, p);
00872       long_sub::op (a1, a0, d1, d0);
00873       if (m+1 <= n) {
00874         if (long_ge::op (a1, a0, 0, p)) {
00875           dest = a0 - p; b0++;
00876           if (dest >= p) {
00877             dest -=p; b0++; } }
00878         else dest = a0;
00879         V::add_mod_core (dest, carry, p, c); carry = b0 + c;
00880         return;
00881       }
00882       if (long_ge::op (a1, a0, 0, p)) {
00883         long_sub::op (a1, a0, 0, p); b0++;
00884         if (long_ge::op (a1, a0, 0, p)) {
00885           long_sub::op (a1, a0, 0, p); b0++;
00886           if (long_ge::op (a1, a0, 0, p)) {
00887             a0 -= p; b0++; }
00888         }
00889       }
00890       dest = a0;
00891       V::add_mod_core (dest, carry, p, c); carry = b0 + c;
00892     }

static void op ( C dest,
const C src,
const C p,
const C q,
nat  r,
nat  s,
nat  t 
) [inline, static]

Definition at line 794 of file modular_int.hpp.

References mmx::C, mmx::min(), mul_mod_helper< C, D, m >::n, and mul_mod_helper< C, D, m >::op().

00795                                          {
00796 
00797       C a1, a0, hi_a1, hi_a0;
00798       C tmp = dest;
00799       
00800       long_mul::op (a1, a0, tmp, src);
00801       hi_a1 = a1;
00802       hi_a0 = a0;
00803       long_rshift::op (hi_a1, hi_a0, s);
00804       C b1, b0;
00805       long_mul::op (b1, b0, hi_a0, q);
00806       if (m >= n) {if (hi_a1 != 0) b1 += q;}
00807       if (m+1 <= n) {
00808         if (t >= n)
00809           if (n >= t) b0 = b1 << (n-t); else  b0 = b1 >> (t-n);
00810         else
00811           b0 = (b0 >> t) | (b1 << (n-t));
00812       }
00813       else
00814         long_rshift::op (b1, b0, t);
00815       if (m+2 <= n) {
00816         dest = a0 - b0*p;
00817         dest = min (dest, dest - p);
00818         return;
00819       }
00820       C d1, d0;
00821       long_mul::op (d1, d0, b0, p);
00822       long_sub::op (a1, a0, d1, d0);
00823       if (m+1 <= n) {
00824         if (long_ge::op (a1, a0, 0, p)) {
00825           dest = a0 - p;
00826           if (dest >= p)
00827             dest -=p; }
00828         else dest = a0;
00829         return;
00830       }
00831       if (long_ge::op (a1, a0, 0, p)) {
00832         long_sub::op (a1, a0, 0, p);
00833         if (long_ge::op (a1, a0, 0, p)) {
00834           long_sub::op (a1, a0, 0, p);
00835           if (long_ge::op (a1, a0, 0, p)) 
00836             a0 -= p;
00837         }
00838       }
00839       dest = a0;
00840     }


Member Data Documentation

const nat n = 8 * sizeof(C) [static]

Definition at line 787 of file modular_int.hpp.

const nat n2 = 4 * sizeof(C) [static]

Definition at line 786 of file modular_int.hpp.


The documentation for this struct was generated from the following file:

Generated on 6 Dec 2012 for numerix by  doxygen 1.6.1