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

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

#include <montgomery-int32.h>

+ Inheritance diagram for Montgomery< int32_t >:
+ Collaboration diagram for Montgomery< int32_t >:

Public Types

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

Public Member Functions

 Montgomery ()
 
 Montgomery (Residu_t p, int=1)
 
 Montgomery (const Self_t &F)
 
Self_toperator= (const Self_t &F)
 
Element minElement () const override
 
Element maxElement () const override
 
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 override
 
bool isOne (const Element &a) const override
 
bool isMOne (const Element &a) const override
 
bool areEqual (const Element &a, const Element &b) const override
 
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 override
 
Elementdiv (Element &r, const Element &a, const Element &b) const override
 
Elementadd (Element &r, const Element &a, const Element &b) const override
 
Elementsub (Element &r, const Element &a, const Element &b) const override
 
Elementneg (Element &r, const Element &a) const override
 
Elementinv (Element &r, const Element &a) const override
 
Elementmulin (Element &r, const Element &a) const override
 
Elementdivin (Element &r, const Element &a) const override
 
Elementaddin (Element &r, const Element &a) const override
 
Elementsubin (Element &r, const Element &a) const override
 
Elementnegin (Element &r) const override
 
Elementinvin (Element &r) const override
 
Elementaxpy (Element &r, const Element &a, const Element &x, const Element &y) const override
 
Elementaxpyin (Element &r, const Element &a, const Element &x) const override
 
Elementaxmy (Element &r, const Element &a, const Element &x, const Element &y) const override
 
Elementaxmyin (Element &r, const Element &a, const Element &x) const override
 
Elementmaxpy (Element &r, const Element &a, const Element &x, const Element &y) const override
 
Elementmaxpyin (Element &r, const Element &a, const Element &x) const override
 
template<class Random >
Elementrandom (const Random &g, Element &r) const
 
template<class Random >
Elementnonzerorandom (const 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

template<>
class Givaro::Montgomery< int32_t >

This class implements the standard arithmetic with Modulo Elements.

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

Examples:
examples/FiniteField/all_field.C, examples/FiniteField/ff_arith.C, and examples/Polynomial/PolynomialCRT.C.

Member Typedef Documentation

using Self_t = Montgomery<int32_t>
using Residu_t = uint32_t
typedef uint32_t Element
inherited
typedef Element* Element_ptr
inherited
typedef const Element ConstElement
inherited
typedef const Element* ConstElement_ptr
inherited

Member Enumeration Documentation

anonymous enum
Enumerator
size_rep 

Constructor & Destructor Documentation

Montgomery ( )
inline
Montgomery ( Residu_t  p,
int  = 1 
)
inline
Montgomery ( const Self_t F)
inline

Member Function Documentation

Self_t& operator= ( const Self_t F)
inline
Element minElement ( ) const
inlineoverridevirtual
Element maxElement ( ) const
inlineoverridevirtual
Residu_t residu ( ) const
inline
Residu_t size ( ) const
inline
Residu_t characteristic ( ) const
inline
Residu_t cardinality ( ) const
inline
T& characteristic ( T &  p) const
inline
T& cardinality ( T &  p) const
inline
static Residu_t maxCardinality ( )
inlinestatic
static Residu_t minCardinality ( )
inlinestatic
bool isZero ( const Element a) const
inlineoverridevirtual
bool isOne ( const Element a) const
inlineoverridevirtual
bool isMOne ( const Element a) const
inlineoverridevirtual
bool areEqual ( const Element a,
const Element b 
) const
inlineoverridevirtual
size_t length ( const Element  a) const
inline
bool operator== ( const Self_t F) const
inline
bool operator!= ( const Self_t F) const
inline
Element& init ( Element x) const
inline
Montgomery< int32_t >::Element & init ( Element x,
const double  a 
) const
inline
Montgomery< int32_t >::Element & init ( Element x,
const int64_t  a 
) const
inline
Montgomery< int32_t >::Element & init ( Element x,
const uint64_t  a 
) const
inline
Montgomery< int32_t >::Element & init ( Element x,
const Integer a 
) const
inline
Element& init ( Element r,
const T &  a 
) const
inline
Element& assign ( Element x,
const Element y 
) const
inline
T& convert ( T &  r,
const Element a 
) const
inline
Element& reduce ( Element x,
const Element y 
) const
inline
Element& reduce ( Element x) const
inline
Montgomery< int32_t >::Element & mul ( Element r,
const Element a,
const Element b 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & div ( Element r,
const Element a,
const Element b 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & add ( Element r,
const Element a,
const Element b 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & sub ( Element r,
const Element a,
const Element b 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & neg ( Element r,
const Element a 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & inv ( Element r,
const Element a 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & mulin ( Element r,
const Element a 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & divin ( Element r,
const Element a 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & addin ( Element r,
const Element a 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & subin ( Element r,
const Element a 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & negin ( Element r) const
inlineoverridevirtual
Montgomery< int32_t >::Element & invin ( Element r) const
inlineoverridevirtual
Montgomery< int32_t >::Element & axpy ( Element r,
const Element a,
const Element x,
const Element y 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & axpyin ( Element r,
const Element a,
const Element x 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & axmy ( Element r,
const Element a,
const Element x,
const Element y 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & axmyin ( Element r,
const Element a,
const Element x 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & maxpy ( Element r,
const Element a,
const Element x,
const Element y 
) const
inlineoverridevirtual
Montgomery< int32_t >::Element & maxpyin ( Element r,
const Element a,
const Element x 
) const
inlineoverridevirtual
Element& random ( const Random &  g,
Element r 
) const
inline
Element& nonzerorandom ( const Random &  g,
Element a 
) const
inline
std::ostream & write ( std::ostream &  s) const
inline
std::istream & read ( std::istream &  s,
Element a 
) const
inline
std::ostream & write ( std::ostream &  s,
const Element a 
) const
inline
Montgomery< int32_t >::Element & redc ( Element r,
const Element  c 
) const
inlineprotected
Montgomery< int32_t >::Element redcal ( const Element  c) const
inlineprotected
Montgomery< int32_t >::Element redcsal ( const Element  c) const
inlineprotected
Montgomery< int32_t >::Element & redcin ( Element r) const
inlineprotected
Montgomery< int32_t >::Element & redcs ( Element r,
const Element  c 
) const
inlineprotected
Montgomery< int32_t >::Element & redcsin ( Element r) const
inlineprotected

Field Documentation

const Element zero = 0
const Element one
const Element mOne
Residu_t _p
protected
Residu_t _Bp
protected
Residu_t _B2p
protected
Residu_t _B3p
protected
Residu_t _nim
protected
double _dp
protected

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