use na::{Real, DefaultAllocator}; use aliases::Vec; use traits::{Alloc, Dimension}; /// Componentwise exponential. pub fn exp(v: &Vec) -> Vec where DefaultAllocator: Alloc { v.map(|x| x.exp()) } /// Componentwise base-2 exponential. pub fn exp2(v: &Vec) -> Vec where DefaultAllocator: Alloc { v.map(|x| x.exp2()) } /// Compute the inverse of the square root of each component of `v`. pub fn inversesqrt(v: &Vec) -> Vec where DefaultAllocator: Alloc { v.map(|x| N::one() / x.sqrt()) } /// Componentwise logarithm. pub fn log(v: &Vec) -> Vec where DefaultAllocator: Alloc { v.map(|x| x.ln()) } /// Componentwise base-2 logarithm. pub fn log2(v: &Vec) -> Vec where DefaultAllocator: Alloc { v.map(|x| x.log2()) } /// Componentwise power. pub fn pow(base: &Vec, exponent: &Vec) -> Vec where DefaultAllocator: Alloc { base.zip_map(exponent, |b, e| b.powf(e)) } /// Componentwise square root. pub fn sqrt(v: &Vec) -> Vec where DefaultAllocator: Alloc { v.map(|x| x.sqrt()) }