diff --git a/src/dvec.rs b/src/dvec.rs index e751c5ac..2d70e2f4 100644 --- a/src/dvec.rs +++ b/src/dvec.rs @@ -102,7 +102,7 @@ impl> DVec elt = elt - self.scalar_mul(&basis_element.dot(self)); - for res.iter().advance |v| + foreach v in res.iter() { elt = elt - v.scalar_mul(&elt.dot(v)) }; if !elt.sqnorm().approx_eq(&Zero::zero()) diff --git a/src/mat_macros.rs b/src/mat_macros.rs index 54b40b10..d358b417 100644 --- a/src/mat_macros.rs +++ b/src/mat_macros.rs @@ -102,7 +102,7 @@ macro_rules! column_impl( { fn set_column(&mut self, col: uint, v: V) { - for v.iter().enumerate().advance |(i, e)| + foreach (i, e) in v.iter().enumerate() { if i == Dim::dim::<$t>() { break } @@ -115,7 +115,7 @@ macro_rules! column_impl( { let mut res = Zero::zero::(); - for res.mut_iter().enumerate().advance |(i, e)| + foreach (i, e) in res.mut_iter().enumerate() { if i >= Dim::dim::<$t>() { break } diff --git a/src/tests/vec.rs b/src/tests/vec.rs index c37bdc70..34a944ca 100644 --- a/src/tests/vec.rs +++ b/src/tests/vec.rs @@ -31,7 +31,7 @@ macro_rules! test_iterator_impl( let nv: $t = v.iter().transform(|e| e * n).collect(); - for mv.mut_iter().advance |e| + foreach e in mv.mut_iter() { *e = *e * n } assert!(nv == mv && nv == v.scalar_mul(&n)); diff --git a/src/vec0_spec.rs b/src/vec0_spec.rs index dd88410a..88d22086 100644 --- a/src/vec0_spec.rs +++ b/src/vec0_spec.rs @@ -1,9 +1,8 @@ use std::cast; use std::num::{Zero, One, Algebraic, Bounded}; use std::vec::{VecIterator, VecMutIterator}; -use std::iterator::{Iterator, IteratorUtil, FromIterator}; +use std::iterator::{Iterator, FromIterator}; use std::cmp::ApproxEq; -use std::uint::iterate; use traits::iterable::{Iterable, IterableMut}; use traits::basis::Basis; use traits::dim::Dim; @@ -28,16 +27,16 @@ impl vec::Vec0 impl Indexable for vec::Vec0 { #[inline] - pub fn at(&self, i: uint) -> N - { unsafe { cast::transmute::<&vec::Vec0, &[N, ..0]>(self)[i].clone() } } + pub fn at(&self, _: uint) -> N + { fail!("Cannot index a Vec0.") } #[inline] - pub fn set(&mut self, i: uint, val: N) - { unsafe { cast::transmute::<&mut vec::Vec0, &mut [N, ..0]>(self)[i] = val } } + pub fn set(&mut self, _: uint, _: N) + { } #[inline] - pub fn swap(&mut self, i1: uint, i2: uint) - { unsafe { cast::transmute::<&mut vec::Vec0, &mut [N, ..0]>(self).swap(i1, i2) } } + pub fn swap(&mut self, _: uint, _: uint) + { } } impl vec::Vec0 @@ -69,50 +68,11 @@ impl Dim for vec::Vec0 impl> Basis for vec::Vec0 { - pub fn canonical_basis(f: &fn(vec::Vec0)) - { - for iterate(0u, 0) |i| - { - let mut basis_element : vec::Vec0 = Zero::zero(); + pub fn canonical_basis(_: &fn(vec::Vec0)) + { } - basis_element.set(i, One::one()); - - f(basis_element); - } - } - - pub fn orthonormal_subspace_basis(&self, f: &fn(vec::Vec0)) - { - // compute the basis of the orthogonal subspace using Gram-Schmidt - // orthogonalization algorithm - let mut basis: ~[vec::Vec0] = ~[]; - - for iterate(0u, 0) |i| - { - let mut basis_element : vec::Vec0 = Zero::zero(); - - basis_element.set(i, One::one()); - - if basis.len() == 0 - 1 - { break; } - - let mut elt = basis_element.clone(); - - elt = elt - self.scalar_mul(&basis_element.dot(self)); - - for basis.iter().advance |v| - { elt = elt - v.scalar_mul(&elt.dot(v)) }; - - if !elt.sqnorm().approx_eq(&Zero::zero()) - { - let new_element = elt.normalized(); - - f(new_element.clone()); - - basis.push(new_element); - } - } - } + pub fn orthonormal_subspace_basis(&self, _: &fn(vec::Vec0)) + { } } impl> Add, vec::Vec0> for vec::Vec0 diff --git a/src/vec_spec.rs b/src/vec_spec.rs index d26f5cf2..e5b093f3 100644 --- a/src/vec_spec.rs +++ b/src/vec_spec.rs @@ -150,7 +150,7 @@ impl UniformSphereSample for Vec2 { pub fn sample(f: &fn(&'static Vec2)) { - for SAMPLES_2_F64.iter().advance |sample| + foreach sample in SAMPLES_2_F64.iter() { f(sample) } } } @@ -159,7 +159,7 @@ impl UniformSphereSample for Vec3 { pub fn sample(f: &fn(&'static Vec3)) { - for SAMPLES_3_F64.iter().advance |sample| + foreach sample in SAMPLES_3_F64.iter() { f(sample) } } }