-
Notifications
You must be signed in to change notification settings - Fork 29
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
Add fmpz mod #83
Merged
Merged
Add fmpz mod #83
Changes from 27 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
5a84520
Add new type to package
GiacomoPope 9fbe93a
Include additional struct
GiacomoPope 12a87ea
Tidy up
GiacomoPope b7b3df3
Level 0 functions for fmpz_mod
GiacomoPope 548107a
Start working on context for fmpz_mod
GiacomoPope 7e7dc87
Small progress
GiacomoPope 59cfb05
clean up context
GiacomoPope 0ecf9a0
Got initalisation somewhat working
GiacomoPope bd09992
Add ability to create type from context
GiacomoPope 06f00d1
Add fmpz_mod tests
GiacomoPope 9f01093
Add comparisons and start arithmetic
GiacomoPope 6f58268
Modify comparison tests following feedback
GiacomoPope f32fdfa
allow other types in addition
GiacomoPope 79db695
update tests
GiacomoPope 717acf4
add test to ensure correct error for mismatched moduli
GiacomoPope 7a8f7e5
First draft of fmpz_mod
GiacomoPope 514f3b0
Update tests
GiacomoPope 91615a2
Avoid call to modulus
GiacomoPope 356ec25
Include additional tests
GiacomoPope 70a1f57
Modify code based on feedback and attempt to simplify code
GiacomoPope cd73cf8
increase coverage of fmpz_mod tests
GiacomoPope 3e79dc7
Small changes based off feedback from PR
GiacomoPope 2e433ca
Remove function in favour for import
GiacomoPope f96f3c3
Get to 99% coverage
GiacomoPope 952159f
Various changes thanks to PR feedback
GiacomoPope 6244dc2
Modify cinit and init
GiacomoPope 42d44ad
Add doctests and rst for fmpz_mod
GiacomoPope 1e7332f
fix doc issues
GiacomoPope 5e09ff1
add sphinx links to docstrings
GiacomoPope db0c86b
Add missing export
GiacomoPope b2dfc43
Fix latex in docstring
GiacomoPope ea30b64
Remove unneeded docstring
GiacomoPope 5dead0c
Make function cdef
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 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,8 @@ | ||
**fmpz** -- integers mod n | ||
=============================================================================== | ||
|
||
.. autoclass :: flint.fmpz_mod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
:members: | ||
:inherited-members: | ||
:undoc-members: | ||
|
This file contains 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 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 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 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 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,45 @@ | ||
from flint.flintlib.flint cimport ulong, slong | ||
from flint.flintlib.fmpz cimport fmpz_t, fmpz_preinvn_struct | ||
from flint.flintlib.nmod cimport nmod_t | ||
|
||
# unimported types {'fmpz_mod_discrete_log_pohlig_hellman_t'} | ||
|
||
cdef extern from "flint/fmpz_mod.h": | ||
ctypedef struct fmpz_mod_ctx_struct: | ||
fmpz_t n | ||
nmod_t mod | ||
ulong n_limbs[3] | ||
ulong ninv_limbs[3] | ||
fmpz_preinvn_struct * ninv_huge | ||
ctypedef fmpz_mod_ctx_struct fmpz_mod_ctx_t[1] | ||
|
||
# Parsed from here | ||
void fmpz_mod_ctx_init(fmpz_mod_ctx_t ctx, const fmpz_t n) | ||
void fmpz_mod_ctx_clear(fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_ctx_set_modulus(fmpz_mod_ctx_t ctx, const fmpz_t n) | ||
void fmpz_mod_set_fmpz(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) | ||
int fmpz_mod_is_canonical(const fmpz_t a, const fmpz_mod_ctx_t ctx) | ||
int fmpz_mod_is_one(const fmpz_t a, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_add(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_add_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_add_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_add_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_sub_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_sub_ui(fmpz_t a, const fmpz_t b, ulong c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_sub_si(fmpz_t a, const fmpz_t b, slong c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_fmpz_sub(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_ui_sub(fmpz_t a, ulong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_si_sub(fmpz_t a, slong b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_neg(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_mul(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_inv(fmpz_t a, const fmpz_t b, const fmpz_mod_ctx_t ctx) | ||
int fmpz_mod_divides(fmpz_t a, const fmpz_t b, const fmpz_t c, const fmpz_mod_ctx_t ctx) | ||
void fmpz_mod_pow_ui(fmpz_t a, const fmpz_t b, ulong e, const fmpz_mod_ctx_t ctx) | ||
int fmpz_mod_pow_fmpz(fmpz_t a, const fmpz_t b, const fmpz_t e, const fmpz_mod_ctx_t ctx) | ||
# void fmpz_mod_discrete_log_pohlig_hellman_init(fmpz_mod_discrete_log_pohlig_hellman_t L) | ||
# void fmpz_mod_discrete_log_pohlig_hellman_clear(fmpz_mod_discrete_log_pohlig_hellman_t L) | ||
# double fmpz_mod_discrete_log_pohlig_hellman_precompute_prime(fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t p) | ||
# const fmpz_struct * fmpz_mod_discrete_log_pohlig_hellman_primitive_root(const fmpz_mod_discrete_log_pohlig_hellman_t L) | ||
# void fmpz_mod_discrete_log_pohlig_hellman_run(fmpz_t x, const fmpz_mod_discrete_log_pohlig_hellman_t L, const fmpz_t y) | ||
int fmpz_next_smooth_prime(fmpz_t a, const fmpz_t b) |
This file contains 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 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 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,12 @@ | ||
from flint.flint_base.flint_base cimport flint_scalar | ||
from flint.flintlib.fmpz cimport fmpz_t | ||
from flint.flintlib.fmpz_mod cimport fmpz_mod_ctx_t | ||
|
||
|
||
cdef class fmpz_mod_ctx: | ||
cdef fmpz_mod_ctx_t val | ||
|
||
cdef class fmpz_mod(flint_scalar): | ||
cdef fmpz_mod_ctx ctx | ||
cdef fmpz_t val | ||
|
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.
This should say
fmpz_mod
.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.
Thank you!!