-
Notifications
You must be signed in to change notification settings - Fork 58
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
Don't use ccalls where wrappers already exist (fmpz edition) #1913
Merged
Merged
Changes from 15 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
43b1872
Don't ccall `fmpz_addmul`
lgoettgens 9c80877
Don't ccall `fmpz_sgn`
lgoettgens bc077fb
Dont ccall `fmpz_lcm`
lgoettgens 86ceb3d
Don't ccall `fmpz_gcd`
lgoettgens 1688a4c
Don't ccall `fmpz_zero`
lgoettgens 87fe6db
Don't ccall `fmpz_sub`
lgoettgens 2aabe4e
Don't ccall `fmpz_divexact`
lgoettgens b33245b
Don't ccall `fmpz_sqrt`/`fmpz_sqrtrem`
lgoettgens 6c49531
Don't ccall `fmpz_bits`
lgoettgens 5eec5f2
Some simplification in divisions
lgoettgens 569413b
Don't call `fmpz_remove`
lgoettgens 4533873
Don't ccall `fmpq_numerator_ptr`
lgoettgens 4f0804b
Refactor and test remove&valuation for QQFieldElem
fingolfin 71e1dfd
Generalize remove! for ZZRingElem
fingolfin ec3ce1e
Add is_positive_entry test
fingolfin 8ed7e5e
Ensure remove! return an Int valuation even on Windows
fingolfin e2903d2
Add some more tests
fingolfin 2399159
oops
fingolfin b152b34
Merge branch 'master' into lg/less-ccalls-fmpz
fingolfin 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
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 |
---|---|---|
|
@@ -158,8 +158,7 @@ | |
@boundscheck _checkbounds(A, i, j) | ||
GC.@preserve A begin | ||
m = mat_entry_ptr(A, i, j) | ||
fl = ccall((:fmpz_sgn, libflint), Int, (Ptr{ZZRingElem},), m) | ||
return isone(fl) | ||
return is_positive(m) | ||
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. Code not covered, seems we have zero tests for |
||
end | ||
end | ||
|
||
|
@@ -769,7 +768,7 @@ | |
zero!(r) | ||
M_ptr = mat_entry_ptr(M, i, 1) | ||
for j in 1:n | ||
ccall((:fmpz_addmul, libflint), Cvoid, (Ref{ZZRingElem}, Ptr{ZZRingElem}, Ptr{ZZRingElem}), r, M_ptr, M_ptr) | ||
addmul!(r, M_ptr, M_ptr) | ||
M_ptr += sizeof(ZZRingElem) | ||
end | ||
if iszero(r) | ||
|
@@ -794,7 +793,7 @@ | |
#this is not going through the "correct" order of the rows, but | ||
#for this is does not matter | ||
if !iszero(unsafe_load(reinterpret(Ptr{Int}, M_ptr))) | ||
mx = max(mx, ccall((:fmpz_bits, libflint), Culong, (Ptr{ZZRingElem},), M_ptr)) | ||
mx = max(mx, nbits(M_ptr)) | ||
end | ||
M_ptr += sizeof(ZZRingElem) | ||
end | ||
|
@@ -1395,7 +1394,7 @@ | |
i_ptr = mat_entry_ptr(A, i, 1) | ||
j_ptr = mat_entry_ptr(A, j, 1) | ||
for k = 1:ncols(A) | ||
ccall((:fmpz_addmul, libflint), Cvoid, (Ptr{ZZRingElem}, Ref{ZZRingElem}, Ptr{ZZRingElem}), i_ptr, s, j_ptr) | ||
addmul!(i_ptr, s, j_ptr) | ||
i_ptr += sizeof(ZZRingElem) | ||
j_ptr += sizeof(ZZRingElem) | ||
end | ||
|
@@ -1409,7 +1408,7 @@ | |
for k = 1:nrows(A) | ||
i_ptr = mat_entry_ptr(A, k, i) | ||
j_ptr = mat_entry_ptr(A, k, j) | ||
ccall((:fmpz_addmul, libflint), Cvoid, (Ptr{ZZRingElem}, Ref{ZZRingElem}, Ptr{ZZRingElem}), i_ptr, s, j_ptr) | ||
addmul!(i_ptr, s, j_ptr) | ||
end | ||
end | ||
end | ||
|
@@ -1628,18 +1627,16 @@ | |
tmp_p += sizeof(ZZRingElem) | ||
end | ||
for j = 1:n | ||
ccall((:fmpz_zero, libflint), Cvoid, (Ref{ZZRingElem}, ), s) | ||
zero!(s) | ||
|
||
tmp_p = mat_entry_ptr(tmp, 1, 1) | ||
for k = 1:j-1 | ||
U_p = mat_entry_ptr(U, k, j) | ||
ccall((:fmpz_addmul, libflint), Cvoid, (Ref{ZZRingElem}, Ptr{ZZRingElem}, Ptr{ZZRingElem}), s, U_p, tmp_p) | ||
addmul!(s, U_p, tmp_p) | ||
tmp_p += sizeof(ZZRingElem) | ||
end | ||
ccall((:fmpz_sub, libflint), Cvoid, | ||
(Ref{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), s, mat_entry_ptr(b, i, j), s) | ||
ccall((:fmpz_divexact, libflint), Cvoid, | ||
(Ptr{ZZRingElem}, Ref{ZZRingElem}, Ptr{ZZRingElem}), mat_entry_ptr(tmp, 1, j), s, mat_entry_ptr(U, j, j)) | ||
sub!(s, mat_entry_ptr(b, i, j), s) | ||
divexact!(mat_entry_ptr(tmp, 1, j), s, mat_entry_ptr(U, j, j)) | ||
end | ||
tmp_p = mat_entry_ptr(tmp, 1, 1) | ||
X_p = mat_entry_ptr(X, i, 1) | ||
|
@@ -1669,21 +1666,20 @@ | |
tmp_ptr += sizeof(ZZRingElem) | ||
end | ||
for j = n:-1:1 | ||
ccall((:fmpz_zero, libflint), Cvoid, (Ref{ZZRingElem}, ), s) | ||
zero!(s) | ||
tmp_ptr = mat_entry_ptr(tmp, 1, j+1) | ||
for k = j + 1:n | ||
U_ptr = mat_entry_ptr(U, j, k) | ||
ccall((:fmpz_addmul, libflint), Cvoid, (Ref{ZZRingElem}, Ptr{ZZRingElem}, Ptr{ZZRingElem}), s, U_ptr, tmp_ptr) | ||
mul!(s, U_ptr, tmp_ptr) | ||
tmp_ptr += sizeof(ZZRingElem) | ||
# s = addmul!(s, U[j, k], tmp[k]) | ||
end | ||
b_ptr = mat_entry_ptr(b, j, i) | ||
ccall((:fmpz_sub, libflint), Cvoid, (Ref{ZZRingElem}, Ptr{ZZRingElem}, Ref{ZZRingElem}), s, b_ptr, s) | ||
sub!(s, b_ptr, s) | ||
# s = b[j, i] - s | ||
tmp_ptr = mat_entry_ptr(tmp, 1, j) | ||
U_ptr = mat_entry_ptr(U, j, j) | ||
ccall((:fmpz_divexact, libflint), Cvoid, (Ptr{ZZRingElem}, Ref{ZZRingElem}, Ptr{ZZRingElem}), tmp_ptr, s, U_ptr) | ||
|
||
divexact!(tmp_ptr, s, U_ptr) | ||
# tmp[j] = divexact(s, U[j,j]) | ||
end | ||
tmp_ptr = mat_entry_ptr(tmp, 1, 1) | ||
|
Oops, something went wrong.
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.
Code not covered, seems we have zero tests for
remove!
:-(