Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature request] allow field.irreducible() and field.generator() as argument in the field constructor #219

Open
dragomang87 opened this issue Mar 14, 2023 · 0 comments

Comments

@dragomang87
Copy link

tl;dr:
given an existing field variable field, trying to construct a copy with
Field(prime, power, field.irreducible(), field.generator())
will not work.

Too short to not read:
Let's consider for example
typedef GFqDom<IdentificationInteger> Field;

Currently, even for same sizes, the constructor of Field will generally not return the same field because the irreducible polynomial seem to be chosen randomly in some way and will thus differ. Thus in order to produce the same field the constructor must be called with:
Field field(prime, power, irreducible, generator)
(In principle, the generator can differ too but this does not seem to happen, it seems to default to 1 in log representation).
The irreducible and generator of an existing field can be obtained with
field.irreducible()
and
field.generator()
The problem is that the Field constructor expects the irreducible and generators as polynomials while the Field class returns integers.
The only way to make it work is with

#include <givaro/modular.h>     // Needed for padic2polynomial function below
Field(prime, power, padic2polynomial(field.irreducible()), padic2polynomial(field.generator()))

with

auto padic2polynomial (Field::Element padic) {
        // Create polynomial field with integer representation
        //// Create the integer prime field
                       Modular<int> PrimeField(3);
        //// Create the polynomial field
        Poly1Dom     < Modular<int>, Dense > Polynomials( PrimeField, Indeter("X") );
        //// Create a padic polynomial field which has the methods to convert a padic integer to a polynomial
        Poly1PadicDom< Modular<int>, Dense > ConverterDomain(Polynomials);
        // Define the polynomial variable
        Poly1PadicDom< Modular<int>, Dense >::Element polynomial;
        // Convert the integer to a  polynomial
        ConverterDomain.radix(polynomial, padic);
        return polynomial;
        }

It would make more sense if Field would return the same format that it expects, and it would made sense for the format to be a Fied::Element so that they can be added to vectors of actual elements, so that the information of how to interpret some elements can be transferred with the elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants