From a2848e6e185498d39a830741bbad4b530fa3a4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Thu, 6 Nov 2014 14:20:59 +0100 Subject: [PATCH] Update to the last rust-nightly. Version of rustc: 0.13.0-nightly (63c4f22f2 2014-11-05 22:31:44 +0000). --- benches/mat.rs | 1 - benches/vec.rs | 1 - src/structs/dmat.rs | 8 ++++---- src/structs/dvec_macros.rs | 12 ++++++------ src/structs/iso_macros.rs | 10 +++++----- src/structs/quat.rs | 2 +- src/structs/rot_macros.rs | 8 ++++---- src/structs/spec/vec0.rs | 4 ++-- src/structs/vec.rs | 8 +++++++- src/structs/vec_macros.rs | 17 ++++++++++++++--- tests/vec.rs | 2 +- 11 files changed, 44 insertions(+), 29 deletions(-) diff --git a/benches/mat.rs b/benches/mat.rs index 7d4d66ba..2f55246a 100644 --- a/benches/mat.rs +++ b/benches/mat.rs @@ -1,6 +1,5 @@ #![feature(macro_rules)] -extern crate debug; extern crate test; extern crate "nalgebra" as na; diff --git a/benches/vec.rs b/benches/vec.rs index 16aaabe0..871d7f0d 100644 --- a/benches/vec.rs +++ b/benches/vec.rs @@ -1,6 +1,5 @@ #![feature(macro_rules)] -extern crate debug; extern crate test; extern crate "nalgebra" as na; diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index da6600fe..d5abefab 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -652,7 +652,7 @@ macro_rules! scalar_mul_impl ( DMat { nrows: left.nrows, ncols: left.ncols, - mij: left.mij.iter().map(|a| a * *right).collect() + mij: left.mij.iter().map(|a| *a * *right).collect() } } } @@ -667,7 +667,7 @@ macro_rules! scalar_div_impl ( DMat { nrows: left.nrows, ncols: left.ncols, - mij: left.mij.iter().map(|a| a / *right).collect() + mij: left.mij.iter().map(|a| *a / *right).collect() } } } @@ -682,7 +682,7 @@ macro_rules! scalar_add_impl ( DMat { nrows: left.nrows, ncols: left.ncols, - mij: left.mij.iter().map(|a| a + *right).collect() + mij: left.mij.iter().map(|a| *a + *right).collect() } } } @@ -697,7 +697,7 @@ macro_rules! scalar_sub_impl ( DMat { nrows: left.nrows, ncols: left.ncols, - mij: left.mij.iter().map(|a| a - *right).collect() + mij: left.mij.iter().map(|a| *a - *right).collect() } } } diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index 3f80c43d..a33b64c7 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -169,10 +169,10 @@ macro_rules! dvec_impl( let mut elt = basis_element.clone(); - elt = elt - self * Dot::dot(&basis_element, self); + elt = elt - *self * Dot::dot(&basis_element, self); for v in res.iter() { - elt = elt - v * Dot::dot(&elt, v) + elt = elt - *v * Dot::dot(&elt, v) }; if !ApproxEq::approx_eq(&Norm::sqnorm(&elt), &Zero::zero()) { @@ -336,7 +336,7 @@ macro_rules! dvec_scalar_mul_impl ( impl $mul<$n, $dvec<$n>> for $n { #[inline] fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| a * *right)) + FromIterator::from_iter(left.as_slice().iter().map(|a| *a * *right)) } } ) @@ -347,7 +347,7 @@ macro_rules! dvec_scalar_div_impl ( impl $div<$n, $dvec<$n>> for $n { #[inline] fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| a / *right)) + FromIterator::from_iter(left.as_slice().iter().map(|a| *a / *right)) } } ) @@ -358,7 +358,7 @@ macro_rules! dvec_scalar_add_impl ( impl $add<$n, $dvec<$n>> for $n { #[inline] fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| a + *right)) + FromIterator::from_iter(left.as_slice().iter().map(|a| *a + *right)) } } ) @@ -369,7 +369,7 @@ macro_rules! dvec_scalar_sub_impl ( impl $sub<$n, $dvec<$n>> for $n { #[inline] fn binop(left: &$dvec<$n>, right: &$n) -> $dvec<$n> { - FromIterator::from_iter(left.as_slice().iter().map(|a| a - *right)) + FromIterator::from_iter(left.as_slice().iter().map(|a| *a - *right)) } } ) diff --git a/src/structs/iso_macros.rs b/src/structs/iso_macros.rs index 7a3f1258..e70acedd 100644 --- a/src/structs/iso_macros.rs +++ b/src/structs/iso_macros.rs @@ -88,7 +88,7 @@ macro_rules! pnt_mul_iso_impl( impl $tmul> for $t { #[inline] fn binop(left: &$tv, right: &$t) -> $tv { - (left + right.translation) * right.rotation + (*left + right.translation) * right.rotation } } ) @@ -140,12 +140,12 @@ macro_rules! translate_impl( impl + Sub> Translate<$tv> for $t { #[inline] fn translate(&self, v: &$tv) -> $tv { - v + self.translation + *v + self.translation } #[inline] fn inv_translate(&self, v: &$tv) -> $tv { - v - self.translation + *v - self.translation } } ) @@ -235,7 +235,7 @@ macro_rules! transformation_impl( } fn append_transformation_cpy(iso: &$t, t: &$t) -> $t { - t * *iso + *t * *iso } fn prepend_transformation(&mut self, t: &$t) { @@ -284,7 +284,7 @@ macro_rules! transform_impl( #[inline] fn inv_transform(t: &$t, p: &$tp) -> $tp { - t.rotation.inv_transform(&(p - t.translation)) + t.rotation.inv_transform(&(*p - t.translation)) } } ) diff --git a/src/structs/quat.rs b/src/structs/quat.rs index 2a8a654c..9de90954 100644 --- a/src/structs/quat.rs +++ b/src/structs/quat.rs @@ -136,7 +136,7 @@ impl + Sub + Add> QuatMulRhs> for Quat { impl + Float + Clone> QuatDivRhs> for Quat { #[inline] fn binop(left: &Quat, right: &Quat) -> Quat { - left * Inv::inv_cpy(right).expect("Unable to invert the denominator.") + *left * Inv::inv_cpy(right).expect("Unable to invert the denominator.") } } diff --git a/src/structs/rot_macros.rs b/src/structs/rot_macros.rs index 108cb725..d8a7c5dd 100644 --- a/src/structs/rot_macros.rs +++ b/src/structs/rot_macros.rs @@ -37,24 +37,24 @@ macro_rules! rotate_impl( impl $trhs for $tv { #[inline] fn rotate(t: &$t, v: &$tv) -> $tv { - t * *v + *t * *v } #[inline] fn inv_rotate(t: &$t, v: &$tv) -> $tv { - v * *t + *v * *t } } impl $trhs for $tp { #[inline] fn rotate(t: &$t, p: &$tp) -> $tp { - t * *p + *t * *p } #[inline] fn inv_rotate(t: &$t, p: &$tp) -> $tp { - p * *t + *p * *t } } ) diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs index 07008827..dfb8a391 100644 --- a/src/structs/spec/vec0.rs +++ b/src/structs/spec/vec0.rs @@ -136,7 +136,7 @@ impl + Neg> Translation> for vec::Vec0 { #[inline] fn inv_translation(&self) -> vec::Vec0 { - -self + -*self } #[inline] @@ -156,7 +156,7 @@ impl + Neg> Translation> for vec::Vec0 { #[inline] fn prepend_translation_cpy(vec: &vec::Vec0, t: &vec::Vec0) -> vec::Vec0 { - vec + *t + *vec + *t } #[inline] diff --git a/src/structs/vec.rs b/src/structs/vec.rs index 736da7f2..85435040 100644 --- a/src/structs/vec.rs +++ b/src/structs/vec.rs @@ -8,7 +8,7 @@ use std::slice::{Items, MutItems}; use std::iter::{Iterator, FromIterator}; use traits::operations::{ApproxEq, POrd, POrdering, PartialLess, PartialEqual, PartialGreater, NotComparable, Axpy, ScalarAdd, ScalarSub, ScalarMul, - ScalarDiv}; + ScalarDiv, Absolute}; use traits::geometry::{Transform, Rotate, FromHomogeneous, ToHomogeneous, Dot, Norm, Translation, Translate}; use traits::structure::{Basis, Cast, Dim, Indexable, Iterable, IterableMut, VecAsPnt, Shape, @@ -135,6 +135,7 @@ rotate_impl!(Pnt1) transform_impl!(Vec1, Pnt1) vec_as_pnt_impl!(Vec1, Pnt1, x) num_float_vec_impl!(Vec1, Vec1MulRhs, Vec1DivRhs) +absolute_vec_impl!(Vec1, x) /// Vector of dimension 2. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] @@ -239,6 +240,7 @@ rotate_impl!(Pnt2) transform_impl!(Vec2, Pnt2) vec_as_pnt_impl!(Vec2, Pnt2, x, y) num_float_vec_impl!(Vec2, Vec2MulRhs, Vec2DivRhs) +absolute_vec_impl!(Vec2, x, y) /// Vector of dimension 3. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] @@ -348,6 +350,7 @@ rotate_impl!(Pnt3) transform_impl!(Vec3, Pnt3) vec_as_pnt_impl!(Vec3, Pnt3, x, y, z) num_float_vec_impl!(Vec3, Vec3MulRhs, Vec3DivRhs) +absolute_vec_impl!(Vec3, x, y, z) /// Vector of dimension 4. @@ -457,6 +460,7 @@ rotate_impl!(Pnt4) transform_impl!(Vec4, Pnt4) vec_as_pnt_impl!(Vec4, Pnt4, x, y, z, w) num_float_vec_impl!(Vec4, Vec4MulRhs, Vec4DivRhs) +absolute_vec_impl!(Vec4, x, y, z, w) /// Vector of dimension 5. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] @@ -567,6 +571,7 @@ rotate_impl!(Pnt5) transform_impl!(Vec5, Pnt5) vec_as_pnt_impl!(Vec5, Pnt5, x, y, z, w, a) num_float_vec_impl!(Vec5, Vec5MulRhs, Vec5DivRhs) +absolute_vec_impl!(Vec5, x, y, z, w, a) /// Vector of dimension 6. #[deriving(Eq, PartialEq, Encodable, Decodable, Clone, Hash, Rand, Zero, Show)] @@ -677,3 +682,4 @@ rotate_impl!(Pnt6) transform_impl!(Vec6, Pnt6) vec_as_pnt_impl!(Vec6, Pnt6, x, y, z, w, a, b) num_float_vec_impl!(Vec6, Vec6MulRhs, Vec6DivRhs) +absolute_vec_impl!(Vec6, x, y, z, w, a, b) diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index 863a2ef8..f09a046f 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -323,7 +323,7 @@ macro_rules! basis_impl( elt = elt - *n * Dot::dot(&basis_element, n); for v in basis.iter() { - elt = elt - v * Dot::dot(&elt, v) + elt = elt - *v * Dot::dot(&elt, v) }; if !ApproxEq::approx_eq(&Norm::sqnorm(&elt), &Zero::zero()) { @@ -519,7 +519,7 @@ macro_rules! translation_impl( #[inline] fn inv_translation(&self) -> $t { - -self + -*self } #[inline] @@ -539,7 +539,7 @@ macro_rules! translation_impl( #[inline] fn prepend_translation_cpy(transform: &$t, t: &$t) -> $t { - transform + *t + *transform + *t } #[inline] @@ -773,3 +773,14 @@ macro_rules! num_float_vec_impl( } ) ) + +macro_rules! absolute_vec_impl( + ($t: ident, $comp0: ident $(,$compN: ident)*) => ( + impl Absolute<$t> for $t { + #[inline] + fn abs(m: &$t) -> $t { + $t::new(m.$comp0.abs() $(, m.$compN.abs() )*) + } + } + ) +) diff --git a/tests/vec.rs b/tests/vec.rs index 42ab35bb..3bf889f1 100644 --- a/tests/vec.rs +++ b/tests/vec.rs @@ -12,7 +12,7 @@ macro_rules! test_iterator_impl( let mut mv: $t = v.clone(); let n: $n = random(); - let nv: $t = v.iter().map(|e| e * n).collect(); + let nv: $t = v.iter().map(|e| *e * n).collect(); for e in mv.iter_mut() { *e = *e * n