-
Notifications
You must be signed in to change notification settings - Fork 8
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
Implement field and other numeric traits from alga. #16
Comments
In general, Decorum takes on the burden of implementing traits in the Rust ecosystem for its types. Are there specific traits that you think should be implemented? |
I need the traits from approx as well as ComplexField and RealField from alga (which for its part requires approx's UlpsEq. Here are the full definitions:
I think implementing approx is doable. E.g. by defining a feature in the toml, plugging the following in lib.rs:
and the following in proxy.rs
nalgebra on the other hand I don't know how to implement, because (aside from my problems understanding the logic of nalgebra) it seems to require implementors of ComplexField to also declare they can do (logically) everything that f64 can do, which is exactly what I don't want, when I'm using R64 or F64, see my alga issue. |
Thanks for the details! This is reminiscent of problems mentioned in #10 and a related issue I opened against It's not entirely clear to me where these trait implementations should live, but at first glance it seems appropriate for |
Support for |
Other crates like approx and alga (used by nalgebra) define traits and implement them for native floating point numbers. They do use generics, so that Decorums numbers can be used. Some of their functionality isn't available though with Decorum's numbers, as their traits are not implemented for Decorums numbers.
Due to Rust's Orphan Rule users of Decorum and those libraries cannot implement the other libraries' traits for their use of Decorum. Either the libraries declaring the traits or Decorum must implement them. What strategy does Decorum use for implementing foreign traits? What dependency hierarchy should be created? Should those libraries depend on Decorum or should Decorum depend on those libraries?
I can imagine creating features in Decorum for use with well known libraries, like the above mentioned, might work.
The text was updated successfully, but these errors were encountered: