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

Make trait bounds for sparse arithmetic operations more deliberate #880

Open
Andlon opened this issue Apr 29, 2021 · 0 comments
Open

Make trait bounds for sparse arithmetic operations more deliberate #880

Andlon opened this issue Apr 29, 2021 · 0 comments
Labels
enhancement nalgebra-sparse Issues about the nalgebra-sparse crate.

Comments

@Andlon
Copy link
Collaborator

Andlon commented Apr 29, 2021

Currently, the necessary trait bounds for methods in nalgebra_sparse::ops and implementations of e.g. Add, Mul and so on are somewhat arbitrary. The issue here is that we'd like to be able to use generalized operations from nalgebra_sparse::ops in the Add/Mul etc. operations, so that optimization efforts can be focused on the free-standing functions. However, by necessity, these functions need both Add, Sub and so on, which means that Add(Csr, Csr) needs T: Sub.

Trait bounds are not only about what operations are needed right now, but due to forward compatibility concerns, we also need to take into account what we might need in the future. Therefore I propose to simplify trait bounds by introducing a trait, perhaps called Number, which is intended to encompass integers and floating-point numbers. Number would corresponds to typical arithmetic operations, such as addition, multiplication, subtraction and division. However, it does not provide a multiplicative inverse like RealField.

We could consider having this trait in nalgebra proper and recommend it as a generic trait bound to use whenever you want to abstract over integers and floating-point numbers. This needs more discussion, however.

@Andlon Andlon added the nalgebra-sparse Issues about the nalgebra-sparse crate. label Apr 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement nalgebra-sparse Issues about the nalgebra-sparse crate.
Projects
None yet
Development

No branches or pull requests

1 participant