Skip to content
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

Some matrix optimizations #1712

Merged
merged 10 commits into from
Apr 16, 2024
Merged

Some matrix optimizations #1712

merged 10 commits into from
Apr 16, 2024

Conversation

joschmitt
Copy link
Collaborator

@joschmitt joschmitt commented Apr 10, 2024

Including and extending the work of @fieker.

I add tests once I see the CI result as usual. (Which needs an AbstractAlgebra update; I forgot.)

@joschmitt joschmitt marked this pull request as draft April 10, 2024 14:23
@joschmitt joschmitt closed this Apr 11, 2024
@joschmitt joschmitt reopened this Apr 11, 2024
Copy link

codecov bot commented Apr 11, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.77%. Comparing base (5fac404) to head (ad676fe).

❗ Current head ad676fe differs from pull request most recent head aab6f83. Consider uploading reports for the commit aab6f83 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1712      +/-   ##
==========================================
+ Coverage   84.68%   84.77%   +0.08%     
==========================================
  Files          94       94              
  Lines       37139    37296     +157     
==========================================
+ Hits        31451    31616     +165     
+ Misses       5688     5680       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joschmitt joschmitt force-pushed the js/claus branch 2 times, most recently from 1c32a42 to de16a6a Compare April 11, 2024 14:09
(Ref{FqMatrix}, Ref{FqMatrix}, Ref{FqField}), A, b, base_ring(a))
end

function Generic.add_one!(a::FqMatrix, i::Int, j::Int)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this function be added for all the different flint matrix types? And is there a better way to do it?
With the pointer it needs 1 allocation (I assume for one(F)) in comparison to 3 allocations for the naive a[i, j] += 1.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is fq_default_sub_one, but no fq_default_add_one. So you could do a neg!(sub_one!(neg!(x))) to do it allocation free. Not sure if this is a good idea.

Any ideas @fieker?

@joschmitt joschmitt marked this pull request as ready for review April 11, 2024 14:12
@fieker
Copy link
Contributor

fieker commented Apr 11, 2024 via email

@thofma
Copy link
Member

thofma commented Apr 11, 2024

fq_default does not have the add_si version.

@joschmitt
Copy link
Collaborator Author

I see what I can do.

@joschmitt joschmitt marked this pull request as draft April 11, 2024 15:09
@fieker
Copy link
Contributor

fieker commented Apr 11, 2024 via email

@joschmitt joschmitt marked this pull request as ready for review April 12, 2024 11:56
@joschmitt
Copy link
Collaborator Author

I added add_one! for the flint matrix types. It is allocation free except for fq_mat and fq_nmod_mat (and the corresponding cases in fq_default_mat). For these, neg(sub_one(neg(...))) is better than add(..., one), but still needs one allocation.

src/flint/fmpz_mod_mat.jl Outdated Show resolved Hide resolved
@joschmitt
Copy link
Collaborator Author

I corrected the fmpz_mod cases as discussed, so this is good to go now.

@thofma thofma merged commit 23c3759 into Nemocas:master Apr 16, 2024
22 of 24 checks passed
@thofma
Copy link
Member

thofma commented Apr 16, 2024

Thanks

@joschmitt joschmitt deleted the js/claus branch April 16, 2024 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants