Givaro
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Montgomery< RecInt::ruint< K > > Class Template Reference

The recint-based Montgomery ring. More...

#include <montgomery-ruint.h>

+ Collaboration diagram for Montgomery< RecInt::ruint< K > >:

Public Types

enum  { size_rep = sizeof(Residu_t) }
 
using Element = RecInt::ruint< K >
 
using LargeElement = RecInt::ruint< K+1 >
 
using Self_t = Montgomery< RecInt::ruint< K > >
 
using Residu_t = RecInt::ruint< K >
 
typedef ElementArray
 
using Element_ptr = Element *
 
using ConstElement_ptr = const Element *
 
typedef ModularRandIter< Self_tRandIter
 
typedef GeneralRingNonZeroRandIter< Self_tNonZeroRandIter
 

Public Member Functions

 Montgomery ()
 
 Montgomery (const Residu_t &p)
 
 Montgomery (const Self_t &F)
 
Element minElement () const
 
Element maxElement () const
 
Residu_t residu () const
 
Residu_t size () const
 
Residu_t characteristic () const
 
Residu_t cardinality () const
 
template<class T >
T & characteristic (T &p) const
 
template<class T >
T & cardinality (T &p) const
 
bool isZero (const Element &a) const
 
bool isOne (const Element &a) const
 
bool isMOne (const Element &a) const
 
bool isUnit (const Element &a) const
 
bool areEqual (const Element &a, const Element &b) const
 
size_t length (const Element a) const
 
bool operator== (const Self_t &F) const
 
bool operator!= (const Self_t &F) const
 
Self_toperator= (const Self_t &F)
 
Elementinit (Element &x) const
 
template<typename T >
Elementinit (Element &r, const T &a) const
 
Elementinit (Element &r, const Integer &a) const
 
Elementassign (Element &x, const Element &y) const
 
template<typename T >
T & convert (T &r, const Element &a) const
 
Elementreduce (Element &x, const Element &y) const
 
Elementreduce (Element &x) const
 
Elementmul (Element &r, const Element &a, const Element &b) const
 
Elementdiv (Element &r, const Element &a, const Element &b) const
 
Elementadd (Element &r, const Element &a, const Element &b) const
 
Elementsub (Element &r, const Element &a, const Element &b) const
 
Elementneg (Element &r, const Element &a) const
 
Elementinv (Element &r, const Element &a) const
 
Elementmulin (Element &r, const Element &a) const
 
Elementdivin (Element &r, const Element &a) const
 
Elementaddin (Element &r, const Element &a) const
 
Elementsubin (Element &r, const Element &a) const
 
Elementnegin (Element &r) const
 
Elementinvin (Element &r) const
 
Elementaxpy (Element &r, const Element &a, const Element &x, const Element &y) const
 
Elementaxpyin (Element &r, const Element &a, const Element &x) const
 
Elementaxmy (Element &r, const Element &a, const Element &x, const Element &y) const
 
Elementaxmyin (Element &r, const Element &a, const Element &x) const
 
Elementmaxpy (Element &r, const Element &a, const Element &x, const Element &y) const
 
Elementmaxpyin (Element &r, const Element &a, const Element &x) const
 
template<class Random >
Elementrandom (Random &g, Element &r) const
 
template<class Random >
Elementnonzerorandom (Random &g, Element &a) const
 
std::istream & read (std::istream &s)
 
std::ostream & write (std::ostream &s) const
 
std::istream & read (std::istream &s, Element &a) const
 
std::ostream & write (std::ostream &s, const Element &a) const
 

Static Public Member Functions

static Residu_t maxCardinality ()
 
static Residu_t minCardinality ()
 

Data Fields

const Element zero
 
const Element one
 
const Element mOne
 

Protected Member Functions

Elementmg_reduc (Element &a, const Element &b) const
 
Elementmg_reduc (Element &a, const LargeElement &b) const
 
Elementto_mg (Element &a, const Element &b) const
 
Elementto_mg (Element &a) const
 

Protected Attributes

RecInt::ruint< K > _p
 
RecInt::ruint< K > _p1
 
RecInt::ruint< K > _r
 
RecInt::ruint< K > _r2
 
RecInt::ruint< K > _r3
 

Detailed Description

template<size_t K>
class Givaro::Montgomery< RecInt::ruint< K > >

The recint-based Montgomery ring.

Only odd moduli allowed An integer (a mod p) is stored as (a * r mod 2^{2^K}) with (r = 2^{2^K} mod p).

Member Typedef Documentation

◆ Element

using Element = RecInt::ruint<K>

◆ LargeElement

◆ Self_t

◆ Residu_t

using Residu_t = RecInt::ruint<K>

◆ Array

typedef Element* Array

◆ Element_ptr

using Element_ptr = Element*

◆ ConstElement_ptr

using ConstElement_ptr = const Element*

◆ RandIter

◆ NonZeroRandIter

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
size_rep 

Constructor & Destructor Documentation

◆ Montgomery() [1/3]

Montgomery ( )
inline

◆ Montgomery() [2/3]

Montgomery ( const Residu_t p)
inline

◆ Montgomery() [3/3]

Montgomery ( const Self_t F)
inline

Member Function Documentation

◆ minElement()

Element minElement ( ) const
inline

◆ maxElement()

Element maxElement ( ) const
inline

◆ residu()

Residu_t residu ( ) const
inline

◆ size()

Residu_t size ( ) const
inline

◆ characteristic() [1/2]

Residu_t characteristic ( ) const
inline

◆ cardinality() [1/2]

Residu_t cardinality ( ) const
inline

