Function russell_lab::check::array_approx_eq
source · pub fn array_approx_eq<T>(u: &[T], v: &[T], tol: f64)
Expand description
Panics if two arrays (vectors) are not approximately equal to each other
§Panics
- Will panic if the dimensions are different
- Will panic if NAN, INFINITY, or NEG_INFINITY is found
- Will panic if the absolute difference of components is greater than the tolerance
§Examples
§Accepts small error
use russell_lab::array_approx_eq;
fn main() {
let u = vec![3.0000001, 2.0];
let v = vec![3.0, 2.0];
array_approx_eq(&u, &v, 1e-6);
}
§Panics on different value
ⓘ
use russell_lab::array_approx_eq;
fn main() {
let u = vec![3.0000001, 2.0];
let v = vec![4.0, 2.0];
array_approx_eq(&u, &v, 1e-6);
}