bug in jacobisymbol Combinatorics.jl

61 views
Skip to first unread message

lapeyre....@gmail.com

unread,
Jan 3, 2015, 12:44:40 PM1/3/15
to julia...@googlegroups.com
This is not correct

julia> jacobisymbol(10,7)
4294967295

This happens in v0.3 and v0.4
I can send more information, and have a possible fix. I tried to find a way to make a comment or issue or something at
https://github.com/jiahao/Combinatorics.jl,
but was unable to find a button for it.  Better to talk before issuing a PR.

--John

lapeyre....@gmail.com

unread,
Jan 3, 2015, 12:52:40 PM1/3/15
to julia...@googlegroups.com
Changing the line that calls libgmp like this ( Int is replaced with Int32 )
  
 return convert(Int,ccall((:__gmpz_jacobi, :libgmp), Int32,

gives correct results. The C header and code says the return type is 'int'.
All values that should be -1, come out 4294967295.  This may be system
dependent, but I only have one laptop available at the moment.

Jiahao Chen

unread,
Jan 3, 2015, 1:11:19 PM1/3/15
to julia...@googlegroups.com
Thanks for the report and the fix.

I've updated the code and strengthened the test; the only change was to use Cint instead of Int32 for consistency with our C calling code:


I've also enabled the issue tracker; didn't realize it was off.

Ivar Nesje

unread,
Jan 3, 2015, 1:19:44 PM1/3/15
to julia...@googlegroups.com
The issue tracker is off for Github forks. If the package has moved and is maintained at @jiahao's fork, he should break the fork relation.

lapeyre....@gmail.com

unread,
Jan 3, 2015, 1:24:06 PM1/3/15
to julia...@googlegroups.com
Great,  thanks. Cint make more sense. Also, the same change needs to be made for
 legendresymbol.

Jiahao Chen

unread,
Jan 3, 2015, 1:38:31 PM1/3/15
to julia...@googlegroups.com
Yes, I've already included the change:

https://github.com/jiahao/Combinatorics.jl/commit/5e3d1b34adac5c7dfc2bd45d5515b34c87d6c9b0

A new version with this fix has been tagged as v0.1.2.

Reply all
Reply to author
Forward
0 new messages