Adapted for the compiler 'incomming' branch.

This commit is contained in:
Sébastien Crozet 2013-06-01 20:50:00 +02:00
parent 4146385e09
commit 0b8058e88f
16 changed files with 96 additions and 91 deletions

View File

@ -1,6 +1,6 @@
use core::num::{One, Zero};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use std::num::{One, Zero};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use traits::workarounds::rlmul::{RMul, LMul};
use traits::dim::Dim;
use traits::inv::Inv;

View File

@ -1,6 +1,6 @@
use core::num::{One, Zero};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use std::num::{One, Zero};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use traits::dim::Dim;
use traits::inv::Inv;
use traits::rotation::Rotation;

View File

@ -1,6 +1,6 @@
use core::num::{One, Zero};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use std::num::{One, Zero};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use traits::dim::Dim;
use traits::inv::Inv;
use traits::transpose::Transpose;

View File

@ -1,6 +1,6 @@
use core::num::{Zero, One, Algebraic};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use std::num::{Zero, One, Algebraic};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use traits::basis::Basis;
use traits::dim::Dim;
use traits::dot::Dot;

View File

@ -1,7 +1,7 @@
use core::num::{One, Zero};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use core::util::swap;
use std::num::{One, Zero};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use std::util::swap;
use traits::dim::Dim;
use traits::inv::Inv;
use traits::transpose::Transpose;

View File

@ -1,7 +1,7 @@
use core::num::{Zero, One, Algebraic};
use core::rand::{Rand, Rng, RngUtil};
use std::num::{Zero, One, Algebraic};
use std::rand::{Rand, Rng, RngUtil};
use dim1::vec1::{Vec1, vec1};
use core::cmp::ApproxEq;
use std::cmp::ApproxEq;
use traits::basis::Basis;
use traits::cross::Cross;
use traits::dim::Dim;

View File

@ -1,7 +1,7 @@
use core::num::{One, Zero};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use core::util::swap;
use std::num::{One, Zero};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use std::util::swap;
use traits::dim::Dim;
use traits::inv::Inv;
use traits::transpose::Transpose;

View File

@ -1,6 +1,6 @@
use core::num::{Zero, One, Algebraic, abs};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use std::num::{Zero, One, Algebraic, abs};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use traits::basis::Basis;
use traits::cross::Cross;
use traits::dim::Dim;

View File

@ -1,6 +1,7 @@
use core::num::{One, Zero};
use core::vec::{from_elem, swap, all, all2, len};
use core::cmp::ApproxEq;
use std::uint::iterate;
use std::num::{One, Zero};
use std::vec::{from_elem, swap, all, all2, len};
use std::cmp::ApproxEq;
use traits::inv::Inv;
use traits::division_ring::DivisionRing;
use traits::transpose::Transpose;
@ -25,7 +26,7 @@ pub fn one_mat_with_dim<T: Copy + One + Zero>(dim: uint) -> DMat<T>
let mut res = zero_mat_with_dim(dim);
let _1 = One::one::<T>();
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{ res.set(i, i, &_1); }
res
@ -67,13 +68,13 @@ Mul<DMat<T>, DMat<T>> for DMat<T>
let dim = self.dim;
let mut res = zero_mat_with_dim(dim);
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{
let mut acc = Zero::zero::<T>();
for uint::range(0u, dim) |k|
for iterate(0u, dim) |k|
{ acc += self.at(i, k) * other.at(k, j); }
res.set(i, j, &acc);
@ -94,9 +95,9 @@ RMul<DVec<T>> for DMat<T>
let dim = self.dim;
let mut res : DVec<T> = zero_vec_with_dim(dim);
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{ res.at[i] = res.at[i] + other.at[j] * self.at(i, j); }
}
@ -114,9 +115,9 @@ LMul<DVec<T>> for DMat<T>
let dim = self.dim;
let mut res : DVec<T> = zero_vec_with_dim(dim);
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{ res.at[i] = res.at[i] + other.at[j] * self.at(j, i); }
}
@ -143,7 +144,7 @@ Inv for DMat<T>
let _0T = Zero::zero::<T>();
// inversion using Gauss-Jordan elimination
for uint::range(0u, dim) |k|
for iterate(0u, dim) |k|
{
// search a non-zero value on the k-th column
// FIXME: would it be worth it to spend some more time searching for the
@ -164,7 +165,7 @@ Inv for DMat<T>
// swap pivot line
if (n0 != k)
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{
let off_n0_j = self.offset(n0, j);
let off_k_j = self.offset(k, j);
@ -176,31 +177,31 @@ Inv for DMat<T>
let pivot = self.at(k, k);
for uint::range(k, dim) |j|
for iterate(k, dim) |j|
{
let selfval = &(self.at(k, j) / pivot);
self.set(k, j, selfval);
}
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{
let resval = &(res.at(k, j) / pivot);
res.set(k, j, resval);
}
for uint::range(0u, dim) |l|
for iterate(0u, dim) |l|
{
if (l != k)
{
let normalizer = self.at(l, k);
for uint::range(k, dim) |j|
for iterate(k, dim) |j|
{
let selfval = &(self.at(l, j) - self.at(k, j) * normalizer);
self.set(l, j, selfval);
}
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{
let resval = &(res.at(l, j) - res.at(k, j) * normalizer);
res.set(l, j, resval);
@ -228,9 +229,9 @@ impl<T:Copy> Transpose for DMat<T>
{
let dim = self.dim;
for uint::range(1u, dim) |i|
for iterate(1u, dim) |i|
{
for uint::range(0u, dim - 1) |j|
for iterate(0u, dim - 1) |j|
{
let off_i_j = self.offset(i, j);
let off_j_i = self.offset(j, i);

View File

@ -1,6 +1,7 @@
use core::num::{Zero, One, Algebraic};
use core::vec::{map_zip, map, all2, len, from_elem, all};
use core::cmp::ApproxEq;
use std::uint::iterate;
use std::num::{Zero, One, Algebraic};
use std::vec::{map_zip, map, all2, len, from_elem, all};
use std::cmp::ApproxEq;
use traits::ring::Ring;
use traits::division_ring::DivisionRing;
use traits::dot::Dot;
@ -28,7 +29,7 @@ impl<T: Copy + DivisionRing + Algebraic + Clone + ApproxEq<T>> DVec<T>
{
let mut res : ~[DVec<T>] = ~[];
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
let mut basis_element : DVec<T> = zero_vec_with_dim(dim);
@ -47,7 +48,7 @@ impl<T: Copy + DivisionRing + Algebraic + Clone + ApproxEq<T>> DVec<T>
let dim = len(self.at);
let mut res : ~[DVec<T>] = ~[];
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
let mut basis_element : DVec<T> = zero_vec_with_dim(len(self.at));
@ -106,7 +107,7 @@ Dot<T> for DVec<T>
let mut res = Zero::zero::<T>();
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ res += self.at[i] * other.at[i]; }
res
@ -119,7 +120,7 @@ impl<T: Copy + Ring> SubDot<T> for DVec<T>
{
let mut res = Zero::zero::<T>();
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ res += (self.at[i] - a.at[i]) * b.at[i]; }
res
@ -134,7 +135,7 @@ ScalarMul<T> for DVec<T>
fn scalar_mul_inplace(&mut self, s: &T)
{
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ self.at[i] *= *s; }
}
}
@ -148,7 +149,7 @@ ScalarDiv<T> for DVec<T>
fn scalar_div_inplace(&mut self, s: &T)
{
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ self.at[i] /= *s; }
}
}
@ -161,7 +162,7 @@ ScalarAdd<T> for DVec<T>
fn scalar_add_inplace(&mut self, s: &T)
{
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ self.at[i] += *s; }
}
}
@ -174,7 +175,7 @@ ScalarSub<T> for DVec<T>
fn scalar_sub_inplace(&mut self, s: &T)
{
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ self.at[i] -= *s; }
}
}
@ -213,7 +214,7 @@ Norm<T> for DVec<T>
{
let l = self.norm();
for uint::range(0u, len(self.at)) |i|
for iterate(0u, len(self.at)) |i|
{ self.at[i] /= l; }
l

View File

@ -1,6 +1,7 @@
use core::num::{One, Zero};
use core::rand::{Rand, Rng, RngUtil};
use core::cmp::ApproxEq;
use std::uint::iterate;
use std::num::{One, Zero};
use std::rand::{Rand, Rng, RngUtil};
use std::cmp::ApproxEq;
use traits::dim::Dim;
use traits::inv::Inv;
use traits::division_ring::DivisionRing;
@ -61,13 +62,13 @@ Mul<NMat<D, T>, NMat<D, T>> for NMat<D, T>
let dim = Dim::dim::<D>();
let mut res = Zero::zero::<NMat<D, T>>();
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{
let mut acc: T = Zero::zero();
for uint::range(0u, dim) |k|
for iterate(0u, dim) |k|
{ acc += self[(i, k)] * other[(k, j)]; }
res.set(i, j, &acc);
@ -86,9 +87,9 @@ RMul<NVec<D, T>> for NMat<D, T>
let dim = Dim::dim::<D>();
let mut res : NVec<D, T> = Zero::zero();
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{ res.at.at[i] = res.at.at[i] + other.at.at[j] * self[(i, j)]; }
}
@ -104,9 +105,9 @@ LMul<NVec<D, T>> for NMat<D, T>
let dim = Dim::dim::<D>();
let mut res : NVec<D, T> = Zero::zero();
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{ res.at.at[i] = res.at.at[i] + other.at.at[j] * self[(j, i)]; }
}
@ -158,9 +159,9 @@ impl<D: Dim, T: Rand + Zero + Copy> Rand for NMat<D, T>
let dim = Dim::dim::<D>();
let mut res : NMat<D, T> = Zero::zero();
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{
for uint::range(0u, dim) |j|
for iterate(0u, dim) |j|
{ res.set(i, j, &rng.gen()); }
}

