mul_mod_helper< C, D, m > Struct Template Reference

#include <modular_int.hpp>

List of all members.

Static Public Member Functions

Static Public Attributes


Detailed Description

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

Definition at line 700 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 740 of file modular_int.hpp.

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

00741                                          {
00742       D a (dest);
00743       a *= src;
00744       if (m + 2 <= n) {
00745         C hi_a = a >> s;
00746         C b = (((D) hi_a) * q) >> t, c = 0;;
00747         dest = ((C) a) - b * p; 
00748         if (dest >= p) { dest -= p; b++; }
00749         V::add_mod_core (dest, carry, p, c); carry = b + c;
00750         return;
00751       }
00752       D hi_a = a >> s;
00753       C b = (hi_a * q) >> t, z= 0;
00754       D c = a - ((D) b) * p;
00755       if (m + 1 <= n) {
00756         if (c >= p) {
00757           dest = c - p; b++;
00758           if (dest >= p) {
00759             dest -= p; b++; }
00760         }
00761         else
00762           dest = c;
00763         V::add_mod_core (dest, carry, p, z); carry = b + z;
00764         return;
00765       }
00766       if (c >= p) {
00767         c -= p; b++;
00768         if (c >= p) {
00769           c -= p; b++;
00770           if (c >= p) {
00771             c -= p; b++; }
00772         }
00773       }
00774       dest = c;
00775       V::add_mod_core (dest, carry, p, z); carry = b + z;
00776     }

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 704 of file modular_int.hpp.

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

Referenced by modulus_mul_int_preinverse< modulus_add_int_naive< modulus_reduction_int_naive< modulus_normalization_int_naive< modulus_maximum_size_int< m > > > > >::mul_mod(), and mul_mod_helper< C, void, m >::op().

00705                                          {
00706       D a (dest);
00707       a *= src;
00708       if (m + 2 <= n) {
00709         C hi_a = a >> s;
00710         C b = (((D) hi_a) * q) >> t;
00711         dest = ((C) a) - b * p;
00712         if (dest >= p) dest -=p;
00713         return;
00714       }
00715       D hi_a = a >> s;
00716       C b = (hi_a * q) >> t;
00717       D c = a - ((D) b) * p;
00718       if (m + 1 <= n) {
00719         if (c >= p) {
00720           dest = c - p;
00721           if (dest >= p)
00722             dest -= p;
00723         }
00724         else
00725           dest = c;
00726         return;
00727       }
00728       if (c >= p) {
00729         c -= p;
00730         if (c >= p) {
00731           c -= p;
00732           if (c >= p) 
00733             c -= p;
00734         }
00735       }
00736       dest = c;
00737     }


Member Data Documentation

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

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

Generated on 6 Dec 2012 for numerix by  doxygen 1.6.1