Commit 5875b39d authored by Egor Larionov's avatar Egor Larionov

update dependencies

parent 72801312
......@@ -4,9 +4,9 @@ version = "0.1.0"
authors = ["Egor Larionov <[email protected]>"]
[dependencies]
num-traits = "0.1"
num-traits = "0.2"
nalgebra = "*"
[dev-dependencies]
approx = "0.1"
rand = "0.3"
rand = "0.5"
......@@ -19,28 +19,26 @@ fn simple_test() {
#[test]
fn random_test() {
use self::rand::{SeedableRng, StdRng};
use self::rand::distributions::{IndependentSample, Range};
use self::rand::{Rng, SeedableRng, StdRng, distributions::Uniform};
let seed: &[_] = &[1,2,3,4];
let seed = [3; 32];
let mut rng: StdRng = SeedableRng::from_seed(seed);
let range = Range::new(-1.0, 1.0);
let range = Uniform::new(-1.0, 1.0);
for _ in 0..99 {
let t = range.ind_sample(&mut rng);
let t = rng.sample(range);
assert_eq!(diff(|x| Float::exp(-x*x/cst(2.0)), t), -t*Float::exp(-t*t/2.0));
}
}
#[test]
fn grad_test() {
use self::rand::{SeedableRng, StdRng};
use self::rand::distributions::{IndependentSample, Range};
use self::rand::{Rng, SeedableRng, StdRng, distributions::Uniform};
let seed: &[_] = &[1,2,3,4];
let seed = [3; 32];
let mut rng: StdRng = SeedableRng::from_seed(seed);
let range = Range::new(-1.0, 1.0);
let range = Uniform::new(-1.0, 1.0);
for _ in 0..99 {
let t = vec![range.ind_sample(&mut rng), range.ind_sample(&mut rng)];
let t = vec![rng.sample(range), rng.sample(range)];
let expected = vec![-0.5*t[1]*Float::exp(-t[0]*t[1]/2.0), -0.5*t[0]*Float::exp(-t[0]*t[1]/2.0)];
assert_eq!(grad(|x| Float::exp(-x[0]*x[1]/cst(2.0)), t), expected);
}
......
......@@ -113,16 +113,15 @@ fn test_hrbf_derivative_simple<K: Kernel<f64> + Default>(order: usize) {
}
fn test_hrbf_derivative_random<K: Kernel<f64> + Default>(order: usize) {
use self::rand::{SeedableRng, StdRng};
use self::rand::distributions::{IndependentSample, Range};
use self::rand::{Rng, SeedableRng, StdRng, distributions::Uniform};
let seed: &[_] = &[1,2,3,4];
let mut rng: StdRng = SeedableRng::from_seed(seed);
let range = Range::new(-1.0, 1.0);
let seed = [3u8;32];
let mut rng = StdRng::from_seed(seed);
let range = Uniform::new(-1.0, 1.0);
for _ in 0..99 {
let x = Point3::new(range.ind_sample(&mut rng),
range.ind_sample(&mut rng),
range.ind_sample(&mut rng));
let x = Point3::new(rng.sample(range),
rng.sample(range),
rng.sample(range));
test_derivative_fd::<_,K>(x, rel_compare, order);
}
}
......
......@@ -49,14 +49,13 @@ fn test_kernel_simple<K: Kernel<Num> + Copy>(kern: K) {
}
fn test_kernel_random<K: Kernel<Num> + Copy>(kern: K) {
use self::rand::{SeedableRng, StdRng};
use self::rand::distributions::{IndependentSample, Range};
use self::rand::{Rng, SeedableRng, StdRng, distributions::Uniform};
let seed: &[_] = &[1,2,3,4];
let mut rng: StdRng = SeedableRng::from_seed(seed);
let range = Range::new(-1.0, 1.0);
let seed = [3; 32];
let mut rng = StdRng::from_seed(seed);
let range = Uniform::new(-1.0, 1.0);
for _ in 0..999 {
let x = range.ind_sample(&mut rng);
let x = rng.sample(range);
test_kernel(kern, x, rel_compare);
}
}
......@@ -66,7 +65,7 @@ fn ulp_compare(a: f64, b: f64) {
}
fn rel_compare(a: f64, b: f64) {
assert_relative_eq!(a,b, max_relative=1e-13, epsilon=1e-14);
assert_relative_eq!(a,b, max_relative=1e-12, epsilon=1e-14);
}
#[test]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment