FAAST
0.2.1
|
An element of a finite field. More...
Public Member Functions | |
Constructors | |
FieldElement () throw () | |
Construct the special 0 element. | |
Properties | |
const Field< T > & | parent () const throw (UndefinedFieldException) |
The parent field. | |
Copy | |
You can copy elements using assignment. | |
FieldElement (const FieldElement< T > &e) throw () | |
FieldElement< T > & | operator= (const FieldElement< T > &e) throw () |
FieldElement< T > & | operator= (const BigInt &i) throw (UndefinedFieldException) |
Assign a scalar value to this element. | |
Binary operators | |
All binary operators throw a NotInSameFieldException if neither of this two conditions is satisfied:
| |
FieldElement< T > | operator+ (const FieldElement< T > &e) const throw (NotInSameFieldException) |
FieldElement< T > | operator- (const FieldElement< T > &e) const throw (NotInSameFieldException) |
FieldElement< T > | operator* (const FieldElement< T > &e) const throw (NotInSameFieldException) |
FieldElement< T > | operator/ (const FieldElement< T > &e) const throw (NotInSameFieldException, DivisionByZeroException) |
void | operator+= (const FieldElement< T > &) throw (NotInSameFieldException) |
void | operator-= (const FieldElement< T > &) throw (NotInSameFieldException) |
void | operator*= (const FieldElement< T > &) throw (NotInSameFieldException) |
void | operator/= (const FieldElement< T > &) throw (NotInSameFieldException, DivisionByZeroException) |
void | sum (const FieldElement< T > &a, const FieldElement< T > &b) throw (NotInSameFieldException) |
Stores a + b in this element. | |
void | difference (const FieldElement< T > &a, const FieldElement< T > &b) throw (NotInSameFieldException) |
Stores a - b in this element. | |
void | product (const FieldElement< T > &a, const FieldElement< T > &b) throw (NotInSameFieldException) |
Stores a * b in this element. | |
void | division (const FieldElement< T > &a, const FieldElement< T > &b) throw (NotInSameFieldException, DivisionByZeroException) |
Stores a / b in this element. | |
Unary operators | |
FieldElement< T > | operator- () const throw () |
Additive inverse. | |
FieldElement< T > | inv () const throw (DivisionByZeroException) |
Multiplicative inverse. | |
FieldElement< T > | operator^ (const ZZ &i) const throw () |
Power. | |
FieldElement< T > | operator^ (const long i) const throw () |
Power. | |
FieldElement< T > | frobenius () const throw () |
p-th power (frobenius morphism). | |
FieldElement< T > | frobenius (const long n) const throw () |
pn-th power (iterated frobenius morphism). | |
FieldElement< T > | trace (const Field< T > &F) const throw (NotASubFieldException) |
Trace over the field F. | |
FieldElement< T > | trace () const throw () |
Trace over Fp | |
FieldElement< T > | pseudotrace (unsigned long n) const throw () |
n-th pseudotrace | |
Self-incrementing Unary operations | |
These operators store the result of the operation into the element itself. | |
void | negate () throw () |
Flip the sign of this element. | |
void | self_inv () throw (DivisionByZeroException) |
Invert this element. | |
void | operator^= (const ZZ &) throw () |
Power. | |
void | operator^= (const long) throw () |
Power. | |
void | self_frobenius () throw () |
p-th power (frobenius morphism). | |
void | self_frobenius (long) throw () |
pn-th power (iterated frobenius morphism). | |
void | self_trace (const Field< T > &F) throw (NotASubFieldException) |
Trace over the field F. | |
void | self_trace () throw () |
Trace over Fp | |
void | self_pseudotrace (unsigned long) throw () |
n-th pseudotrace | |
Minimal polynomials and Evaluation | |
FieldPolynomial< T > | minimalPolynomial () const throw () |
The minimal polynomial over Fp. | |
FieldPolynomial< T > | minimalPolynomial (const Field< T > &F) const throw (NotASubFieldException, NotSupportedException) |
The minimal polynomial over the field F. | |
void | minimalPolynomials (const Field< T > &F, vector< FieldPolynomial< T > > &res) const throw (NotASubFieldException, NotSupportedException) |
All the minimal polynomials up to the field F. | |
FieldPolynomial< T > | affineMinimalPolynomial (const Field< T > &F, const FieldElement< T > &a, vector< FieldPolynomial< T > > &minpols) const throw (NotASubFieldException, NoSuchPolynomialException, NotSupportedException, BadParametersException) |
The a-affine minimal polynomial over the field F. | |
FieldPolynomial< T > | affineMinimalPolynomial (const Field< T > &F, const FieldElement< T > &a) const throw (NotASubFieldException, NoSuchPolynomialException, NotSupportedException) |
The a-affine minimal polynomial over the field F. | |
FieldElement< T > | evaluate (const FieldPolynomial< T > &P, vector< FieldPolynomial< T > > &minpols) const throw (IllegalCoercionException, BadParametersException) |
The evaulation of P at this element. | |
FieldElement< T > | evaluate (const FieldPolynomial< T > &P) const throw (IllegalCoercionException) |
The evaulation of P at this element. | |
Coercion of elements | |
Every element has an unique parent field, but it may belong to some subfield of its parent field or you may want to change its parent field to an overfield of its actual one. Coercion does exactly this. When the coericion is impossible because either there is no known embedding between the two fields or because the element does not belong to the new field, an IllegalCoercionException is thrown. | |
FieldElement< T > | toScalar () const throw (IllegalCoercionException) |
Coerce to a scalar. | |
FieldElement< T > | operator>> (const Field< T > &F) const throw (IllegalCoercionException) |
Coerce to the field F. | |
void | operator>>= (const Field< T > &) throw (IllegalCoercionException) |
Coerce to the field F and store the result in this element. | |
bool | isCoercible (const Field< T > &) const throw () |
Test if this element is coercible to F. | |
Predicates | |
bool | operator== (const FieldElement< T > &) const throw (NotInSameFieldException) |
Equality. | |
bool | operator== (const BigInt &) const throw () |
Equality. | |
bool | operator!= (const FieldElement< T > &e) const throw (NotInSameFieldException) |
Inequality. | |
bool | operator!= (const BigInt &i) const throw () |
Inequality. | |
bool | isZero () const throw () |
Test to zero. | |
bool | isOne () const throw () |
Test to one. | |
bool | isScalar () const throw () |
Test if this element belongs to Fp. | |
Access to the Infrastructure | |
These methods let you access the internal
| |
void | toInfrastructure (GFp &e) const throw (IllegalCoercionException) |
Get the representation of elements whose parent field is Fp. | |
void | toInfrastructure (GFpE &e) const throw (IllegalCoercionException) |
Get the representation of elements whose parent field is an extension field. | |
Printing | |
ostream & | print (ostream &o) const |
Print this element to o. | |
ostream & | print (ostream &o, const string &var) const |
Print this element to o as a polynomial over Fp in the variable var. | |
ostream & | print (ostream &o, const vector< string > &vars) const |
Print this element to o as a multivariate polynomial over Fp. |
Related Functions | |
(Note that these are not member functions.) | |
void | pushDown (const FieldElement< T > &e, vector< FieldElement< T > > &v) throw (NoSubFieldException) |
Convert e from the internal (univariate) representation to the bivariate representation over the immediate subfield in the primitive tower (the stem). | |
void | liftUp (const vector< FieldElement< T > > &v, FieldElement< T > &e) throw (NotInSameFieldException, NoOverFieldException) |
Convert v from the bivariate representation over the immediate subfield in the primitive tower (the stem) to the internal (univariate) representation. | |
template<class T > | |
ostream & | operator<< (ostream &o, const FieldElement< T > &e) |
Print e to o. |
Local types | |
Local types defined in this class. They are aliases to simplify the access to the Infrastructure T and its subtypes.
| |
typedef T | Infrastructure |
typedef T::GFp | GFp |
typedef T::MatGFp | MatGFp |
typedef T::GFpX | GFpX |
typedef T::GFpE | GFpE |
typedef T::GFpEX | GFpEX |
typedef T::BigInt | BigInt |
typedef T::Context | Context |
An element of a finite field.
Objects of this class represent elements of a finite field, as represented by the class Field. With the exception of the zero element created by the default constructor, any element has an unique parent field and binary operations can combine two elements only in one of the following two cases:
Elements created through the default constructor, as for example
have a special status as they don't belong to any specific field: their default value is 0 and they can be combined with any other element. The result of a binary operation involving such a special element is one of the following:
Elements are internally represented as univariate polynomials with coefficients in Fp modulo an irreducible polynomial as described in [DFS '09, Section 3]. The way the arithmetics of the field are actually implemented is given by the template parameter T that must be one of the Infrastructures. Note that changing the Infrastructure may sensibly change the speed of your code.
T | An Infrastructure. It specfies which NTL types will carry out the arithmetic operations. |
|
inline |
Construct the special 0 element.
The special 0 element does not belong to any field, yet it can be added, multiplied, etc. to any other FieldElement. See the introduction for more details. If you want to construct the 0 element of a specific field, use Field::zero() instead.
FieldPolynomial< T > FAAST::FieldElement< T >::affineMinimalPolynomial | ( | const Field< T > & | F, |
const FieldElement< T > & | a, | ||
vector< FieldPolynomial< T > > & | minpols | ||
) | const throw (NotASubFieldException, NoSuchPolynomialException, NotSupportedException, BadParametersException) |
The a-affine minimal polynomial over the field F.
This is an optimized version of affineMinimalPolynomial(const Field<T>&, const FieldElement<T>&) const that lets you pass an additional parameter minpols containing some precomputed quantities.
The optional parameter minpols must contain either the result of minimalPolynomials(F,minpols)
, or must be an empty vector, in which case it is filled with the result of minimalPolynomials(F,minpols)
. In any other case either a BadParametersException is thrown or the behaviour is undefined.
This method should be preferred when you care about efficiency and you do many calls to affineMinimalPolynomial() and evaluate().
[in] | F | A subfield of the parent field. |
[in] | a | An element contained in the field F[x], where x is this element. |
[in,out] | minpols | If this vector is empty, then minimalPolynomials(F,minpols) is called, otherwise it is assumed to contain the data computed by the former method call. |
NotASubFieldException | If the parent field is not an extension field of F. |
NotSupportedException | If F is a prime field not being the base field of an Artin-Schreier tower. |
NoSuchPolynomialException | If no such polynomial exists. Equivalently, if a is not an element of F[x] where x is this element. |
BadParametersException | If minpols is not empty or does not contain the result of minimalPolynomials(F,minpols) . |
|
inline |
The a-affine minimal polynomial over the field F.
That is the minimum degree polynomial P of F[X] such that
where x is this element. Observe that this is the same as computing the interpolation polynomial such that
where is the frobenius morphism fixing F. This implements a yet unpublished algorithm, it only works when F is a field of an Artin-Schreier tower as constructed in [DFS '09, Section 3].
[in] | F | A subfield of the parent field. |
[in] | a | An element contained in the field F[x], where x is this element. |
NotASubFieldException | If the parent field is not an extension field of F. |
NotSupportedException | If F is a prime field not being the base field of an Artin-Schreier tower. |
NoSuchPolynomialException | If no such polynomial exists. Equivalently, if a is not an element of the field F[x], where x is this element. minimalPolynomials(F,minpols) . |
FieldElement< T > FAAST::FieldElement< T >::evaluate | ( | const FieldPolynomial< T > & | P, |
vector< FieldPolynomial< T > > & | minpols | ||
) | const throw (IllegalCoercionException, BadParametersException) |
The evaulation of P at this element.
This is an optimized version of evaluate(const FieldPolynomial<T>&) const that lets you pass an additional parameter minpols containing some precomputed quantities.
The optional parameter minpols must contain either the result of minimalPolynomials(F,minpols)
, or must be an empty vector, in which case it is filled with the result of minimalPolynomials(F,minpols)
. In any other case either a BadParametersException is thrown or the behaviour is undefined.
This method should be preferred when you care about efficiency and you do many calls to affineMinimalPolynomial() and evaluate().
[in] | P | A polynomial with coefficients in a subfield or overfield of the parent field. |
[in,out] | minpols | If this vector is empty, then minimalPolynomials(F,minpols) is called, otherwise it is assumed to contain the data computed by the former method call. |
IllegalCoercionException | If this element cannot be coerced to the coefficient field of P nor can P be coerced to the parent field. |
BadParametersException | If minpols is not empty or does not contain the result of minimalPolynomials(F,minpols) . |
P.evaluate(*this, minpols)
.
|
inline |
The evaulation of P at this element.
This implements a yet unpublished algorithm for Artin-Schreier towers constructed as in [DFS '09, Section 3]. It uses Horner evaluation scheme for all the other cases.
The optional parameter minpols must contain either the result of this.minimalPolynomials(P.parent,v), or must be an empty vector, in which case it is filled with the result of minimalPolynomials(P.parent,v).
[in] | P | A polynomial with coefficients in a subfield or overfield of the parent field. |
IllegalCoercionException | If this element cannot be coerced to the coefficient field of P nor can P be coerced to the parent field. |
P.evaluate(*this)
.
|
inline |
pn-th power (iterated frobenius morphism).
This method is a generalization of the algorithm IterFrobenius
of [DFS '09, Section 5].
bool FAAST::FieldElement< T >::isScalar | ( | ) | const throw () |
Test if this element belongs to Fp.
|
inline |
The minimal polynomial over the field F.
This method implements a yet unpublished algorithm to compute minimal polynomials in Artin-Schreier towers. It only works when F is a field of an Artin-Schreier tower as constructed in [DFS '09, Section 3].
[in] | F | A subfield of the parent field of this element. |
NotASubFieldException | If the parent field is not an extension field of F. |
NotSupportedException | If F is a prime field not being the base field of an Artin-Schreier tower. Use minimalPolynomial() instead. |
void FAAST::FieldElement< T >::minimalPolynomials | ( | const Field< T > & | F, |
vector< FieldPolynomial< T > > & | res | ||
) | const throw (NotASubFieldException, NotSupportedException) |
All the minimal polynomials up to the field F.
The result is the same as doing
up to minimalPolynomial
(parent()). The computation is more efficient, though.
[in] | F | A subfield of the parent field field. |
[out] | res | The vector is filled with the minimal polynomials of this element over the intermediate extension fields of F. All previous data are discarded. |
NotASubFieldException | If the parent field is not an extension field of F. |
NotSupportedException | If F is a prime field not being the base field of an Artin-Schreier tower. Use minimalPolynomial() instead. |
|
inline |
Inequality.
This method does not try to coerce the elements to the same field to test equality.
NotInSameFieldException | If the two elements do not have de same parent field. |
FieldElement< T > & FAAST::FieldElement< T >::operator= | ( | const BigInt & | i | ) | throw (UndefinedFieldException) |
Assign a scalar value to this element.
The parent field of the element does not change through the assignment.
UndefinedFieldException | If this is the special 0 element and i is different from 0. |
bool FAAST::FieldElement< T >::operator== | ( | const FieldElement< T > & | e | ) | const throw (NotInSameFieldException) |
Equality.
This method does not try to coerce the elements to the same field to test equality.
NotInSameFieldException | If the two elements do not have de same parent field. |
|
inline |
Coerce to the field F.
[in] | F | A finite subfield or overfield of the parent field, containing this element. |
IllegalCoercionException | If no embedding is known between the parent field and F or if this element does not belong to F. |
void FAAST::FieldElement< T >::operator>>= | ( | const Field< T > & | F | ) | throw (IllegalCoercionException) |
Coerce to the field F and store the result in this element.
[in] | F | A finite subfield or overfield of the parent field, containing this element. |
IllegalCoercionException | If no embedding is known between the parent field and F or if this element does not belong to F. |
|
inline |
The parent field.
With the exception of the zero element created by the default constructor, any element has an unique parent field and binary operations can combine two elements only in one of the following two cases:
UndefinedFieldException | If this element does not belong to any field. |
ostream & FAAST::FieldElement< T >::print | ( | ostream & | o, |
const vector< string > & | vars | ||
) | const |
Print this element to o as a multivariate polynomial over Fp.
The number of variables in vars must be at least one plus the Artin-Schreier height of the parent field. The recursive descent along the tower is done via Field::toBivariate(), the list of the fields involved in the descent is internally stored and reproduces backwards the list of calls to Field::ArtinSchreierExtension that have created the parent field.
[in,out] | o | An output stream. |
[in] | vars | A vector of variable names. |
BadParametersException | If there is not enough variables in vars. |
|
inline |
n-th pseudotrace
Let x be this element, the n-th pseudotrace, noted Tn(x) is
This method is a generalization of the algorithm Pseudotrace
of [DFS '09, Section 5].
void FAAST::FieldElement< T >::self_pseudotrace | ( | unsigned long | n | ) | throw () |
n-th pseudotrace
Let x be this element, the n-th pseudotrace, noted Tn(x) is
This method is a generalization of the algorithm Pseudotrace
of [DFS '09, Section 5].
void FAAST::FieldElement< T >::toInfrastructure | ( | GFp & | e | ) | const throw (IllegalCoercionException) |
Get the representation of elements whose parent field is Fp.
[out] | e | An NTL scalar element to hold the result. |
IllegalCoercionException | If the parent field is not a prime field |
void FAAST::FieldElement< T >::toInfrastructure | ( | GFpE & | e | ) | const throw (IllegalCoercionException) |
Get the representation of elements whose parent field is an extension field.
[out] | e | An NTL element to hold the result. |
IllegalCoercionException | If the parent field is a prime field |
FieldElement< T > FAAST::FieldElement< T >::toScalar | ( | ) | const throw (IllegalCoercionException) |
Coerce to a scalar.
Coerce to an element of Fp.
IllegalCoercionException | If the element is not a scalar. |
|
inline |
Trace over the field F.
NotASubFieldException | If this element does not belong to an overfield of F. |
|
friend |
Convert v from the bivariate representation over the immediate subfield in the primitive tower (the stem) to the internal (univariate) representation.
If the parent field of the elements of v is the prime field, then e is the element whose univariate representation has v as cofficients. Otherwise let
This method stores in e an element of e.parent()
such that .overField()
If v is too short, it is filled with zeros. If v is too long, the unnecessary elements are ignored.
Let K be the field in the primitive tower (the stem) isomorphic to the parent field of the elements of v, this corresponds to convert v from the multivariate representation as an element of K[x] to the internal (univariate) representation. This routine implements the algorithm LiftUp
of [DFS '09, Section 4.4].
[in] | v | A vector of elements all in the same field. |
[out] | e | An element satisfying condition (2). |
NotInSameFieldException | If the elements of v do not all have the same parent field. |
NoOverFieldException | If the parent field of the elements of v has no overfield. |
|
friend |
Convert e from the internal (univariate) representation to the bivariate representation over the immediate subfield in the primitive tower (the stem).
If the parent field of e is the base field of an Artin-Schreier tower, then v is filled with the coefficients in Fp of its univariate representation. Otherwise let
This method fills the vector v with p elements of e.parent()
such that .subField()
Let K be the field in the primitive tower (the stem) isomorphic to e.parent()
, this corresponds to convert e from its internal (univariate) representation to the bivariate representation as an element of K[x]. This routine implements the algorithm .subField()
PushDown
of [DFS '09, Section 4.2].
[in] | e | An element of any field. |
[out] | v | A vector of elements of e.parent() that satisfies condition (1). |
NoSubFieldException | If Fp is the parent field of e. |