The ChainCon Software (Release 0.03)
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
tZp< intType > Class Template Reference

An element of the ring Z_p, where p is globally set. More...

#include <ringzp.h>

Public Member Functions

 tZp ()
 Default constructor of a ring element. More...
 
 tZp (const intType &n)
 Constructor from an integer number (to be used mainly for 0 or 1). More...
 
 operator intType () const
 Conversion to an integer. More...
 
intType delta () const
 The delta function. More...
 
tZp< intType > & negate ()
 Negates the ring element. More...
 
tZp< intType > & invert ()
 Inverts the ring element. Assumes that 'p' is a prime number. More...
 
tZp< intType > & operator+= (const tZp< intType > &another)
 Adds another ring element. More...
 
tZp< intType > & operator*= (const tZp< intType > &another)
 Multiplies by another ring element. More...
 
void swap (tZp< intType > &another)
 Swaps the internal data with another ring element. More...
 

Static Public Member Functions

static void setp (const intType &p)
 Sets the number p for the ring. More...
 
static const intType & getp ()
 Gets the currently set number p for the ring. More...
 
static std::string ringsymbol ()
 Returns the symbol of the ring. More...
 

Private Attributes

intType _n
 The number corresponding to the ring element. More...
 

Static Private Attributes

static intType _p = 2
 The number that defines the ring. More...
 

Friends

bool divide (const tZp< intType > &a, const tZp< intType > &b, tZp< intType > &quotient, tZp< intType > &remainder)
 Performs the division with remainder in the ring. More...
 

Detailed Description

template<class intType>
class tZp< intType >

An element of the ring Z_p, where p is globally set.

Set p=0 for the ring Z (note the limited range of valid values). In this implementation, p must be set smaller than the square root of the largest positive number that can be encoded in the underlying integer type.

Definition at line 179 of file ringzp.h.

Constructor & Destructor Documentation

◆ tZp() [1/2]

template<class intType >
tZp< intType >::tZp ( )
inline

Default constructor of a ring element.

Note: The default copy constructor, destructor, and assignment operators are fine.

Definition at line 282 of file ringzp.h.

◆ tZp() [2/2]

template<class intType >
tZp< intType >::tZp ( const intType &  n)
inlineexplicit

Constructor from an integer number (to be used mainly for 0 or 1).

Definition at line 288 of file ringzp.h.

Member Function Documentation

◆ delta()

template<class intType >
intType tZp< intType >::delta ( void  ) const
inline

The delta function.

Definition at line 325 of file ringzp.h.

◆ getp()

template<class intType >
const intType & tZp< intType >::getp ( )
inlinestatic

Gets the currently set number p for the ring.

Definition at line 435 of file ringzp.h.

◆ invert()

template<class intType >
tZp< intType > & tZp< intType >::invert ( )
inline

Inverts the ring element. Assumes that 'p' is a prime number.

Definition at line 347 of file ringzp.h.

References invertModuloSmallP().

Referenced by divide().

◆ negate()

template<class intType >
tZp< intType > & tZp< intType >::negate ( )
inline

Negates the ring element.

Definition at line 334 of file ringzp.h.

◆ operator intType()

template<class intType >
tZp< intType >::operator intType ( ) const
inline

Conversion to an integer.

Note that in some rings this conversion may not be valid.

Definition at line 319 of file ringzp.h.

◆ operator*=()

template<class intType >
tZp< intType > & tZp< intType >::operator*= ( const tZp< intType > &  another)
inline

Multiplies by another ring element.

Definition at line 369 of file ringzp.h.

◆ operator+=()

template<class intType >
tZp< intType > & tZp< intType >::operator+= ( const tZp< intType > &  another)
inline

Adds another ring element.

Definition at line 360 of file ringzp.h.

◆ ringsymbol()

template<class intType >
std::string tZp< intType >::ringsymbol ( )
inlinestatic

Returns the symbol of the ring.

Definition at line 441 of file ringzp.h.

◆ setp()

template<class intType >
void tZp< intType >::setp ( const intType &  p)
inlinestatic

Sets the number p for the ring.

Definition at line 389 of file ringzp.h.

References numberIsPrime().

◆ swap()

template<class intType >
void tZp< intType >::swap ( tZp< intType > &  another)
inline

Swaps the internal data with another ring element.

Definition at line 378 of file ringzp.h.

Friends And Related Function Documentation

◆ divide

template<class intType>
bool divide ( const tZp< intType > &  a,
const tZp< intType > &  b,
tZp< intType > &  quotient,
tZp< intType > &  remainder 
)
friend

Performs the division with remainder in the ring.

Returns true if the remainer is zero, false otherwise.

Definition at line 182 of file ringzp.h.

Member Data Documentation

◆ _n

template<class intType>
intType tZp< intType >::_n
private

The number corresponding to the ring element.

Definition at line 267 of file ringzp.h.

Referenced by divide().

◆ _p

template<class intType>
intType tZp< intType >::_p = 2
staticprivate

The number that defines the ring.

Definition at line 270 of file ringzp.h.


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