Skip to content

Commit

Permalink
refactor: replace num dependency with num-traits (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
imrn99 authored May 30, 2024
1 parent c19fb8a commit e0c102c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ integraal-examples = { version = "0.0.2", path = "./examples" }
# external
rand = "0.9.0-alpha.1"
rustversion = "1.0.15"
num = "0.4.3"
num-traits = "0.2.19"
2 changes: 1 addition & 1 deletion integraal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ montecarlo = ["dep:rand"]
# DEPS

[dependencies]
num.workspace = true
num-traits.workspace = true
rand = { workspace = true, features = ["small_rng"], optional = true }

[build-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions integraal/src/structure/implementations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use crate::{
ComputeMethod, DomainDescriptor, FunctionDescriptor, Integraal, IntegraalError, Scalar,
};
use num::abs;
use std::ops::Deref;

// ------ CONTENT
Expand Down Expand Up @@ -76,7 +75,8 @@ impl<'a, X: Scalar> Integraal<'a, X> {
let step = args[idx] - args[idx - 1];
let y1 = vals[idx - 1];
let y2 = vals[idx];
(y1.min(y2) + abs(y1 - y2) / X::from_f32(2.0).unwrap()) * step
(y1.min(y2) + num_traits::abs(y1 - y2) / X::from_f32(2.0).unwrap())
* step
})
.sum(),
#[cfg(feature = "montecarlo")]
Expand Down
12 changes: 6 additions & 6 deletions integraal/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
pub trait Scalar:
Clone
+ Copy
+ num::Float
+ num::Signed
+ num::FromPrimitive
+ num_traits::Float
+ num_traits::Signed
+ num_traits::FromPrimitive
+ std::ops::Sub<Output = Self>
+ std::ops::Mul<Output = Self>
+ std::iter::Sum
Expand All @@ -18,9 +18,9 @@ pub trait Scalar:
impl<
X: Clone
+ Copy
+ num::Float
+ num::Signed
+ num::FromPrimitive
+ num_traits::Float
+ num_traits::Signed
+ num_traits::FromPrimitive
+ std::ops::Sub<Output = Self>
+ std::ops::Mul<Output = Self>
+ std::iter::Sum,
Expand Down

0 comments on commit e0c102c

Please sign in to comment.