From 10f2b9b0b1958811617705e924adb28a1a2ca771 Mon Sep 17 00:00:00 2001 From: Brendan Zabarauskas Date: Mon, 26 Nov 2012 00:49:26 +1000 Subject: [PATCH] Remove generic type from pow method --- src/funs/exp.rs | 82 ++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/src/funs/exp.rs b/src/funs/exp.rs index 028f302..179f5ec 100644 --- a/src/funs/exp.rs +++ b/src/funs/exp.rs @@ -5,7 +5,7 @@ use num::cast::*; use vec::{Vec2, Vec3, Vec4}; pub trait Exp { - pure fn pow(n: &N) -> self; + pure fn pow(n: &self) -> self; pure fn exp() -> self; pure fn log_() -> self; pure fn exp2() -> self; @@ -14,49 +14,49 @@ pub trait Exp { pure fn inv_sqrt() -> self; } -#[inline(always)] pub pure fn pow(x: &T, n: &N) -> T { x.pow(n) } -#[inline(always)] pub pure fn exp(x: &T) -> T { x.exp() } -#[inline(always)] pub pure fn log_(x: &T) -> T { x.log_() } -#[inline(always)] pub pure fn exp2(x: &T) -> T { x.exp2() } -#[inline(always)] pub pure fn log2(x: &T) -> T { x.log2() } -#[inline(always)] pub pure fn sqrt(x: &T) -> T { x.sqrt() } -#[inline(always)] pub pure fn inv_sqrt(x: &T) -> T { x.inv_sqrt() } +#[inline(always)] pub pure fn pow(x: &T, n: &T) -> T { x.pow(n) } +#[inline(always)] pub pure fn exp(x: &T) -> T { x.exp() } +#[inline(always)] pub pure fn log_(x: &T) -> T { x.log_() } +#[inline(always)] pub pure fn exp2(x: &T) -> T { x.exp2() } +#[inline(always)] pub pure fn log2(x: &T) -> T { x.log2() } +#[inline(always)] pub pure fn sqrt(x: &T) -> T { x.sqrt() } +#[inline(always)] pub pure fn inv_sqrt(x: &T) -> T { x.inv_sqrt() } pub impl f32: Exp { - #[inline(always)] pure fn pow(n: &N) -> f32 { cast(cmath::c_float_utils::pow(self, n.cast())) } - #[inline(always)] pure fn exp() -> f32 { cast(cmath::c_float_utils::exp(self)) } - #[inline(always)] pure fn log_() -> f32 { cast(cmath::c_float_utils::ln(self)) } - #[inline(always)] pure fn exp2() -> f32 { cast(cmath::c_float_utils::exp2(self)) } - #[inline(always)] pure fn log2() -> f32 { cast(cmath::c_float_utils::log2(self)) } - #[inline(always)] pure fn sqrt() -> f32 { cast(cmath::c_float_utils::sqrt(self)) } - #[inline(always)] pure fn inv_sqrt() -> f32 { 1f32 / self.sqrt() } // TODO: optimise? need a wizard + #[inline(always)] pure fn pow(n: &f32) -> f32 { cast(cmath::c_float_utils::pow(self, n.cast())) } + #[inline(always)] pure fn exp() -> f32 { cast(cmath::c_float_utils::exp(self)) } + #[inline(always)] pure fn log_() -> f32 { cast(cmath::c_float_utils::ln(self)) } + #[inline(always)] pure fn exp2() -> f32 { cast(cmath::c_float_utils::exp2(self)) } + #[inline(always)] pure fn log2() -> f32 { cast(cmath::c_float_utils::log2(self)) } + #[inline(always)] pure fn sqrt() -> f32 { cast(cmath::c_float_utils::sqrt(self)) } + #[inline(always)] pure fn inv_sqrt() -> f32 { 1f32 / self.sqrt() } // TODO: optimise? need a wizard } pub impl f64: Exp { - #[inline(always)] pure fn pow(n: &N) -> f64 { cast(cmath::c_double_utils::pow(self, n.cast())) } - #[inline(always)] pure fn exp() -> f64 { cast(cmath::c_double_utils::exp(self)) } - #[inline(always)] pure fn log_() -> f64 { cast(cmath::c_double_utils::ln(self)) } - #[inline(always)] pure fn exp2() -> f64 { cast(cmath::c_double_utils::exp2(self)) } - #[inline(always)] pure fn log2() -> f64 { cast(cmath::c_double_utils::log2(self)) } - #[inline(always)] pure fn sqrt() -> f64 { cast(cmath::c_double_utils::sqrt(self)) } - #[inline(always)] pure fn inv_sqrt() -> f64 { 1f64 / self.sqrt() } // TODO: optimise? need a wizard + #[inline(always)] pure fn pow(n: &f64) -> f64 { cast(cmath::c_double_utils::pow(self, n.cast())) } + #[inline(always)] pure fn exp() -> f64 { cast(cmath::c_double_utils::exp(self)) } + #[inline(always)] pure fn log_() -> f64 { cast(cmath::c_double_utils::ln(self)) } + #[inline(always)] pure fn exp2() -> f64 { cast(cmath::c_double_utils::exp2(self)) } + #[inline(always)] pure fn log2() -> f64 { cast(cmath::c_double_utils::log2(self)) } + #[inline(always)] pure fn sqrt() -> f64 { cast(cmath::c_double_utils::sqrt(self)) } + #[inline(always)] pure fn inv_sqrt() -> f64 { 1f64 / self.sqrt() } // TODO: optimise? need a wizard } pub impl float: Exp { - #[inline(always)] pure fn pow(n: &N) -> float { cast(cmath::c_float_utils::pow(cast(self), n.cast())) } - #[inline(always)] pure fn exp() -> float { cast(cmath::c_float_utils::exp(cast(self))) } - #[inline(always)] pure fn log_() -> float { cast(cmath::c_float_utils::ln(cast(self))) } - #[inline(always)] pure fn exp2() -> float { cast(cmath::c_float_utils::exp2(cast(self))) } - #[inline(always)] pure fn log2() -> float { cast(cmath::c_float_utils::log2(cast(self))) } - #[inline(always)] pure fn sqrt() -> float { cast(cmath::c_float_utils::sqrt(cast(self))) } - #[inline(always)] pure fn inv_sqrt() -> float { 1f / self.sqrt() } // TODO: optimise? need a wizard + #[inline(always)] pure fn pow(n: &float) -> float { cast(cmath::c_float_utils::pow(cast(self), n.cast())) } + #[inline(always)] pure fn exp() -> float { cast(cmath::c_float_utils::exp(cast(self))) } + #[inline(always)] pure fn log_() -> float { cast(cmath::c_float_utils::ln(cast(self))) } + #[inline(always)] pure fn exp2() -> float { cast(cmath::c_float_utils::exp2(cast(self))) } + #[inline(always)] pure fn log2() -> float { cast(cmath::c_float_utils::log2(cast(self))) } + #[inline(always)] pure fn sqrt() -> float { cast(cmath::c_float_utils::sqrt(cast(self))) } + #[inline(always)] pure fn inv_sqrt() -> float { 1f / self.sqrt() } // TODO: optimise? need a wizard } pub impl Vec2: Exp { #[inline(always)] - pure fn pow(n: &N) -> Vec2 { - Vec2::new(pow(&self[0], n), - pow(&self[1], n)) + pure fn pow(n: &Vec2) -> Vec2 { + Vec2::new(pow(&self[0], &n[0]), + pow(&self[1], &n[1])) } #[inline(always)] @@ -98,10 +98,10 @@ pub impl Vec2: Exp { pub impl Vec3: Exp { #[inline(always)] - pure fn pow(n: &N) -> Vec3 { - Vec3::new(pow(&self[0], n), - pow(&self[1], n), - pow(&self[2], n)) + pure fn pow(n: &Vec3) -> Vec3 { + Vec3::new(pow(&self[0], &n[0]), + pow(&self[1], &n[1]), + pow(&self[2], &n[2])) } #[inline(always)] @@ -149,11 +149,11 @@ pub impl Vec3: Exp { pub impl Vec4: Exp { #[inline(always)] - pure fn pow(n: &N) -> Vec4 { - Vec4::new(pow(&self[0], n), - pow(&self[1], n), - pow(&self[2], n), - pow(&self[3], n)) + pure fn pow(n: &Vec4) -> Vec4 { + Vec4::new(pow(&self[0], &n[0]), + pow(&self[1], &n[1]), + pow(&self[2], &n[2]), + pow(&self[3], &n[3])) } #[inline(always)]