linbox
|
Ring of elements modulo some power of two. More...
#include <poweroftwomodular.h>
Data Structures | |
struct | RandIter |
Random iterator generator type. More... | |
Public Types | |
typedef Ints | Element |
Element type. | |
Public Member Functions | |
Object Management | |
PowerOfTwoModular (void) | |
Default constructor. | |
integer & | convert (integer &x, const Element &y) const |
Conversion of field base element to a template class T. | |
Element & | init (Element &x, const Ints &y=0) const |
Initialization of field base element from an integer. | |
Element & | assign (Element &x, const Element &y) const |
Assignment of one field base element to another. | |
integer & | cardinality (integer &c) const |
Cardinality. | |
integer & | characteristic (integer &c) const |
Characteristic. | |
int & | poweroftwo (int &c) |
poweroftwo | |
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. | |
bool | areEqual (const Element &x, const Element &y) const |
Equality of two elements. | |
bool | isZero (const Element &x) const |
Zero equality. | |
bool | isOne (const Element &x) const |
One equality. | |
bool | isUnit (const Element &x) const |
isUnit. | |
bool | isZeroDivisor (const Element &x) const |
isZeroDivisor. | |
Element & | gcd_poweroftwo (Element &x, const Element &y) const |
Gcd with 2^_poweroftwo . | |
bool | doesdivide (const Element &x, const Element &y) const |
Does x divide y. | |
int | poweroftwoinx (const Element &x) const |
Power of two in x Input Element x = 2^n*y where y is odd Output n. | |
Element & | bezout (const Element &x, const Element &y, Element &gcd, Element &u, Element &v) const |
bezout. | |
Element & | add (Element &x, const Element &y, const Element &z) const |
Addition. | |
Element & | sub (Element &x, const Element &y, const Element &z) const |
Subtraction. | |
Element & | mul (Element &x, const Element &y, const Element &z) const |
Multiplication. | |
Element & | div (Element &x, const Element &y, const Element &z) const |
Division. | |
Element & | neg (Element &x, const Element &y) const |
Additive Inverse (Negation). | |
Element & | inv (Element &x, const Element &y) const |
Multiplicative Inverse. | |
Element & | inv2 (Element &x, const Element &y) const |
Multiplicative Inverse 2. | |
Element & | axpy (Element &r, const Element &a, const Element &x, const Element &y) const |
Natural AXPY. | |
Input/Output Operations | |
std::ostream & | write (std::ostream &os) const |
Print field. | |
std::istream & | read (std::istream &is) |
Read field. | |
std::ostream & | write (std::ostream &os, const Element &x) const |
Print field base element. | |
std::istream & | read (std::istream &is, Element &x) const |
Read field base element. | |
Inplace Arithmetic Operations | |
x <- x op y; x <- op x | |
Element & | addin (Element &x, const Element &y) const |
Inplace Addition. | |
Element & | subin (Element &x, const Element &y) const |
Inplace Subtraction. | |
Element & | mulin (Element &x, const Element &y) const |
Inplace Multiplication. | |
Element & | divin (Element &x, const Element &y) const |
Inplace Division. | |
Element & | negin (Element &x) const |
Inplace Additive Inverse (Inplace Negation). | |
Element & | invin (Element &x) const |
Inplace Multiplicative Inverse. | |
Element & | axpyin (Element &r, const Element &a, const Element &x) const |
Inplace AXPY. | |
Protected Attributes | |
Element | _poweroftwo |
Private (non-static) element for modulus. |
Ring of elements modulo some power of two.
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 |
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.
x | template class T to contain output (reference returned). |
y | constant field base element. |
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.
x | field base element to contain output (reference returned). |
y | integer. |
Assignment of one field base element to another.
This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
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.
Equality of two elements.
This function assumes both field base elements have already been constructed and initialized.
x | field base element |
y | field base element |
bool isZero | ( | const Element & | x | ) | const [inline] |
Zero equality.
Test if field base element is equal to zero. This function assumes the field base element has already been constructed and initialized.
x | field base element. |
bool isOne | ( | const Element & | x | ) | const [inline] |
One equality.
Test if field base element is equal to one. This function assumes the field base element has already been constructed and initialized.
x | field base element. |
bool isUnit | ( | const Element & | x | ) | const [inline] |
isUnit.
x |
bool isZeroDivisor | ( | const Element & | x | ) | const [inline] |
isZeroDivisor.
x |
Gcd with 2^_poweroftwo .
Valid for Ints up to 32 bits Specialization is required for bigger Ints
x | |
y |
Element& bezout | ( | const Element & | x, |
const Element & | y, | ||
Element & | gcd, | ||
Element & | u, | ||
Element & | v | ||
) | const [inline] |
bezout.
x,y | |
gcd | |
u,v |
std::ostream& write | ( | std::ostream & | os | ) | const [inline] |
Print field.
os | output stream to which field is written. |
std::istream& read | ( | std::istream & | is | ) | [inline] |
Read field.
is | input stream from which field is read. |
std::ostream& write | ( | std::ostream & | os, |
const Element & | x | ||
) | const [inline] |
Print field base element.
This function assumes the field base element has already been constructed and initialized.
os | output stream to which field base element is written. |
x | field base element. |
std::istream& read | ( | std::istream & | is, |
Element & | x | ||
) | const [inline] |
Read field base element.
This function assumes the field base element has already been constructed and initialized.
is | input stream from which field base element is read. |
x | field base element. |
Addition.
x = y + z This function assumes all the field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
z | field base element. |
Subtraction.
x = y - z This function assumes all the field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
z | field base element. |
Multiplication.
x = y * z This function assumes all the field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
z | field base element. |
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)
x | field base element (reference returned). |
y | field base element. |
z | field base element. |
Additive Inverse (Negation).
x = - y This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
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)
x | field base element (reference returned). |
y | field base element. |
Multiplicative Inverse 2.
x = 1 / y This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
Element& axpy | ( | Element & | r, |
const Element & | a, | ||
const Element & | x, | ||
const Element & | y | ||
) | const [inline] |
Natural AXPY.
r = a * x + y This function assumes all field elements have already been constructed and initialized.
r | field element (reference returned). |
a | field element. |
x | field element. |
y | field element. |
Inplace Addition.
x += y This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
Inplace Subtraction.
x -= y This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
Inplace Multiplication.
x *= y This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
Inplace Division.
x /= y This function assumes both field base elements have already been constructed and initialized.
x | field base element (reference returned). |
y | field base element. |
Inplace Additive Inverse (Inplace Negation).
x = - x This function assumes the field base element has already been constructed and initialized.
x | field base element (reference returned). |
Inplace Multiplicative Inverse.
x = 1 / x This function assumes the field base elementhas already been constructed and initialized.
x | field base element (reference returned). |
Inplace AXPY.
r += a * x This function assumes all field elements have already been constructed and initialized. Purely virtual
r | field element (reference returned). |
a | field element. |
x | field element. |