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

Less strong trait bounds for algorithms #1474

Open
jbirnick opened this issue Jan 14, 2025 · 2 comments
Open

Less strong trait bounds for algorithms #1474

jbirnick opened this issue Jan 14, 2025 · 2 comments

Comments

@jbirnick
Copy link

jbirnick commented Jan 14, 2025

Hello, I would like to use nalgebra for my project, however one thing that prevents me from that (and which also confuses me) is that all the e.g. matrix algorithms (QR, SVD, ...) require the base type to implement ComplexField.

But this trait is huge, requiring to implement sin, exp, acosh and what not. It also has a lot of supertraits. I guess those linear algebra algorithms never use those trigonometric methods, also also don't need all the supertraits, so why are the requirements so strong? Couldn't there be a trait with less strong requirements?

I want to use nalgebra together with arbitrary-precision floats, like the ones from rug. I would argue this is a quite common/important use case, but the huge trait ComplexField which is difficult to implement poses a significant barrier for that.

Other people had the same problem: https://stackoverflow.com/questions/73871027/use-nalgebra-with-float-types-from-rug

@Ralith
Copy link
Collaborator

Ralith commented Jan 15, 2025

Requiring only the exact operations used has other drawbacks: it leads to more complex trait bounds, slower compilation, and leaks implementation details in a way that is highly prone to breaking changes. Perhaps there's a sweet spot in between somewhere (promising not to use hyperbolic trigonometry in most algorithms probably isn't a maintenance hazard), but some careful analysis and design would be required to capitalize on that.

@jbirnick
Copy link
Author

jbirnick commented Jan 15, 2025

Yeah I think a sweet spot without trigonometry would be great.

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

No branches or pull requests

2 participants