Skip to content

Start adding support for matrix functions #135

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

Merged
merged 10 commits into from
Jun 6, 2025
Merged

Start adding support for matrix functions #135

merged 10 commits into from
Jun 6, 2025

Conversation

mtfishman
Copy link
Member

@mtfishman mtfishman commented Jun 6, 2025

Start adding support for matrix functions such as exp(A), cos(A), inv(A), etc. on square block diagonal matrices. The operations are applied to the diagonal blocks. Care is taken to instantiate unstored diagonal blocks in case they are nontrivial (or even if they remain zero they get instantiated for simplicity).

Matrix functions supported by Julia can be found:

The strategy to handle this generically is to use Base.promote_op to use type inference on the block type of the input block sparse matrix to determine the block type of the output. A number of operations are broken right now because the LinearAlgebra.jl dense implementations are type unstable, I'll look into fixing those manually. Maybe we can provide an interface like initialize_output(f, A) (inspired by MatrixAlgebraKit.initialize_output) for customizing/specifying the output type. It can default to Base.promote_op. This issue is fixed by introducing initialize_output_blocksparse(f, A), which defaults to Base.promote_op but then uses similartype in cases that are type unstable.

Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.15%. Comparing base (81003b1) to head (82f7c13).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #135      +/-   ##
==========================================
+ Coverage   74.84%   75.15%   +0.31%     
==========================================
  Files          35       35              
  Lines        1749     1771      +22     
==========================================
+ Hits         1309     1331      +22     
  Misses        440      440              
Flag Coverage Δ
docs 6.44% <0.00%> (-0.09%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mtfishman mtfishman merged commit 6be3e32 into main Jun 6, 2025
19 checks passed
@mtfishman mtfishman deleted the mf/matrix_funcs branch June 6, 2025 20:20
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.

1 participant