Last active
June 26, 2018 20:07
-
-
Save czotti/aa59044dfc1c7d85f3358a9d2fd6b400 to your computer and use it in GitHub Desktop.
Cargo run with approx for a slice of Complex
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[package] | |
name = "approx" | |
version = "0.1.0" | |
authors = ["Clément Zotti <clement.zotti@imeka.ca>"] | |
[dependencies] | |
ndarray = ">=0.10.12,<0.12.0" | |
num = "0.1" | |
[dependencies.approx] | |
version = "0.2" | |
features = ["use_complex"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[macro_use] extern crate approx; | |
extern crate ndarray; | |
extern crate num; | |
use num::complex::Complex; | |
use ndarray::arr2; | |
fn main() { | |
let sh = arr2(&[ | |
[Complex::new(0.28205, 0.0), | |
Complex::new(0.38415, 0.04054)], | |
[Complex::new(0.28205, 0.0), | |
Complex::new(0.38135, 0.05154)], | |
[Complex::new(0.28205, 0.0), | |
Complex::new(0.38095, 0.00784)]]); | |
let gt = arr2(&[ | |
[Complex::new(0.28207, 0.0), | |
Complex::new(0.38417, 0.04056)], | |
[Complex::new(0.28207, 0.0), | |
Complex::new(0.38137, 0.05156)], | |
[Complex::new(0.28207, 0.0), | |
Complex::new(0.38097, 0.00786)]]); | |
assert_relative_eq!([1.0f32, 4.01f32][..], [1.0f32, 4.01f32][..]); | |
assert_relative_eq!(Complex::new(0.2, 0.1), Complex::new(0.2, 0.1)); | |
assert_relative_eq!(&sh.as_slice().unwrap(), >.as_slice().unwrap()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment