#include <polynomial.h>
Collaboration diagram for libecc::polynomial< m, k, k1, k2 >:
Public Types | |
typedef Operator::bitsetExpression< m, false, false, Operator::bitsetXOR > | xor_type |
The type of add and subtract expressions of polynomials (ie, p1 + p2). | |
Public Member Functions | |
polynomial (void) | |
polynomial (bitset_digit_t coefficients) | |
polynomial (polynomial const &p) | |
polynomial (bitset< m > const &coefficients) | |
polynomial (std::string const &coefficients) | |
polynomial (xor_type const &expression) | |
polynomial & | operator= (polynomial const &p) |
polynomial & | operator= (bitset< m > const &coefficients) |
polynomial & | operator= (xor_type const &expression) |
polynomial (polynomial const &b, polynomial const &c) | |
polynomial & | square (bitset_digit_t *tmpbuf) const |
bool | sqrt (void) |
polynomial & | operator+= (polynomial const &p) |
polynomial & | operator-= (polynomial const &p) |
polynomial & | operator *= (polynomial const &p) |
polynomial & | operator *= (typename polynomial< m, k, k1, k2 >::xor_type const &expr) |
polynomial & | operator/= (polynomial const &p) |
polynomial & | operator/= (typename polynomial< m, k, k1, k2 >::xor_type const &expr) |
int | trace (void) const |
bitset< m > const & | get_bitset (void) const |
bitset< m > & | get_bitset (void) |
Static Public Member Functions | |
polynomial const & | unity (void) |
bitset< m > const & | normal (void) |
Static Public Attributes | |
unsigned int const | square_digits |
Friends | |
xor_type | operator+ (polynomial const &p1, polynomial const &p2) |
xor_type | operator- (polynomial const &p1, polynomial const &p2) |
polynomial | operator * (polynomial const &p1, polynomial const &p2) |
bool | operator * (polynomial< m, k, k1, k2 >::xor_type const &expr, polynomial< m, k, k1, k2 > const &p2) |
bool | operator * (polynomial< m, k, k1, k2 > const &p1, polynomial< m, k, k1, k2 >::xor_type const &expr) |
polynomial | operator/ (polynomial const &p1, polynomial const &p2) |
bool | operator/ (polynomial< m, k, k1, k2 >::xor_type const &expr, polynomial< m, k, k1, k2 > const &p2) |
bool | operator/ (polynomial< m, k, k1, k2 > const &p1, polynomial< m, k, k1, k2 >::xor_type const &expr) |
bool | operator== (polynomial const &p1, polynomial const &p2) |
bool | operator== (polynomial< m, k, k1, k2 >::xor_type const &expr, polynomial< m, k, k1, k2 > const &p2) |
bool | operator== (polynomial< m, k, k1, k2 > const &p1, polynomial< m, k, k1, k2 >::xor_type const &expr) |
bool | operator!= (polynomial const &p1, polynomial const &p2) |
bool | operator!= (polynomial< m, k, k1, k2 >::xor_type const &expr, polynomial< m, k, k1, k2 > const &p2) |
bool | operator!= (polynomial< m, k, k1, k2 > const &p1, polynomial< m, k, k1, k2 >::xor_type const &expr) |
std::ostream & | operator<< (std::ostream &os, polynomial const &p) |
std::ostream & | operator<< (std::ostream &os, polynomial< m, k, k1, k2 >::xor_type const &expr) |
This class represents a polynomial with binairy coefficients (0 or 1) for a finite field with the fixed reduction polynomial.
The reduction polynomial is either a trinomial (when k1 is 0), tm+tk+1>, or a pentanomial, tm+tk+tk1+tk2+1>.
|
The type of add and subtract expressions of polynomials (ie, p1 + p2).
|
|
Construct an uninitialized field element. |
|
Construct a polynomial of a low degree. |
|
Copy constructor. |
|
Construct a polynomial with binairy coefficients given by the bitset coefficients. |
|
Construct a polynomial with binairy coefficients given by the hexadecimal value in the string coefficients. |
|
Construct a polynomial that is the sum of two other polynomials. This constructor is for implicit conversion in code like
Here this constructor is used to convert the xor_type (which is Operator::bitsetExpression<m, false, false, Operator::bitsetXOR>) returned by Note that because polynomial is a template, automatic conversion does unfortunately not happen. Code like
needs an explicit Also note that code like
where the + may be a minus, and the * can be any binary operator, will not compile at all: it is not possible to determine the return type (a polynomial) from a call to operator*(xor_type, xor_type). Instead you have to split up the line or provide an explicit cast for one of the operands:
|
|
Construct a polynomial x that is the solution to the quadratic equation x2 + b |
|
Return the underlaying bitset representing the coefficients. |
|
Return the underlaying bitset representing the coefficients. |
|
Returns the normal to the hyperplane existing of all elements with trace 0. The returned value is a reference to a constant static. This function is extremely fast.
|
|
Multiply this polynomial by the sum of two polynomials. For example,
|
|
Multiply this polynomial with polynomial p. |
|
Add polynomial p to this polynomial. |
|
Subtract polynomial p from this polynomial. Has the same effect as adding it. |
|
Devide this polynomial by the sum of two polynomials. For example,
|
|
Devide this polynomial by polynomial p. |
|
Add two polynomials and assign the result to this polynomial. This operator is used when doing |
|
Assignment operator, set the coefficients of this polynomial equal to coefficients. |
|
Assignment operator, set this polynomial equal to p. |
|
Calculate the square root of this polynomial. Returns true if a solution was found. If m, k, k1 and k2 represent an irreducible polynomial (as it should for this to be a field) then a solution will always be found and this function will always return true. |
|
Calculate the square of this polynomial. The result is written into tmpbuf which is returned, casted to a polynomial. Usage:
|
|
Returns the trace of this object. The trace is either 0 or 1. If the trace is 0 then there will exist a polynomial y such that this object is equal to y + y2. Otherwise no such polynomial exists. This function is extremely fast (a few assembly instructions).
|
|
Returns the multiplicative unity for the field (1). |
|
Multiply polynomial p1 with the result of expr (the result of an addition or subtraction).
For example: |
|
Multiply polynomial p2 with the result of expr (the result of an addition or subtraction).
For example: |
|
Multiply polynomial p1 with polynomial p2. |
|
Compare polynomial p1 with the result of expr (the result of an addition or subtraction).
For example:
|
|
Compare polynomial p2 with the result of expr (the result of an addition or subtraction).
For example:
|
|
Compare two polynomials. Returns |
|
Prepare the addition of two polynomials. Returns a dummy object with two pointers to the polynomials to be added. The addition does not take place until the final destination polynomial is known as well. Note that it is not possible to write:
There is a complicated reason for that. Instead, write
For example, when adding a whole series of polynomials you'd do:
Basically, it is not supported to add or substract a polynomial to or from a temporary that represents an addition or subtraction by itself. |
|
Prepare the subtraction of two polynomials. Returns a dummy object with two pointers to the polynomials to be subtracted. The subtraction does not take place until the final destination polynomial is known as well.
|
|
Devide polynomial p1 by the result of expr (the result of an addition or subtraction).
For example: |
|
Devide polynomial the result of expr, the result of an addition or subtraction, by polynomial p2.
For example: |
|
Devide polynomial p1 by polynomial p2. |
|
Write the binary coefficients of the result of expr (the result of an addition or subtraction) to os.
|
|
Write the binary coefficients of the polynomial p to os.
For example, an output string |
|
Compare polynomial p1 with the result of expr (the result of an addition or subtraction).
For example:
|
|
Compare polynomial p2 with the result of expr (the result of an addition or subtraction).
For example:
|
|
Compare two polynomials. Returns |
|
Number of digits needed for temporary buffer used to calculate a square. |