Skip to main content

hypot

Function hypot 

Source
pub fn hypot(x: &[f64]) -> f64
Expand description

§hypot(x)

Geometric Function

The hypot function calculates the Euclidean norm (also known as the magnitude or length) of a vector in n-dimensional space.

§Examples

use mathlab::math::{hypot, INF_F64 as inf, is_nan_f64 as is_nan};
assert_eq!(hypot(&[0.0]), 0.0);
assert_eq!(hypot(&[1.0]), 1.0);
assert_eq!(hypot(&[1.0 / 0.0]), inf);
assert!(is_nan(hypot(&[0.0 / 0.0])));
assert_eq!(hypot(&[4.0]), 4.0);
assert_eq!(hypot(&[3.0, 4.0]), 5.0);
assert_eq!(hypot(&[4.0, 2.0, 4.0]), 6.0);
assert_eq!(hypot(&[-3.0, -4.0]), 5.0);
assert_eq!(hypot(&[-4.0]), 4.0);

End Fun Doc