View File

@ -1,7 +1,8 @@
use core::num::{Zero, Algebraic};
use core::rand::{Rand, Rng, RngUtil};
use core::vec::{map};
use core::cmp::ApproxEq;
use std::uint::iterate;
use std::num::{Zero, Algebraic};
use std::rand::{Rand, Rng, RngUtil};
use std::vec::{map};
use std::cmp::ApproxEq;
use ndim::dvec::{DVec, zero_vec_with_dim, is_zero_vec};
use traits::basis::Basis;
use traits::ring::Ring;
@ -189,7 +190,7 @@ impl<D: Dim, T: Rand + Zero + Copy> Rand for NVec<D, T>
let dim = Dim::dim::<D>();
let mut res : NVec<D, T> = Zero::zero();
for uint::range(0u, dim) |i|
for iterate(0u, dim) |i|
{ res.at.at[i] = rng.gen() }
res

View File

@ -1,9 +1,9 @@
#[test]
use core::num::{One, abs};
use std::num::{Real, One, abs};
#[test]
use core::rand::{random};
use std::rand::{random};
#[test]
use core::cmp::ApproxEq;
use std::cmp::ApproxEq;
#[test]
use traits::inv::Inv;
#[test]
@ -25,7 +25,7 @@ use adaptors::rotmat::Rotmat;
macro_rules! test_inv_mat_impl(
($t:ty) => (
for uint::range(0u, 10000u) |_|
for 10000.times
{
let randmat : $t = random();
@ -46,6 +46,7 @@ fn test_inv_mat2()
fn test_inv_mat3()
{ test_inv_mat_impl!(Mat3<f64>); }
// FIXME: ICE
// #[test]
// fn test_inv_nmat()
// { test_inv_mat_impl!(NMat<d7, f64>); }
@ -53,10 +54,10 @@ fn test_inv_mat3()
#[test]
fn test_rotation2()
{
for uint::range(0u, 10000u) |_|
for 10000.times
{
let randmat = One::one::<Rotmat<Mat2<f64>>>();
let ang = &vec1(abs::<f64>(random()) % f64::consts::pi);
let ang = &vec1(abs::<f64>(random()) % Real::pi());
assert!(randmat.rotated(ang).rotation().approx_eq(ang));
}

View File

@ -1,11 +1,11 @@
#[test]
use core::num::{Zero, One};
use std::num::{Zero, One};
#[test]
use core::rand::{random};
use std::rand::{random};
#[test]
use core::vec::{all, all2};
use std::vec::{all, all2};
#[test]
use core::cmp::ApproxEq;
use std::cmp::ApproxEq;
#[test]
use dim3::vec3::Vec3;
#[test]
@ -27,7 +27,7 @@ use traits::norm::Norm;
macro_rules! test_commut_dot_impl(
($t:ty) => (
for uint::range(0u, 10000u) |_|
for 10000.times
{
let v1 : $t = random();
let v2 : $t = random();
@ -39,7 +39,7 @@ macro_rules! test_commut_dot_impl(
macro_rules! test_basis_impl(
($t:ty) => (
for uint::range(0u, 10000u) |_|
for 10000.times
{
let basis = Basis::canonical_basis::<$t>();
@ -53,7 +53,7 @@ macro_rules! test_basis_impl(
macro_rules! test_subspace_basis_impl(
($t:ty) => (
for uint::range(0u, 10000u) |_|
for 10000.times
{
let v : Vec3<f64> = random();
let v1 = v.normalized();
@ -72,7 +72,7 @@ macro_rules! test_subspace_basis_impl(
#[test]
fn test_cross_vec3()
{
for uint::range(0u, 10000u) |_|
for 10000.times
{
let v1 : Vec3<f64> = random();
let v2 : Vec3<f64> = random();

View File

@ -1,4 +1,4 @@
use core::num::{One, Zero};
use std::num::{One, Zero};
/**
* Trait of elements of a ring. A rings is an algebraic structure, the

View File

@ -1,4 +1,4 @@
use core::num::Zero;
use std::num::Zero;
use traits::division_ring::DivisionRing;
use traits::workarounds::scalar_op::{ScalarMul, ScalarDiv};