-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Migrate over to num crate #80
Comments
Yes I've wanted to use the If you want to use |
Opened #81 with refactoring of https://github.com/avhz/RustQuant/blob/main/src/utilities/sequence.rs |
Disclaimer: I'm not a math wiz at all. So my understanding might be lacking. use num::traits::{One, Zero};
// other parts of your code...
impl<'v> Zero for Variable<'v> {
fn zero() -> Self {
Variable {
graph: &Graph::new(), // you need to provide a way to get a default graph
index: 0, // assuming 0 is a sensible default index
value: 0.0,
}
}
fn is_zero(&self) -> bool {
self.value == 0.0
}
}
impl<'v> One for Variable<'v> {
fn one() -> Self {
Variable {
graph: &Graph::new(), // you need to provide a way to get a default graph
index: 0, // assuming 0 is a sensible default index
value: 1.0,
}
}
fn is_one(&self) -> bool {
self.value == 1.0
}
} |
How is this @Uzaaft? It seems like a good idea. Any way I can help? |
Checking in again |
There's a lot of code where methods are implemented on different type of numbers(f64, i64, u64, f32, etc...)
Example of file: https://github.com/avhz/RustQuant/blob/main/src/utilities/sequence.rs
Wouldn't it make sense to reduce the amount of code by adding some library, like https://github.com/rust-num/num, that has a collection of numeric types and traits which could be used.
The text was updated successfully, but these errors were encountered: