Comments (6)
On 23 May 2014 18:19, Julian Ospald [email protected] wrote:
I am currently using flint for a small fun crypto project which involves a
lot of polynomial arithmetic, modulus stuff and euclidean algorithm.There are a few things in the flint API that confuses me. Please bear with
me in case I was just too stupid to figure out something:
- a lot of functions are void without any indication if they succeeded
or not... I have to check the parameters I passed or wait for a segfault in
order to figure out what just happenedThis can't be changed. Some functions need to return values, so it would
be inconsistent to have them return fail/pass. Besides this, if a flint
function fails, it's a bug.
- it seems most functions don't do any checking on the parameters they
use... so you get a segfault instead somewhere in the middle of the code,
when the function tries to dereference null-pointersWe intend to add asserts, which will detect invalid input when
--enable-assert is specified at configure. But it's a lot of work. Bear
with us.
- although the allocation of polynomials is pretty smart, it also
makes it extremely difficult to implement some algorithms that expect
trailing 0-coefficients (NOT null-pointers!)... this makes me check for
both... is it a null pointer? if it is not, is it a null-coefficient?You should not ever have a coefficient that is a null pointer. Are you
using fmpz_poly_get_coeff_ptr or something like that?
Algorithms in flint should be fine with trailing zero coefficients. But we
don't do any special for speed, and we could.
- It's not clear to me whether it is safe to access some structs
directly. E.g. it gets a bit weird if you have to operate a lot on
polynomial coefficients and have to use fmpz_poly_get_coeff_ptr() in a
hundred placesThat's C for you.
- the meaning of "get" is confusing in a lot of functions
- for modular reduction I ended up calling fmpz_poly_get_nmod_poly()
and fmpz_poly_set_nmod_poly_unsigned() directly after it in most of the
cases, maybe a convenience function here would be a thing to consider in
case I don't really need the nmod_poly data type?Yes, we could add a function for reducing coefficients without creating the
intermediate type. This would be easy.But what bothers me most is the error handling. Did I miss a section in
the manual and there is some sort of global variable I can check? Or is
this just a design decision of debugging segfaults instead of functions
returning error codes?
Welcome to C!
You might investigate the valgrind program. And yes, it is a design
decision, for efficiency reasons. It definitely wont be changed. Sorry
about that.
As I say, things will be easier when we have asserts throughout. But
currently, if you pass valid input according to the documentation, and it
segfaults, please report it as a bug!
Bill.
Anyway, probably the most advanced library in this field. Pretty awesome.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/76
.
from flint2.
using fmpz_poly_get_coeff_ptr or something like that?
Exactly. One of the polynomials might have a much lesser degree and I need to compare coefficients in both. The comparison now is 2 steps (as in: assume "0"-coefficient if fmpz_poly_get_coeff_ptr() returns a NULL-pointer). The same goes for setting coefficients in the blue, without knowing the whole polynomial yet.
Setting trailing zero-coefficients via the fmpz_poly_set_coeff_* functions will just be ignored, or I did something wrong.
You might investigate the valgrind program.
Already using it :)
from flint2.
On 23 May 2014 19:32, Julian Ospald [email protected] wrote:
using fmpz_poly_get_coeff_ptr or something like that?
Exactly. One of the polynomials might have a much lesser degree and I need
to compare coefficients in both. The comparison now is 2 steps (as in:
assume "0"-coefficient if fmpz_poly_get_coeff_ptr() returns a NULL-pointer).You have to take the length of the polynomials into account. You can use
FLINT_MIN(len1, len2) to work out the shortest length, then do two for
loops, one up to min, the other for the rest. This is the way I'd do it in
C anyway.The same goes for setting coefficients in the blue, without knowing the
whole polynomial yet.Setting trailing zero-coefficients via the fmpz_poly_set_coeff_* functions
will just be ignored, or I did something wrong.
Possibly. The higher the index, the higher the degree of the coefficient.
So setting a coefficient to zero beyond the end of an existing polynomial
will just set the coefficient, then normalise the polynomial, which is
equivalent to doing nothing.
All functions in flint assume polynomials are normalised (unless noted
otherwise).
You might investigate the valgrind program.
Already using it :)
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/76#issuecomment-44038943
.
from flint2.
Thanks for the hints.
Another convenience function that I think would be nice to have upstream is:
int fmpz_invmod_ui(fmpz_t f, const fmpz_t g, ulong h);
from flint2.
On 24 May 2014 22:19, Julian Ospald [email protected] wrote:
Thanks for the hints.
Another convenience function that I think would be nice to have upstream
is:int fmpz_invmod_ui(fmpz_t f, const fmpz_t g, ulong h);
Thanks for the suggestion.
If we look at the interface of GMP for example, there are two situations
where _ui functions are provided:
-
Where it is impractical to provide a multiprecision input, e.g. fib_ui,
bin_ui, etc. -
In very simple, low cost, arithmetic functions, such as add_ui, mul_ui,
set_ui.
We could (and might) add fmpz_invmod_ui. But it doesn't really fit into
either of the above categories, so it isn't high priority for us.
Do you have a specific use case in mind?
Bill.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/76#issuecomment-44098709
.
from flint2.
Do you have a specific use case in mind?
I guess it is just for convenience. I use it for the NTRUEncrypt algorithms where I operate on the coefficients with the NTRU parameters which are very small. Not sure if it makes sense to convert them to fmpz_t types.
from flint2.
Related Issues (20)
- Could we release 3.1.3-p1? HOT 1
- fmpz_mpoly_pfrac_init: internal error HOT 7
- Worklist for nfloat HOT 3
- SIMD abstraction layers HOT 5
- Problems with Riemann theta functions HOT 44
- 3.1.3 isn't in the Downlioads section of the website: https://flintlib.org/downloads.html HOT 2
- Document need for libtool
- Improve parallel Schönhage-Strassen multiplication
- file padic_types.h not getting installed HOT 2
- Test failures when compiled with GCC graphite flags HOT 5
- #error machine_vector.h not implemented on AMD Ryzen 7 without forcing --enable-avx HOT 14
- Segmentation Fault in Fortran-C Interoperability when Using Arb Library for Complex Integration HOT 2
- Error finding PkgConfig while installing Flint package using CMake on Windows HOT 1
- Add a function to compute b/sqrt(a)
- Multivariate rational functions over the integers mod n HOT 3
- AVX and nmod HOT 8
- FLINT license should be stated on the FLINT website HOT 1
- Gentoo Linux: sci-mathematics/flint-3.1.3_p1 QA Notice: Package triggers severe warnings which indicate that it may exhibit random runtime failures. HOT 1
- Missing functions in `fq_default` HOT 1
- `fq_default_poly_evaluate_fq_default` with context type `FMPZ_MOD` segfaults
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flint2.