#include <poweroftwomodular.h>
element | Element type, e.g. long or integer |
Intermediate | Type to use for intermediate computations. This should be a data type that can support integers twice the length of the maximal modulus used |
Public Types | |
typedef Ints | Element |
Public Methods | |
Object Management | |
PowerOfTwoModular (void) | |
integer & | convert (integer &x, const Element &y) const |
Element & | init (Element &x, const Ints &y=0) const |
Element & | assign (Element &x, const Element &y) const |
integer & | cardinality (integer &c) const |
integer & | characteristic (integer &c) const |
int & | poweroftwo (int &c) |
Arithmetic Operations | |
x <- y op z; x <- op y These operations require all elements, including x, to be initialized before the operation is called. Uninitialized field base elements will give undefined results. | |
Object Management bool | areEqual (const Element &x, const Element &y) const |
bool | isZero (const Element &x) const |
bool | isOne (const Element &x) const |
bool | isUnit (const Element &x) const |
bool | isZeroDivisor (const Element &x) const |
Element & | gcd_poweroftwo (Element &x, const Element &y) const |
bool | doesdivide (const Element &x, const Element &y) const |
int | poweroftwoinx (const Element &x) const |
Element & | bezout (const Element &x, const Element &y, Element &gcd, Element &u, Element &v) const |
Input/Output Operations | |
Arithmetic Operations std::ostream & | write (std::ostream &os) const |
std::istream & | read (std::istream &is) |
std::ostream & | write (std::ostream &os, const Element &x) const |
std::istream & | read (std::istream &is, Element &x) const |
Arithmetic Operations | |
x <- y op z; x <- op y These operations require all elements, including x, to be initialized before the operation is called. Uninitialized field base elements will give undefined results. | |
Element & | add (Element &x, const Element &y, const Element &z) const |
Element & | sub (Element &x, const Element &y, const Element &z) const |
Element & | mul (Element &x, const Element &y, const Element &z) const |
Element & | div (Element &x, const Element &y, const Element &z) const |
Element & | neg (Element &x, const Element &y) const |
Element & | inv (Element &x, const Element &y) const |
Element & | inv2 (Element &x, const Element &y) const |
Element & | axpy (Element &r, const Element &a, const Element &x, const Element &y) const |
Inplace Arithmetic Operations | |
x <- x op y; x <- op x | |
Arithmetic Operations Element & | addin (Element &x, const Element &y) const |
Element & | subin (Element &x, const Element &y) const |
Element & | mulin (Element &x, const Element &y) const |
Element & | divin (Element &x, const Element &y) const |
Element & | negin (Element &x) const |
Element & | invin (Element &x) const |
Element & | axpyin (Element &r, const Element &a, const Element &x) const |
Protected Attributes | |
Element | _poweroftwo |
Private (non-static) element for modulus. |
|
Element type |
|
Default constructor. |
|
Addition. x = y + z This function assumes all the field base elements have already been constructed and initialized.
|
|
Inplace Addition. x += y This function assumes both field base elements have already been constructed and initialized.
|
|
Equality of two elements. This function assumes both field base elements have already been constructed and initialized.
|
|
Assignment of one field base element to another. This function assumes both field base elements have already been constructed and initialized.
|
|
Natural AXPY. r = a * x + y This function assumes all field elements have already been constructed and initialized.
|
|
Inplace AXPY. r += a * x This function assumes all field elements have already been constructed and initialized. Purely virtual
|
|
|
|
Cardinality. Return integer representing cardinality of the domain. Returns a non-negative integer for all domains with finite cardinality, and returns -1 to signify a domain of infinite cardinality.
|
|
Characteristic. Return integer representing characteristic of the domain. Returns a positive integer to all domains with finite characteristic, and returns 0 to signify a domain of infinite characteristic.
|
|
Conversion of field base element to a template class T. This function assumes the output field base element x has already been constructed, but that it is not already initialized.
|
|
Division. x = y / z This function assumes all the field base elements have already been constructed and initialized. This fonction assumes that x divides y. That can be verified by using doesdivide(x,y)
|
|
Inplace Division. x /= y This function assumes both field base elements have already been constructed and initialized.
|
|
Does x divide y |
|
Gcd with 2^_poweroftwo * Valid for Ints up to 32 bits * Specialization is required for bigger Ints |
|
Initialization of field base element from an integer. Behaves like C++ allocator construct. This function assumes the output field base element x has already been constructed, but that it is not already initialized. This is not a specialization of the template function because such a specialization is not allowed inside the class declaration.
|
|
Multiplicative Inverse. x = 1 / y This function assumes both field base elements have already been constructed and initialized. This function assumes that y is odd (ie 1/y exists)
|
|
Multiplicative Inverse 2. x = 1 / y This function assumes both field base elements have already been constructed and initialized.
|
|
Inplace Multiplicative Inverse. x = 1 / x This function assumes the field base elementhas already been constructed and initialized.
|
|
One equality. Test if field base element is equal to one. This function assumes the field base element has already been constructed and initialized.
|
|
|
|
Zero equality. Test if field base element is equal to zero. This function assumes the field base element has already been constructed and initialized.
|
|
|
|
Multiplication. x = y * z This function assumes all the field base elements have already been constructed and initialized.
|
|
Inplace Multiplication. x *= y This function assumes both field base elements have already been constructed and initialized.
|
|
Additive Inverse (Negation). x = - y This function assumes both field base elements have already been constructed and initialized.
|
|
Inplace Additive Inverse (Inplace Negation). x = - x This function assumes the field base element has already been constructed and initialized.
|
|
poweroftwo |
|
Power of two in x Input Element x = 2^n*y where y is odd Output n |
|
Read field base element. This function assumes the field base element has already been constructed and initialized.
|
|
Read field.
|
|
Subtraction. x = y - z This function assumes all the field base elements have already been constructed and initialized.
|
|
Inplace Subtraction. x -= y This function assumes both field base elements have already been constructed and initialized.
|
|
Print field base element. This function assumes the field base element has already been constructed and initialized.
|
|
Print field.
|
|
Private (non-static) element for modulus.
|