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

Overload LinearAlgebra.tr #210

Merged
merged 4 commits into from
Jul 6, 2023
Merged

Overload LinearAlgebra.tr #210

merged 4 commits into from
Jul 6, 2023

Conversation

dkarrasch
Copy link
Member

Some users expressed interest in the trace function, so here we go. In the generic case, this is, of course, expensive, but in some cases we may leverage the lazy structure and algebraic rules to compute the trace allocation-free, like in the (lazy) Kronecker product of two square matrices. Another included classic use case is (lazy) rank-one matrices.

@codecov
Copy link

codecov bot commented Jul 2, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.01 🎉

Comparison is base (b6b1044) 99.67% compared to head (fd150d4) 99.68%.

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

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #210      +/-   ##
==========================================
+ Coverage   99.67%   99.68%   +0.01%     
==========================================
  Files          21       22       +1     
  Lines        1540     1591      +51     
==========================================
+ Hits         1535     1586      +51     
  Misses          5        5              
Impacted Files Coverage Δ
src/LinearMaps.jl 100.00% <ø> (ø)
src/kronecker.jl 100.00% <100.00%> (ø)
src/trace.jl 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@dkarrasch dkarrasch merged commit 65eb422 into master Jul 6, 2023
@JeffFessler
Copy link
Member

The fallback code for general types might have been simpler if we allowed A[i,i] 🥲

@dkarrasch dkarrasch deleted the dk/trace branch July 31, 2023 19:00
@dkarrasch
Copy link
Member Author

True, but less efficient, because how would you reuse the canonical vector?

@dkarrasch
Copy link
Member Author

I wonder if we should have some kind of iterator for iterating all canonical vectors, though. Let me think about it...

@JeffFessler
Copy link
Member

Ah yes, fair point.

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.

2 participants