diff --git a/src/lib.rs b/src/lib.rs index 9950f8c56..a99d6d52f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,7 +135,7 @@ use crate::iterators::{ElementsBase, ElementsBaseMut, Iter, IterMut, Lanes, Lane pub use crate::arraytraits::AsArray; #[cfg(feature = "std")] pub use crate::linalg_traits::NdFloat; -pub use crate::linalg_traits::{LinalgScalar, NdFloatCore}; +pub use crate::linalg_traits::LinalgScalar; pub use crate::stacking::{concatenate, stack, stack_new_axis}; diff --git a/src/linalg_traits.rs b/src/linalg_traits.rs index 50afefa52..43fe5f8d3 100644 --- a/src/linalg_traits.rs +++ b/src/linalg_traits.rs @@ -8,7 +8,7 @@ use crate::ScalarOperand; #[cfg(feature = "std")] use num_traits::Float; -use num_traits::{float::FloatCore, One, Zero}; +use num_traits::{One, Zero}; use std::fmt; use std::ops::{Add, Div, Mul, Sub}; use std::ops::{AddAssign, DivAssign, MulAssign, RemAssign, SubAssign}; @@ -73,31 +73,3 @@ impl NdFloat for f32 {} #[cfg(feature = "std")] impl NdFloat for f64 {} -/// A no_std floating-point element type represented by `f32` and `f64`. -/// -/// Trait `NdFloatCore` is only implemented for `f32` and `f64` and encompasses -/// much float-relevant ndarray functionality as possible, while working for no_std -/// code, including the traits needed for linear algebra and for *right hand side* scalar -/// operations (`ScalarOperand`). -/// -/// This trait can only be implemented by `f32` and `f64`. -pub trait NdFloatCore: - FloatCore - + AddAssign - + SubAssign - + MulAssign - + DivAssign - + RemAssign - + fmt::Display - + fmt::Debug - + fmt::LowerExp - + fmt::UpperExp - + ScalarOperand - + LinalgScalar - + Send - + Sync -{ -} - -impl NdFloatCore for f32 {} -impl NdFloatCore for f64 {} diff --git a/src/prelude.rs b/src/prelude.rs index 7789ab5c4..e25e52175 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -51,7 +51,7 @@ pub use crate::{array, azip, s}; pub use crate::ShapeBuilder; #[doc(no_inline)] -pub use crate::{AsArray, NdFloatCore}; +pub use crate::AsArray; #[doc(no_inline)] #[cfg(feature = "std")] diff --git a/tests/oper.rs b/tests/oper.rs index b3655d454..7193a49da 100644 --- a/tests/oper.rs +++ b/tests/oper.rs @@ -10,6 +10,7 @@ use ndarray::prelude::*; use ndarray::{rcarr1, rcarr2}; use ndarray::{Data, LinalgScalar}; use ndarray::{Ix, Ixs}; +use num_traits::Zero; use std::iter::FromIterator; use approx::assert_abs_diff_eq; @@ -33,18 +34,9 @@ fn test_oper(op: &str, a: &[f32], b: &[f32], c: &[f32]) { test_oper_arr::(op, aa.clone(), bb.clone(), cc.clone()); } -#[cfg(feature = "std")] -trait TestFloat: NdFloat {} -#[cfg(not(feature = "std"))] -trait TestFloat: NdFloatCore {} - -impl TestFloat for f32 {} - -fn test_oper_arr(op: &str, mut aa: ArcArray, bb: ArcArray, cc: ArcArray) +fn test_oper_arr(op: &str, mut aa: ArcArray, bb: ArcArray, cc: ArcArray) where - A: TestFloat, - for<'a> &'a A: Neg, D: Dimension, { match op { @@ -155,17 +147,16 @@ fn scalar_operations() { } } -fn reference_dot<'a, A, V1, V2>(a: V1, b: V2) -> A +fn reference_dot<'a, V1, V2>(a: V1, b: V2) -> f32 where - A: TestFloat, - V1: AsArray<'a, A>, - V2: AsArray<'a, A>, + V1: AsArray<'a, f32>, + V2: AsArray<'a, f32>, { let a = a.into(); let b = b.into(); a.iter() .zip(b.iter()) - .fold(A::zero(), |acc, (&x, &y)| acc + x * y) + .fold(f32::zero(), |acc, (&x, &y)| acc + x * y) } #[test]