Merge pull request #105 from atheriel/vec_ops
Actually implement division, remainder, and index operators for vectors.
This commit is contained in:
commit
f5cb1fb8e4
1 changed files with 20 additions and 0 deletions
|
@ -203,10 +203,30 @@ macro_rules! vec(
|
|||
#[inline] fn mul(&self, v: &$Self<S>) -> $Self<S> { self.mul_v(v) }
|
||||
}
|
||||
|
||||
impl<S: BaseNum> Div<$Self<S>, $Self<S>> for $Self<S> {
|
||||
#[inline] fn div(&self, v: &$Self<S>) -> $Self<S> { self.div_v(v) }
|
||||
}
|
||||
|
||||
impl<S: BaseNum> Rem<$Self<S>, $Self<S>> for $Self<S> {
|
||||
#[inline] fn rem(&self, v: &$Self<S>) -> $Self<S> { self.rem_v(v) }
|
||||
}
|
||||
|
||||
impl<S: BaseNum> One for $Self<S> {
|
||||
#[inline] fn one() -> $Self<S> { $Self::from_value(one()) }
|
||||
}
|
||||
|
||||
impl<S: BaseNum> Index<uint, S> for $Self<S> {
|
||||
#[inline]
|
||||
fn index<'a>(&'a self, index: &uint) -> &'a S {
|
||||
let slice: &[S, ..$n] = unsafe { mem::transmute(self) };
|
||||
&slice[*index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: BaseNum> IndexMut<uint, S> for $Self<S> {
|
||||
#[inline] fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut S { self.mut_i(*index) }
|
||||
}
|
||||
|
||||
impl<S: BaseFloat> ApproxEq<S> for $Self<S> {
|
||||
#[inline]
|
||||
fn approx_eq_eps(&self, other: &$Self<S>, epsilon: &S) -> bool {
|
||||
|
|
Loading…
Reference in a new issue