dimforge / nalgebra

Linear algebra library for Rust.
https://nalgebra.org
Apache License 2.0
3.96k stars 473 forks source link

Merge the hyperdual crate into nalgebra? #1047

Closed ChristopherRabotin closed 2 years ago

ChristopherRabotin commented 2 years ago

Would it be of interest to merge the hyperdual crate (code , crates.io) into nalgebra? It provides automatic differentiation and is currently used in the aerospace industry to that affect, so it has a pretty good level of testing.

I suspect this could be useful to nalgebra given the recent rise in the number of automatic differentiation crates (mostly for machine learning), and given that nalgebra now has dual quaternions (cf. #487).

I would be happy to do most of the work if I'm told where that crate best fits into nalgebra.

Andlon commented 2 years ago

Hi @ChristopherRabotin. I think hyperdual looks like a super useful crate, and I might find some use cases for it myself. That said, I have some concerns about increasing the scope of nalgebra beyond its current scope - which is already huge.

The "core focus" of nalgebra - in my opinion - is two-fold:

Dual quaternions - while relevant for automatic differentiation - is also at its core a geometric primitive. In fact, its primary use in nalgebra is precisely to aid in e.g. interpolating rigid body poses, a common problem in computer graphics.

Automatic differentiation is a pretty big field of its own, and I don't see any immediate benefits by adding these sorts of capabilities to nalgebra directly, since there's a clear one-way dependency: automatic differentiation may need to know about matrices and vectors, but general-purpose matrices and vectors do not need to concern themselves with automatic differentiation. It seems like exactly the kind of functionality that might reside in an external crate.

A bigger issue is that external crates that depend on nalgebra require constant maintenance to remain compatible. Since nalgebra generally makes frequent backwards-incompatible releases, it gets very difficult when a developer needs to inter-op between two dependencies that depend on two different versions of nalgebra. This is a pretty significant problem as the ecosystem of crates built on top of nalgebra grows. I think further discussion of this particular problem should continue in a separate issue, however.

ChristopherRabotin commented 2 years ago

Hi,

All that makes sense. Let's keep them separate.

Thanks for the detailed answer.

On Thu, Dec 30, 2021, 10:29 Andreas Borgen Longva @.***> wrote:

Hi @ChristopherRabotin https://github.com/ChristopherRabotin. I think hyperdual looks like a super useful crate, and I might find some use cases for it myself. That said, I have some concerns about increasing the scope of nalgebra beyond its current scope - which is already huge.

The "core focus" of nalgebra - in my opinion - is two-fold:

  • linear algebra
  • geometric primitives, primarily for computer graphics & physics

Dual quaternions - while relevant for automatic differentiation - is also at its core a geometric primitive. In fact, its primary use in nalgebra is precisely to aid in e.g. interpolating rigid body poses, a common problem in computer graphics.

Automatic differentiation is a pretty big field of its own, and I don't see any immediate benefits by adding these sorts of capabilities to nalgebra directly, since there's a clear one-way dependency: automatic differentiation may need to know about matrices and vectors, but general-purpose matrices and vectors do not need to concern themselves with automatic differentiation. It seems like exactly the kind of functionality that might reside in an external crate.

A bigger issue is that external crates that depend on nalgebra require constant maintenance to remain compatible. Since nalgebra generally makes frequent backwards-incompatible releases, it gets very difficult when a developer needs to inter-op between two dependencies that depend on two different versions of nalgebra. This is a pretty significant problem as the ecosystem of crates built on top of nalgebra grows. I think further discussion of this particular problem should continue in a separate issue, however.

— Reply to this email directly, view it on GitHub https://github.com/dimforge/nalgebra/issues/1047#issuecomment-1002944133, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABEZV2FFEIO26D4IPZYCPVTUTQRA5ANCNFSM5J67ALDQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

sebcrozet commented 2 years ago

I agree by the point made by @Andlon. Automatic differentiation is it’s own field which deserves it’s own crate(s). Thank you for the proposal though @ChristopherRabotin!