Skip to content

Conversation

@kshyatt
Copy link
Member

@kshyatt kshyatt commented Aug 7, 2025

Tried this as a way to learn about the structure of the package, so please feel free to aggressively critique it :).

I've added supported for generalized eigendecomposition over two inputs, A and B. All this arose out of a desire to add coverage to the ggev methods. I fixed some errors in the ccall wrapper and tried to implement the interface in a semi-reasonable way. Annoyingly, LAPACK doesn't provide the support for LAPACK_Expert for this...

@kshyatt kshyatt requested a review from Jutho August 7, 2025 12:58
@codecov
Copy link

codecov bot commented Aug 7, 2025

Codecov Report

❌ Patch coverage is 98.61111% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/algorithms.jl 94.44% 2 Missing ⚠️
Files with missing lines Coverage Δ
src/MatrixAlgebraKit.jl 100.00% <ø> (ø)
src/common/gauge.jl 100.00% <100.00%> (ø)
src/implementations/eig.jl 100.00% <100.00%> (ø)
src/implementations/gen_eig.jl 100.00% <100.00%> (ø)
src/interface/eig.jl 83.33% <ø> (+20.83%) ⬆️
src/interface/gen_eig.jl 100.00% <100.00%> (ø)
src/yalapack.jl 71.67% <100.00%> (+4.56%) ⬆️
src/algorithms.jl 87.38% <94.44%> (+6.89%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

Overall looks really good to me, and definitely in the same style as the rest so I think you nailed it!

I like the generalization of the macro to multiple arguments. Given that we only have a single keyword supported and this is mostly an internal thing anyways, I would even be fine with dropping the specification altogether: @functiondef 2 f seems also good to me. This ultimately doesn't really matter though so I have no strong opinions here.

As an alternative, an idea that might also work is to simply bundle the arguments together: gen_eig!((A, B), ...) might actually require less work for altering the rest of the functionality, but I'm not sure if it is that much more convenient, nor easy to remember/read etc. Just wanted to share the idea, definitely feel free to let me know what you think about it because I'm not convinced it is better.

For the distinction between gen_eig and gen_eig_full, I assume this is because for eig and eig_full we have a similar function laying around somewhere. I think this is an idea that made it in at some point and was never properly worked out, I'm not sure if we really need both (I would personally prefer if we could get rid of one of them even).
For eig, we only export the eig_full variants, so I would say to do the same here, and at some point just remove eig etc altogether?

end
end

function _reorder_realeigendecomposition!(W, WR, WI, Wbeta, work, VR, jobvr)
Copy link
Member

Choose a reason for hiding this comment

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

Possibly can use inbounds annotations in this function, not sure if this matters?

Copy link
Member Author

Choose a reason for hiding this comment

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

It might for large arrays

@kshyatt
Copy link
Member Author

kshyatt commented Aug 8, 2025

As an alternative, an idea that might also work is to simply bundle the arguments together: gen_eig!((A, B), ...) might actually require less work for altering the rest of the functionality, but I'm not sure if it is that much more convenient, nor easy to remember/read etc. Just wanted to share the idea, definitely feel free to let me know what you think about it because I'm not convinced it is better.

Indeed I think the same result might be achievable with a little more type specification on the arguments and making them a Vararg{AbstractVecOrMat, N} or NTuple{N, AbstractVecOrMat} or somesuch, which would remove the need for the macro kwarg. Happy to give that a spin if anyone would like.

Copy link
Member

@lkdvos lkdvos left a comment

Choose a reason for hiding this comment

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

Nice! I would prefer to use the ! for the gaugefix function because it is in-place, otherwise good to go for me!

kshyatt and others added 3 commits August 13, 2025 14:43
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
Co-authored-by: Lukas Devos <ldevos98@gmail.com>
@kshyatt kshyatt enabled auto-merge (squash) August 13, 2025 12:43
@kshyatt kshyatt merged commit a8d9401 into main Aug 13, 2025
10 checks passed
@kshyatt kshyatt deleted the ksh/gen_eig branch August 13, 2025 13:11
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.

4 participants