◆ characteristic() [2/2]

T& characteristic ( T &  p) const
inline

◆ cardinality() [2/2]

T& cardinality ( T &  p) const
inline

◆ maxCardinality()

static Residu_t maxCardinality ( )
inlinestatic

◆ minCardinality()

static Residu_t minCardinality ( )
inlinestatic

◆ isZero()

bool isZero ( const Element a) const
inline

◆ isOne()

bool isOne ( const Element a) const
inline

◆ isMOne()

bool isMOne ( const Element a) const
inline

◆ isUnit()

bool isUnit ( const Element a) const
inline

◆ areEqual()

bool areEqual ( const Element a,
const Element b 
) const
inline

◆ length()

size_t length ( const Element  a) const
inline

◆ operator==()

bool operator== ( const Self_t F) const
inline

◆ operator!=()

bool operator!= ( const Self_t F) const
inline

◆ operator=()

Self_t& operator= ( const Self_t F)
inline

◆ init() [1/3]

Element& init ( Element x) const
inline

◆ init() [2/3]

Element& init ( Element r,
const T &  a 
) const
inline

◆ init() [3/3]

Element& init ( Element r,
const Integer a 
) const
inline

◆ assign()

Element& assign ( Element x,
const Element y 
) const
inline

◆ convert()

T& convert ( T &  r,
const Element a 
) const
inline

◆ reduce() [1/2]

Element& reduce ( Element x,
const Element y 
) const
inline

◆ reduce() [2/2]

Element& reduce ( Element x) const
inline

◆ mul()

Montgomery< RecInt::ruint< K > >::Element & mul ( Element r,
const Element a,
const Element b 
) const
inline

◆ div()

Montgomery< RecInt::ruint< K > >::Element & div ( Element r,
const Element a,
const Element b 
) const
inline

◆ add()

Montgomery< RecInt::ruint< K > >::Element & add ( Element r,
const Element a,
const Element b 
) const
inline

◆ sub()

Montgomery< RecInt::ruint< K > >::Element & sub ( Element r,
const Element a,
const Element b 
) const
inline

◆ neg()

Montgomery< RecInt::ruint< K > >::Element & neg ( Element r,
const Element a 
) const
inline

◆ inv()

Montgomery< RecInt::ruint< K > >::Element & inv ( Element r,
const Element a 
) const
inline

◆ mulin()

Montgomery< RecInt::ruint< K > >::Element & mulin ( Element r,
const Element a 
) const
inline

◆ divin()

Montgomery< RecInt::ruint< K > >::Element & divin ( Element r,
const Element a 
) const
inline

◆ addin()

Montgomery< RecInt::ruint< K > >::Element & addin ( Element r,
const Element a 
) const
inline

◆ subin()

Montgomery< RecInt::ruint< K > >::Element & subin ( Element r,
const Element a 
) const
inline

◆ negin()

Montgomery< RecInt::ruint< K > >::Element & negin ( Element r) const
inline

◆ invin()

Montgomery< RecInt::ruint< K > >::Element & invin ( Element r) const
inline

◆ axpy()

Montgomery< RecInt::ruint< K > >::Element & axpy ( Element r,
const Element a,
const Element x,
const Element y 
) const
inline

◆ axpyin()

Montgomery< RecInt::ruint< K > >::Element & axpyin ( Element r,
const Element a,
const Element x 
) const
inline

◆ axmy()

Montgomery< RecInt::ruint< K > >::Element & axmy ( Element r,
const Element a,
const Element x,
const Element y 
) const
inline

◆ axmyin()

Montgomery< RecInt::ruint< K > >::Element & axmyin ( Element r,
const Element a,
const Element x 
) const
inline

◆ maxpy()

Montgomery< RecInt::ruint< K > >::Element & maxpy ( Element r,
const Element a,
const Element x,
const Element y 
) const
inline

◆ maxpyin()

Montgomery< RecInt::ruint< K > >::Element & maxpyin ( Element r,
const Element a,
const Element x 
) const
inline

◆ random()

Element& random ( Random &  g,
Element r 
) const
inline

◆ nonzerorandom()

Element& nonzerorandom ( Random &  g,
Element a 
) const
inline

◆ read() [1/2]

std::istream& read ( std::istream &  s)

◆ write() [1/2]

std::ostream & write ( std::ostream &  s) const
inline

◆ read() [2/2]

std::istream & read ( std::istream &  s,
Element a 
) const
inline

◆ write() [2/2]

std::ostream & write ( std::ostream &  s,
const Element a 
) const
inline

◆ mg_reduc() [1/2]

Montgomery< RecInt::ruint< K > >::Element & mg_reduc ( Element a,
const Element b 
) const
inlineprotected

◆ mg_reduc() [2/2]

Montgomery< RecInt::ruint< K > >::Element & mg_reduc ( Element a,
const LargeElement b 
) const
inlineprotected

◆ to_mg() [1/2]

Montgomery< RecInt::ruint< K > >::Element & to_mg ( Element a,
const Element b 
) const
inlineprotected

◆ to_mg() [2/2]

Montgomery< RecInt::ruint< K > >::Element & to_mg ( Element a) const
inlineprotected

Field Documentation

◆ zero

const Element zero

◆ one

const Element one

◆ mOne

const Element mOne

◆ _p

RecInt::ruint<K> _p
protected

◆ _p1

RecInt::ruint<K> _p1
protected

◆ _r

RecInt::ruint<K> _r
protected

◆ _r2

RecInt::ruint<K> _r2
protected

◆ _r3

RecInt::ruint<K> _r3
protected

The documentation for this class was generated from the following files: