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