Repository: bluss/rust-ndarray
Pull request #193 (2016-04-27 14:18:50)

Use num-traits / num-complex explicitly


Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 3707217c..54196fa8 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,9 +22,12 @@ test = false
 [build-dependencies]
 rustc_version = "0.1.3"
 
-[dependencies.num]
+[dependencies.num-traits]
+version = "0.1.32"
+default-features = false
+
+[dependencies.num-complex]
 version = "0.1.32"
-features = ["complex"]
 default-features = false
 
 [dependencies.itertools]
diff --git a/examples/convo.rs b/examples/convo.rs
index 64abfb89..50a275d4 100644
--- a/examples/convo.rs
+++ b/examples/convo.rs
@@ -1,9 +1,9 @@
 #![allow(unused)]
 #[macro_use(s)]
 extern crate ndarray;
-extern crate num;
+extern crate num_traits;
 
-use num::Float;
+use num_traits::Float;
 
 use ndarray::{
     ArrayView,
diff --git a/examples/linalg.rs b/examples/linalg.rs
index 504b941f..358f537a 100644
--- a/examples/linalg.rs
+++ b/examples/linalg.rs
@@ -4,11 +4,12 @@
 //! purposes.
 
 extern crate ndarray;
-extern crate num as libnum;
+extern crate num_traits;
+extern crate num_complex;
 
-use libnum::{Num, zero, Zero, One};
-use libnum::Float;
-use libnum::Complex;
+use num_traits::{Num, Zero, One};
+use num_traits::Float;
+use num_complex::Complex;
 use std::ops::{Add, Sub, Mul, Div};
 
 use ndarray::{RcArray, Ix};
@@ -55,7 +56,7 @@ impl<A: LinalgScalar + Float +  Num> ComplexField for Complex<A>
 {
     #[inline]
     fn conjugate(self) -> Complex<A> { self.conj() }
-    fn sqrt_real(self) -> Complex<A> { Complex::new(self.re.sqrt(), zero()) }
+    fn sqrt_real(self) -> Complex<A> { Complex::new(self.re.sqrt(), A::zero()) }
     #[inline]
     fn is_complex() -> bool { true }
 }
@@ -208,7 +209,7 @@ pub fn least_squares<A: ComplexField>(a: &Mat<A>, b: &Col<A>) -> Col<A>
 /// Return L.
 pub fn cholesky<A: ComplexField>(a: Mat<A>) -> Mat<A>
 {
-    let z = zero::<A>();
+    let z = A::zero();
     let (m, n) = a.dim();
     assert!(m == n);
     // Perform the operation in-place on `a`
diff --git a/src/impl_ops.rs b/src/impl_ops.rs
index 1150777d..ca3c4f9b 100644
--- a/src/impl_ops.rs
+++ b/src/impl_ops.rs
@@ -7,7 +7,7 @@
 // except according to those terms.
 
 use std::any::Any;
-use libnum::Complex;
+use num_complex::Complex;
 
 /// Elements that can be used as direct operands in arithmetic with arrays.
 ///
@@ -218,7 +218,7 @@ mod arithmetic_ops {
     use imp_prelude::*;
 
     use std::ops::*;
-    use libnum::Complex;
+    use num_complex::Complex;
 
     impl_binary_op!(Add, +, add, +=, "addition");
     impl_binary_op!(Sub, -, sub, -=, "subtraction");
diff --git a/src/lib.rs b/src/lib.rs
index 8b69b214..ff32bb3b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -75,7 +75,8 @@ extern crate blas_sys;
 extern crate matrixmultiply;
 
 extern crate itertools;
-extern crate num as libnum;
+extern crate num_traits as libnum;
+extern crate num_complex;
 
 use std::rc::Rc;
 use std::slice::{self, Iter, IterMut};


Test patch:
diff --git a/tests/complex.rs b/tests/complex.rs
index 0cb483d5..01fbd44f 100644
--- a/tests/complex.rs
+++ b/tests/complex.rs
@@ -1,10 +1,12 @@
 
-extern crate num;
+extern crate num_traits;
+extern crate num_complex;
 extern crate ndarray;
 
 use ndarray::{arr1, arr2, Axis};
 use ndarray::OwnedArray;
-use num::{Num, Complex};
+use num_traits::Num;
+use num_complex::Complex;
 
 fn c<T: Clone + Num>(re: T, im: T) -> Complex<T> {
     Complex::new(re, im)
diff --git a/tests/oper.rs b/tests/oper.rs
index 29253674..5d8384af 100644
--- a/tests/oper.rs
+++ b/tests/oper.rs
@@ -1,5 +1,5 @@
 #[macro_use(s)] extern crate ndarray;
-extern crate num as libnum;
+extern crate num_traits;
 
 use ndarray::prelude::*;
 use ndarray::{arr0, rcarr1, rcarr2};
@@ -7,7 +7,7 @@ use ndarray::{LinalgScalar, Data};
 use ndarray::linalg::general_mat_mul;
 
 use std::fmt;
-use libnum::Float;
+use num_traits::Float;
 
 fn test_oper(op: &str, a: &[f32], b: &[f32], c: &[f32])
 {