Givaro
Public Types | Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes
Montgomery< int32_t > Class Reference

This class implements the standard arithmetic with Modulo Elements. More...

#include <montgomery-int32.h>

Public Types

enum  { size_rep = sizeof(Residu_t) }
 
using Self_t = Montgomery< int32_t >
 
using Element = uint32_t
 
using Element_ptr = Element *
 
using ConstElement = const Element
 
using ConstElement_ptr = const Element *
 
using Residu_t = uint32_t
 
typedef ModularRandIter< Self_tRandIter
 
typedef GeneralRingNonZeroRandIter< Self_tNonZeroRandIter
 

Public Member Functions

 Montgomery ()
 
 Montgomery (Residu_t p, int=1)
 
 Montgomery (const Self_t &F)
 
Self_toperator= (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
 
Elementinit (Element &x) const
 
Elementinit (Element &x, const double a) const
 
Elementinit (Element &x, const int64_t a) const
 
Elementinit (Element &x, const uint64_t a) const
 
Elementinit (Element &x, const Integer &a) const
 
template<typename T >
Elementinit (Element &r, const T &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::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 = 0
 
const Element one
 
const Element mOne
 

Protected Member Functions

Elementredc (Element &, const Element) const
 
Element redcal (const Element) const
 
Element redcsal (const Element) const
 
Elementredcin (Element &) const
 
Elementredcs (Element &, const Element) const
 
Elementredcsin (Element &) const
 

Protected Attributes

Residu_t _p
 
Residu_t _Bp
 
Residu_t _B2p
 
Residu_t _B3p
 
Residu_t _nim
 
double _dp
 

Detailed Description

This class implements the standard arithmetic with Modulo Elements.

Reduction is made through Montgomery's reduction. Representation of a is by storing (aB).

Member Typedef Documentation

◆ Self_t

using Self_t = Montgomery<int32_t>

◆ Element

using Element = uint32_t

◆ Element_ptr

using Element_ptr = Element*

◆ ConstElement

using ConstElement = const Element

◆ ConstElement_ptr

using ConstElement_ptr = const Element*

◆ Residu_t

using Residu_t = uint32_t

◆ RandIter

◆ NonZeroRandIter

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
size_rep 

Constructor & Destructor Documentation

◆ Montgomery() [1/3]

Montgomery ( )
inline

◆ Montgomery() [2/3]

Montgomery ( Residu_t  p,
int  = 1 
)
inline

◆ Montgomery() [3/3]

Montgomery ( const Self_t F)
inline

Member Function Documentation

◆ operator=()

Self_t& operator= ( const Self_t F)
inline

◆ 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

◆ init() [1/6]

Element& init ( Element x) const
inline

◆ init() [2/6]

Montgomery< int32_t >::Element & init ( Element x,
const double  a 
) const
inline

◆ init() [3/6]

Montgomery< int32_t >::Element & init ( Element x,
const int64_t  a 
) const
inline

◆ init() [4/6]

Montgomery< int32_t >::Element & init ( Element x,
const uint64_t  a 
) const
inline

◆ init() [5/6]

Montgomery< int32_t >::Element & init ( Element x,
const Integer a 
) const
inline

◆ init() [6/6]

Element& init ( Element r,
const T &  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< int32_t >::Element & mul ( Element r,
const Element a,
const Element b 
) const
inline

◆ div()

Montgomery< int32_t >::Element & div ( Element r,
const Element a,
const Element b 
) const
inline

◆ add()

Montgomery< int32_t >::Element & add ( Element r,
const Element a,
const Element b 
) const
inline

◆ sub()

Montgomery< int32_t >::Element & sub ( Element r,
const Element a,
const Element b 
) const
inline

◆ neg()

Montgomery< int32_t >::Element & neg ( Element r,
const Element a 
) const
inline

◆ inv()

Montgomery< int32_t >::Element & inv ( Element r,
const Element a 
) const
inline

◆ mulin()

Montgomery< int32_t >::Element & mulin ( Element r,
const Element a 
) const
inline

◆ divin()

Montgomery< int32_t >::Element & divin ( Element r,
const Element a 
) const
inline

◆ addin()

Montgomery< int32_t >::Element & addin ( Element r,
const Element a 
) const
inline

◆ subin()

Montgomery< int32_t >::Element & subin ( Element r,
const Element a 
) const
inline

◆ negin()

Montgomery< int32_t >::Element & negin ( Element r) const
inline

◆ invin()

Montgomery< int32_t >::Element & invin ( Element r) const
inline

◆ axpy()

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

◆ axpyin()

Montgomery< int32_t >::Element & axpyin ( Element r,
const Element a,
const Element x 
) const
inline

◆ axmy()

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

◆ axmyin()

Montgomery< int32_t >::Element & axmyin ( Element r,
const Element a,
const Element x 
) const
inline

◆ maxpy()

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

◆ maxpyin()

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

◆ write() [1/2]

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

◆ read()

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

◆ write() [2/2]

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

◆ redc()

Montgomery< int32_t >::Element & redc ( Element r,
const Element  c 
) const
inlineprotected

◆ redcal()

Montgomery< int32_t >::Element redcal ( const Element  c) const
inlineprotected

◆ redcsal()

Montgomery< int32_t >::Element redcsal ( const Element  c) const
inlineprotected

◆ redcin()

Montgomery< int32_t >::Element & redcin ( Element r) const
inlineprotected

◆ redcs()

Montgomery< int32_t >::Element & redcs ( Element r,
const Element  c 
) const
inlineprotected

◆ redcsin()

Montgomery< int32_t >::Element & redcsin ( Element r) const
inlineprotected

Field Documentation

◆ zero

const Element zero = 0

◆ one

const Element one

◆ mOne

const Element mOne

◆ _p

Residu_t _p
protected

◆ _Bp

Residu_t _Bp
protected

◆ _B2p

Residu_t _B2p
protected

◆ _B3p

Residu_t _B3p
protected

◆ _nim

Residu_t _nim
protected

◆ _dp

double _dp
protected

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