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

Add nalgebra support #68

Merged
merged 19 commits into from
Aug 24, 2020

Conversation

Maher4Ever
Copy link
Contributor

This PR adds support for the nalgebra crate. This allows using static matrices with argmin. It also means that operations that panicked before now result in a compilation error (e.g., multiplying incompatible static matrices).

Not all math traits were implemented; only the ones that were implemented for ndarray are now implemented for nalgebra. A usage example was also added for the Gauss-Newton solver.

The implementations of argmin's math traits use a lof of generic code to support all the matrices provided by nalgebra (both static and dynamic ones). However, the disadvantage is that any change in nalgabra's definitions of matrices or the functions they support will break the implementations in argmin.

NB: Thank you for providing and maintaining such a great optimization crate with support for many solvers. It saved us a lot of time :)

Maher Sallam added 18 commits August 7, 2020 16:35
…nspose

When using static matrices, it must be possible to specify the result type of transposing a non-square matrix. For example, transposing a `na::Matrix6x2` would result in a `na::Matrix2x6` matrix.
The example uses dynamic matrices instead of static ones because `ArgminOp` only allows specifying the type of Jacobian/Hessian but not their transposes. Although it's possible to add 2 extra associated types for the transposes, it would be a breaking change; it's better to wait for when associated type defaults are stable.

Also, to get this working, the std::default::Default bound had to be removed from the solver's parameters because dynamic matrices in nalgebra don't implement it.
@stefan-k
Copy link
Member

Wow! This is amazing, thank you for this massive contribution!

However, the disadvantage is that any change in nalgabra's definitions of matrices or the functions they support will break the implementations in argmin.

That's probably a general problem of this approach. I'm open to any ideas that may improve this situation.
I've designed the math traits with ndarray and Vec in mind, which in some situations may be suboptimal for nalgebra. If you have suggestions for improvements please let me know.

I'm not sure, but I think the CI is failing because finitediff does not support nalgebra (yet).

I will try to give this a thorough review in the next couple of days.

Thanks again! :)

@Maher4Ever Maher4Ever force-pushed the feature/add-nalgebra-support branch from f406e2f to a851f02 Compare August 17, 2020 14:58
@Maher4Ever Maher4Ever force-pushed the feature/add-nalgebra-support branch from a851f02 to 884d04e Compare August 17, 2020 15:02
@Maher4Ever
Copy link
Contributor Author

@stefan-k You're more than welcome :)

The CI is failing because I accidentally committed an example I was working on that (indeed) isn't compiling due to finitediff not supporting nalgebra. I removed that example from the branch to solve the issue. Hopefully, the checks will succeed now.

Copy link
Member

@stefan-k stefan-k left a comment

Choose a reason for hiding this comment

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

Thanks again for your contribution! :)

@stefan-k stefan-k merged commit 57327d8 into argmin-rs:master Aug 24, 2020
@stefan-k stefan-k mentioned this pull request Aug 24, 2020
@Maher4Ever Maher4Ever deleted the feature/add-nalgebra-support branch February 9, 2021 14:30
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