-
Notifications
You must be signed in to change notification settings - Fork 38
Include the fq_default type
#97
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
Merged
Merged
Changes from 29 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
1bd96ee
Add a VERY rough start on adding fq
GiacomoPope 2488e5f
Merge branch 'flintlib:master' into add_fq
GiacomoPope 20aa30b
Merge branch 'master' into add_fq
GiacomoPope 277794f
Merge branch 'master' into add_fq
GiacomoPope 942152a
Merge branch 'master' into add_fq
GiacomoPope 3d637f6
further work on fq_default with luca de feo
GiacomoPope b728899
add line to meson build
GiacomoPope c8fe699
more boilerplate code
GiacomoPope 1307116
add fq_default to the doctests
GiacomoPope 6bf96a7
start on type conversions and comparisons
GiacomoPope 7e68a0c
untested arithemtic
GiacomoPope 7347924
begin adding tests
GiacomoPope 49b882c
clean up enum name, maybe a little hacky...
GiacomoPope ad5be0b
attempt to fix doctests for all versions
GiacomoPope ece8c45
add docstrings
GiacomoPope 273deee
remove trailing whitespace
GiacomoPope 78a42dd
remove unused var
GiacomoPope 6e71a59
include equality tests
GiacomoPope 44c3186
move more boilerplate into the flint_base
GiacomoPope 9da32da
remove parsing of list to self in any_to...
GiacomoPope 3c93c45
add to_list method and repr function
GiacomoPope 0a9d276
add tests for fq_default init from context
GiacomoPope eca0210
some small clean up across the file
GiacomoPope f2443f8
refactor equality and coercion
GiacomoPope 915837e
attempt to include is_primitive
GiacomoPope 83f2179
use union instead of struct
GiacomoPope 525883f
comment out broken function
GiacomoPope 812fea4
make is_primitive work
GiacomoPope ef2136a
broken refactor; need help
GiacomoPope 172c9d8
remove is_primitive and modify base template
GiacomoPope ce8cd4d
modify _arith_ to use cpdef
GiacomoPope ee4ae24
fix some but not all reviewer comments -- need to stop for the day
GiacomoPope 38b6ce1
change docstrings for the type stuff
GiacomoPope 52f8847
ensure the modulus matches for scalar coercion
GiacomoPope 66c54f4
use try / except for slong conversion
GiacomoPope 163f7cc
move docstring to class
GiacomoPope e32a6dd
refactor out where the dict is for types
GiacomoPope 876fd2a
move docstring
GiacomoPope e79b397
add docs
GiacomoPope f789f22
check modulus for nmod_poly and fmpz_mod_poly
GiacomoPope File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| from flint.flintlib.flint cimport flint_bitcnt_t, fmpz_struct, slong, flint_rand_t, ulong | ||
| from flint.flintlib.fmpz cimport fmpz_t, fmpz_struct | ||
| from flint.flintlib.fmpz_mod cimport fmpz_mod_ctx_t | ||
| from flint.flintlib.fmpz_mod_mat cimport fmpz_mod_mat_t | ||
| from flint.flintlib.fmpz_poly cimport fmpz_poly_t, fmpz_poly_struct | ||
| from flint.flintlib.fmpz_mod_poly cimport fmpz_mod_poly_t, fmpz_mod_poly_struct | ||
|
|
||
| cdef extern from "flint/fq.h": | ||
|
|
||
| ctypedef fmpz_poly_t fq_t | ||
| ctypedef fmpz_poly_struct fq_struct | ||
|
|
||
| ctypedef struct fq_ctx_struct: | ||
| fmpz_mod_ctx_t ctxp | ||
|
|
||
| int sparse_modulus | ||
| int is_conway # whether field was initialized with the Flint Conway tables (assures primitivity) | ||
|
|
||
| fmpz_struct * a | ||
| slong * j | ||
| slong len | ||
|
|
||
| fmpz_mod_poly_t modulus | ||
| fmpz_mod_poly_t inv | ||
|
|
||
| char * var | ||
|
|
||
| ctypedef fq_ctx_struct fq_ctx_t[1] | ||
|
|
||
| void fq_ctx_init(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) | ||
| int _fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) | ||
| void fq_ctx_init_conway(fq_ctx_t ctx, const fmpz_t p, slong d, const char *var) | ||
| void fq_ctx_init_modulus(fq_ctx_t ctx, const fmpz_mod_poly_t modulus, const fmpz_mod_ctx_t ctxp, const char *var) | ||
| void fq_ctx_clear(fq_ctx_t ctx) | ||
| const fmpz_mod_poly_struct* fq_ctx_modulus(const fq_ctx_t ctx) | ||
| long fq_ctx_degree(const fq_ctx_t ctx) | ||
| fmpz_struct * fq_ctx_prime(const fq_ctx_t ctx) | ||
| void fq_ctx_order(fmpz_t f, const fq_ctx_t ctx) | ||
| # int fq_ctx_fprint(FILE * file, const fq_ctx_t ctx) | ||
| void fq_ctx_print(const fq_ctx_t ctx) | ||
| void fq_ctx_randtest(fq_ctx_t ctx) | ||
| void fq_ctx_randtest_reducible(fq_ctx_t ctx) | ||
| void fq_init(fq_t rop, const fq_ctx_t ctx) | ||
| void fq_init2(fq_t rop, const fq_ctx_t ctx) | ||
| void fq_clear(fq_t rop, const fq_ctx_t ctx) | ||
| void _fq_sparse_reduce(fmpz_struct *R, slong lenR, const fq_ctx_t ctx) | ||
| void _fq_dense_reduce(fmpz_struct *R, slong lenR, const fq_ctx_t ctx) | ||
| void _fq_reduce(fmpz_struct *r, slong lenR, const fq_ctx_t ctx) | ||
| void fq_reduce(fq_t rop, const fq_ctx_t ctx) | ||
| void fq_add(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) | ||
| void fq_sub(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) | ||
| void fq_sub_one(fq_t rop, const fq_t op1, const fq_ctx_t ctx) | ||
| void fq_neg(fq_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void fq_mul(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) | ||
| void fq_mul_fmpz(fq_t rop, const fq_t op, const fmpz_t x, const fq_ctx_t ctx) | ||
| void fq_mul_si(fq_t rop, const fq_t op, slong x, const fq_ctx_t ctx) | ||
| void fq_mul_ui(fq_t rop, const fq_t op, ulong x, const fq_ctx_t ctx) | ||
| void fq_sqr(fq_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void fq_div(fq_t rop, const fq_t op1, const fq_t op2, const fq_ctx_t ctx) | ||
| void _fq_inv(fmpz_struct *rop, const fmpz_struct *op, slong len, const fq_ctx_t ctx) | ||
| void fq_inv(fq_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void fq_gcdinv(fq_t f, fq_t inv, const fq_t op, const fq_ctx_t ctx) | ||
| void _fq_pow(fmpz_struct *rop, const fmpz_struct *op, slong len, const fmpz_t e, const fq_ctx_t ctx) | ||
| void fq_pow(fq_t rop, const fq_t op, const fmpz_t e, const fq_ctx_t ctx) | ||
| void fq_pow_ui(fq_t rop, const fq_t op, const ulong e, const fq_ctx_t ctx) | ||
| int fq_sqrt(fq_t rop, const fq_t op1, const fq_ctx_t ctx) | ||
| void fq_pth_root(fq_t rop, const fq_t op1, const fq_ctx_t ctx) | ||
| int fq_is_square(const fq_t op, const fq_ctx_t ctx) | ||
| # int fq_fprint_pretty(FILE *file, const fq_t op, const fq_ctx_t ctx) | ||
| int fq_print_pretty(const fq_t op, const fq_ctx_t ctx) | ||
| # void fq_fprint(FILE * file, const fq_t op, const fq_ctx_t ctx) | ||
| void fq_print(const fq_t op, const fq_ctx_t ctx) | ||
| char * fq_get_str(const fq_t op, const fq_ctx_t ctx) | ||
| char * fq_get_str_pretty(const fq_t op, const fq_ctx_t ctx) | ||
| void fq_randtest(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) | ||
| void fq_randtest_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) | ||
| void fq_randtest_dense(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) | ||
| void fq_rand(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) | ||
| void fq_rand_not_zero(fq_t rop, flint_rand_t state, const fq_ctx_t ctx) | ||
| void fq_set(fq_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void fq_set_si(fq_t rop, const slong x, const fq_ctx_t ctx) | ||
| void fq_set_ui(fq_t rop, const ulong x, const fq_ctx_t ctx) | ||
| void fq_set_fmpz(fq_t rop, const fmpz_t x, const fq_ctx_t ctx) | ||
| void fq_swap(fq_t op1, fq_t op2, const fq_ctx_t ctx) | ||
| void fq_zero(fq_t rop, const fq_ctx_t ctx) | ||
| void fq_one(fq_t rop, const fq_ctx_t ctx) | ||
| void fq_gen(fq_t rop, const fq_ctx_t ctx) | ||
| int fq_get_fmpz(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void fq_get_fmpz_poly(fmpz_poly_t a, const fq_t b, const fq_ctx_t ctx) | ||
| void fq_get_fmpz_mod_poly(fmpz_mod_poly_t a, const fq_t b, const fq_ctx_t ctx) | ||
| void fq_set_fmpz_poly(fq_t a, const fmpz_poly_t b, const fq_ctx_t ctx) | ||
| void fq_set_fmpz_mod_poly(fq_t a, const fmpz_mod_poly_t b, const fq_ctx_t ctx) | ||
| void fq_get_fmpz_mod_mat(fmpz_mod_mat_t col, const fq_t a, const fq_ctx_t ctx) | ||
| void fq_set_fmpz_mod_mat(fq_t a, const fmpz_mod_mat_t col, const fq_ctx_t ctx) | ||
| int fq_is_zero(const fq_t op, const fq_ctx_t ctx) | ||
| int fq_is_one(const fq_t op, const fq_ctx_t ctx) | ||
| int fq_equal(const fq_t op1, const fq_t op2, const fq_ctx_t ctx) | ||
| int fq_is_invertible(const fq_t op, const fq_ctx_t ctx) | ||
| int fq_is_invertible_f(fq_t f, const fq_t op, const fq_ctx_t ctx) | ||
| void _fq_trace(fmpz_t rop, const fmpz_struct *op, slong len, const fq_ctx_t ctx) | ||
| void fq_trace(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void _fq_norm(fmpz_t rop, const fmpz_struct *op, slong len, const fq_ctx_t ctx) | ||
| void fq_norm(fmpz_t rop, const fq_t op, const fq_ctx_t ctx) | ||
| void _fq_frobenius(fmpz_struct *rop, const fmpz_struct *op, slong len, slong e, const fq_ctx_t ctx) | ||
| void fq_frobenius(fq_t rop, const fq_t op, slong e, const fq_ctx_t ctx) | ||
| int fq_multiplicative_order(fmpz_t ord, const fq_t op, const fq_ctx_t ctx) | ||
| int fq_is_primitive(const fq_t op, const fq_ctx_t ctx) | ||
| void fq_bit_pack(fmpz_t f, const fq_t op, flint_bitcnt_t bit_size, const fq_ctx_t ctx) | ||
| void fq_bit_unpack(fq_t rop, const fmpz_t f, flint_bitcnt_t bit_size, const fq_ctx_t ctx) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than having
swap=TrueI would just have two methods_sub_and_rsub_.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that
__sub__handles all conditionality so that_sub_and_rsub_do not need to check anything. Also keyword arguments can add overhead that I would avoid at this level.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK I've done this for the base class and added
rsub,rdiv.