From e6e099b7c4f55042fe6576748f0e8a7ec5194d9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Fri, 9 Jan 2015 22:26:05 +0100 Subject: [PATCH] Replace int, and uint, by isize and usize. --- benches/common/macros.rs | 10 ++-- benches/dmat.rs | 4 +- src/lib.rs | 30 +++++----- src/linalg/decompositions.rs | 20 +++---- src/structs/dmat.rs | 106 ++++++++++++++++----------------- src/structs/dvec.rs | 22 +++---- src/structs/dvec_macros.rs | 46 +++++++------- src/structs/iso.rs | 12 ++-- src/structs/iso_macros.rs | 2 +- src/structs/mat_macros.rs | 90 ++++++++++++++-------------- src/structs/ortho.rs | 4 +- src/structs/persp.rs | 4 +- src/structs/pnt.rs | 64 ++++++++++---------- src/structs/pnt_macros.rs | 4 +- src/structs/rot.rs | 10 ++-- src/structs/rot_macros.rs | 18 +++--- src/structs/spec/complex.rs | 2 +- src/structs/spec/mat.rs | 12 ++-- src/structs/spec/primitives.rs | 96 ++++++++++++++--------------- src/structs/spec/vec.rs | 12 ++-- src/structs/spec/vec0.rs | 28 ++++----- src/structs/vec_macros.rs | 38 ++++++------ src/traits/geometry.rs | 18 +++--- src/traits/operations.rs | 16 ++--- src/traits/structure.rs | 66 ++++++++++---------- tests/mat.rs | 32 +++++----- tests/quat.rs | 12 ++-- tests/vec.rs | 12 ++-- 28 files changed, 395 insertions(+), 395 deletions(-) diff --git a/benches/common/macros.rs b/benches/common/macros.rs index 2918f428..06923a74 100644 --- a/benches/common/macros.rs +++ b/benches/common/macros.rs @@ -4,7 +4,7 @@ macro_rules! bench_binop( ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -27,7 +27,7 @@ macro_rules! bench_binop_na( ($name: ident, $t1: ty, $t2: ty, $binop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -50,7 +50,7 @@ macro_rules! bench_unop( ($name: ident, $t: ty, $unop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -72,7 +72,7 @@ macro_rules! bench_unop_self( ($name: ident, $t: ty, $unop: ident) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); @@ -94,7 +94,7 @@ macro_rules! bench_construction( ($name: ident, $constructor: path $(, $args: ident: $types: ty)*) => { #[bench] fn $name(bh: &mut Bencher) { - const LEN: uint = 1 << 13; + const LEN: usize = 1 << 13; let mut rng = IsaacRng::new_unseeded(); diff --git a/benches/dmat.rs b/benches/dmat.rs index bd1468f8..0fc3cbe0 100644 --- a/benches/dmat.rs +++ b/benches/dmat.rs @@ -11,7 +11,7 @@ macro_rules! bench_mul_dmat( let a: DMat = DMat::new_random($nrows, $ncols); let mut b: DMat = DMat::new_random($nrows, $ncols); - for _ in range(0u, 1000) { + for _ in range(0us, 1000) { // XXX: the clone here is highly undesirable! b = a.clone() * b; } @@ -53,7 +53,7 @@ macro_rules! bench_mul_dmat_dvec( let m : DMat = DMat::new_random($nrows, $ncols); let mut v : DVec = DVec::new_random($ncols); - for _ in range(0u, 1000) { + for _ in range(0us, 1000) { // XXX: the clone here is highly undesirable! v = m.clone() * v } diff --git a/src/lib.rs b/src/lib.rs index 20a51261..cb819222 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,7 +42,7 @@ fn main() { an optimized set of tools for computer graphics and physics. Those features include: * Vectors with static sizes: `Vec0`, `Vec1`, `Vec2`, `Vec3`, `Vec4`, `Vec5`, `Vec6`. -* Points with static sizes: `Pnt0`, `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`. +* Poisizes with static sizes: `Pnt0`, `Pnt1`, `Pnt2`, `Pnt3`, `Pnt4`, `Pnt5`, `Pnt6`. * Square matrices with static sizes: `Mat1`, `Mat2`, `Mat3`, `Mat4`, `Mat5`, `Mat6 `. * Rotation matrices: `Rot2`, `Rot3`, `Rot4`. * Quaternions: `Quat`, `UnitQuat`. @@ -314,7 +314,7 @@ pub fn orig() -> P { Orig::orig() } -/// Returns the center of two points. +/// Returns the center of two poisizes. #[inline] pub fn center, V: Copy>(a: &P, b: &P) -> P { let _2 = one::() + one(); @@ -324,13 +324,13 @@ pub fn center, V: Copy>(a: &P, b: &P) -> P { /* * FloatPnt */ -/// Returns the distance between two points. +/// Returns the distance between two poisizes. #[inline(always)] pub fn dist, V: Norm>(a: &P, b: &P) -> N { a.dist(b) } -/// Returns the squared distance between two points. +/// Returns the squared distance between two poisizes. #[inline(always)] pub fn sqdist, V: Norm>(a: &P, b: &P) -> N { a.sqdist(b) @@ -408,7 +408,7 @@ pub fn append_translation>(m: &M, v: &V) -> M { * Translate

*/ -/// Applies a translation to a point. +/// Applies a translation to a poisize. /// /// ```rust /// extern crate "nalgebra" as na; @@ -428,7 +428,7 @@ pub fn translate>(m: &M, p: &P) -> P { m.translate(p) } -/// Applies an inverse translation to a point. +/// Applies an inverse translation to a poisize. /// /// ```rust /// extern crate "nalgebra" as na; @@ -575,18 +575,18 @@ pub fn inv_rotate>(m: &M, v: &V) -> V { * RotationWithTranslation */ -/// Rotates a copy of `m` by `amount` using `center` as the pivot point. +/// Rotates a copy of `m` by `amount` using `center` as the pivot poisize. #[inline(always)] -pub fn append_rotation_wrt_point + Copy, +pub fn append_rotation_wrt_poisize + Copy, AV, M: RotationWithTranslation>( m: &M, amount: &AV, center: &LV) -> M { - RotationWithTranslation::append_rotation_wrt_point_cpy(m, amount, center) + RotationWithTranslation::append_rotation_wrt_poisize_cpy(m, amount, center) } -/// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot point. +/// Rotates a copy of `m` by `amount` using `m.translation()` as the pivot poisize. #[inline(always)] pub fn append_rotation_wrt_center + Copy, AV, @@ -744,7 +744,7 @@ pub fn from_homogeneous>(m: &M) -> Res { /// Samples the unit sphere living on the dimension as the samples types. /// -/// The number of sampling point is implementation-specific. It is always uniform. +/// The number of sampling poisize is implementation-specific. It is always uniform. #[inline(always)] pub fn sample_sphere(f: F) { UniformSphereSample::sample(f) @@ -837,7 +837,7 @@ pub fn mean>(observations: &M) -> N { */ /// Computes the eigenvalues and eigenvectors of a square matrix usin the QR algorithm. #[inline(always)] -pub fn eigen_qr>(m: &M, eps: &N, niter: uint) -> (M, V) { +pub fn eigen_qr>(m: &M, eps: &N, niter: usize) -> (M, V) { EigenQR::eigen_qr(m, eps, niter) } @@ -852,7 +852,7 @@ pub fn eigen_qr>(m: &M, eps: &N, niter: uint) -> (M, V) { */ /// Construct the identity matrix for a given dimension #[inline(always)] -pub fn new_identity(dim: uint) -> M { +pub fn new_identity(dim: usize) -> M { Eye::new_identity(dim) } @@ -874,7 +874,7 @@ pub fn orthonormal_subspace_basis bool>(v: &V, f: F) { /// Gets the (0-based) i-th element of the canonical basis of V. #[inline] -pub fn canonical_basis_element(i: uint) -> Option { +pub fn canonical_basis_element(i: usize) -> Option { Basis::canonical_basis_element(i) } @@ -902,7 +902,7 @@ pub fn diag, V>(m: &M) -> V { /// /// Same as `Dim::dim::(None::)`. #[inline(always)] -pub fn dim() -> uint { +pub fn dim() -> usize { Dim::dim(None::) } diff --git a/src/linalg/decompositions.rs b/src/linalg/decompositions.rs index 3b60d436..9c14e61d 100644 --- a/src/linalg/decompositions.rs +++ b/src/linalg/decompositions.rs @@ -11,10 +11,10 @@ use std::ops::{Mul, Add, Sub}; /// * `dim` - the dimension of the space the resulting matrix operates in /// * `start` - the starting dimension of the subspace of the reflexion /// * `vec` - the vector defining the reflection. -pub fn householder_matrix(dim: uint, start: uint, vec: V) -> M +pub fn householder_matrix(dim: usize, start: usize, vec: V) -> M where N: BaseFloat, - M: Eye + Indexable<(uint, uint), N>, - V: Indexable { + M: Eye + Indexable<(usize, usize), N>, + V: Indexable { let mut qk : M = Eye::new_identity(dim); let subdim = vec.shape(); @@ -40,8 +40,8 @@ pub fn householder_matrix(dim: uint, start: uint, vec: V) -> M /// * `m` - matrix to decompose pub fn qr(m: &M) -> (M, M) where N: BaseFloat, - V: Indexable + Norm, - M: Copy + Eye + ColSlice + Transpose + Indexable<(uint, uint), N> + + V: Indexable + Norm, + M: Copy + Eye + ColSlice + Transpose + Indexable<(usize, usize), N> + Mul { let (rows, cols) = m.shape(); assert!(rows >= cols); @@ -50,7 +50,7 @@ pub fn qr(m: &M) -> (M, M) let iterations = min(rows - 1, cols); - for ite in range(0u, iterations) { + for ite in range(0us, iterations) { let mut v = r.col_slice(ite, ite, rows); let alpha = if unsafe { v.unsafe_at(ite) } >= ::zero() { @@ -74,17 +74,17 @@ pub fn qr(m: &M) -> (M, M) } /// Eigendecomposition of a square matrix using the qr algorithm. -pub fn eigen_qr(m: &M, eps: &N, niter: uint) -> (M, V) +pub fn eigen_qr(m: &M, eps: &N, niter: usize) -> (M, V) where N: BaseFloat, - VS: Indexable + Norm, - M: Indexable<(uint, uint), N> + SquareMat + Add + + VS: Indexable + Norm, + M: Indexable<(usize, usize), N> + SquareMat + Add + Sub + ColSlice + ApproxEq + Copy { let mut eigenvectors: M = ::one::(); let mut eigenvalues = *m; // let mut shifter: M = Eye::new_identity(rows); - let mut iter = 0u; + let mut iter = 0us; for _ in range(0, niter) { let mut stop = true; diff --git a/src/structs/dmat.rs b/src/structs/dmat.rs index 9b7cb5c0..cc6d3195 100644 --- a/src/structs/dmat.rs +++ b/src/structs/dmat.rs @@ -18,15 +18,15 @@ use std::fmt::{Show, Formatter, Result, String}; /// Matrix with dimensions unknown at compile-time. #[derive(Eq, PartialEq, Clone)] pub struct DMat { - nrows: uint, - ncols: uint, + nrows: usize, + ncols: usize, mij: Vec } impl DMat { /// Creates an uninitialized matrix. #[inline] - pub unsafe fn new_uninitialized(nrows: uint, ncols: uint) -> DMat { + pub unsafe fn new_uninitialized(nrows: usize, ncols: usize) -> DMat { let mut vec = Vec::with_capacity(nrows * ncols); vec.set_len(nrows * ncols); @@ -45,7 +45,7 @@ impl DMat { /// * `dim` - The dimension of the matrix. A `dim`-dimensional matrix contains `dim * dim` /// components. #[inline] - pub fn new_zeros(nrows: uint, ncols: uint) -> DMat { + pub fn new_zeros(nrows: usize, ncols: usize) -> DMat { DMat::from_elem(nrows, ncols, ::zero()) } @@ -66,7 +66,7 @@ impl DMat { impl DMat { /// Builds a matrix filled with random values. #[inline] - pub fn new_random(nrows: uint, ncols: uint) -> DMat { + pub fn new_random(nrows: usize, ncols: usize) -> DMat { DMat::from_fn(nrows, ncols, |_, _| rand::random()) } } @@ -74,7 +74,7 @@ impl DMat { impl DMat { /// Builds a matrix filled with a given constant. #[inline] - pub fn new_ones(nrows: uint, ncols: uint) -> DMat { + pub fn new_ones(nrows: usize, ncols: usize) -> DMat { DMat::from_elem(nrows, ncols, ::one()) } } @@ -82,7 +82,7 @@ impl DMat { impl DMat { /// Builds a matrix filled with a given constant. #[inline] - pub fn from_elem(nrows: uint, ncols: uint, val: N) -> DMat { + pub fn from_elem(nrows: usize, ncols: usize, val: N) -> DMat { DMat { nrows: nrows, ncols: ncols, @@ -97,7 +97,7 @@ impl DMat { /// /// The vector must have at least `nrows * ncols` elements. #[inline] - pub fn from_row_vec(nrows: uint, ncols: uint, vec: &[N]) -> DMat { + pub fn from_row_vec(nrows: usize, ncols: usize, vec: &[N]) -> DMat { let mut res = DMat::from_col_vec(ncols, nrows, vec); // we transpose because the buffer is row_major @@ -113,7 +113,7 @@ impl DMat { /// /// The vector must have at least `nrows * ncols` elements. #[inline] - pub fn from_col_vec(nrows: uint, ncols: uint, vec: &[N]) -> DMat { + pub fn from_col_vec(nrows: usize, ncols: usize, vec: &[N]) -> DMat { assert!(nrows * ncols == vec.len()); DMat { @@ -127,7 +127,7 @@ impl DMat { impl DMat { /// Builds a matrix filled with a given constant. #[inline(always)] - pub fn from_fn N>(nrows: uint, ncols: uint, mut f: F) -> DMat { + pub fn from_fn N>(nrows: usize, ncols: usize, mut f: F) -> DMat { DMat { nrows: nrows, ncols: ncols, @@ -137,17 +137,17 @@ impl DMat { /// The number of row on the matrix. #[inline] - pub fn nrows(&self) -> uint { + pub fn nrows(&self) -> usize { self.nrows } /// The number of columns on the matrix. #[inline] - pub fn ncols(&self) -> uint { + pub fn ncols(&self) -> usize { self.ncols } - /// Transforms this matrix into an array. This consumes the matrix and is O(1). + /// Transforms this matrix isizeo an array. This consumes the matrix and is O(1). /// The returned vector contains the matrix data in column-major order. #[inline] pub fn to_vec(self) -> Vec { @@ -178,10 +178,10 @@ impl Eye for DMat { /// * `dim` - The dimension of the matrix. A `dim`-dimensional matrix contains `dim * dim` /// components. #[inline] - fn new_identity(dim: uint) -> DMat { + fn new_identity(dim: usize) -> DMat { let mut res = DMat::new_zeros(dim, dim); - for i in range(0u, dim) { + for i in range(0us, dim) { let _1: N = ::one(); res[(i, i)] = _1; } @@ -192,19 +192,19 @@ impl Eye for DMat { impl DMat { #[inline(always)] - fn offset(&self, i: uint, j: uint) -> uint { + fn offset(&self, i: usize, j: usize) -> usize { i + j * self.nrows } } -impl Indexable<(uint, uint), N> for DMat { +impl Indexable<(usize, usize), N> for DMat { /// Changes the value of a component of the matrix. /// /// # Arguments /// * `rowcol` - 0-based tuple (row, col) to be changed #[inline] - fn set(&mut self, rowcol: (uint, uint), val: N) { + fn set(&mut self, rowcol: (usize, usize), val: N) { let (row, col) = rowcol; assert!(row < self.nrows); assert!(col < self.ncols); @@ -215,7 +215,7 @@ impl Indexable<(uint, uint), N> for DMat { /// Just like `set` without bounds checking. #[inline] - unsafe fn unsafe_set(&mut self, rowcol: (uint, uint), val: N) { + unsafe fn unsafe_set(&mut self, rowcol: (usize, usize), val: N) { let (row, col) = rowcol; let offset = self.offset(row, col); *self.mij.as_mut_slice().get_unchecked_mut(offset) = val @@ -226,7 +226,7 @@ impl Indexable<(uint, uint), N> for DMat { /// # Arguments /// * `rowcol` - 0-based tuple (row, col) to be read #[inline] - fn at(&self, rowcol: (uint, uint)) -> N { + fn at(&self, rowcol: (usize, usize)) -> N { let (row, col) = rowcol; assert!(row < self.nrows); assert!(col < self.ncols); @@ -235,14 +235,14 @@ impl Indexable<(uint, uint), N> for DMat { /// Just like `at` without bounds checking. #[inline] - unsafe fn unsafe_at(&self, rowcol: (uint, uint)) -> N { + unsafe fn unsafe_at(&self, rowcol: (usize, usize)) -> N { let (row, col) = rowcol; *self.mij.as_slice().get_unchecked(self.offset(row, col)) } #[inline] - fn swap(&mut self, rowcol1: (uint, uint), rowcol2: (uint, uint)) { + fn swap(&mut self, rowcol1: (usize, usize), rowcol2: (usize, usize)) { let (row1, col1) = rowcol1; let (row2, col2) = rowcol2; let offset1 = self.offset(row1, col1); @@ -255,17 +255,17 @@ impl Indexable<(uint, uint), N> for DMat { } -impl Shape<(uint, uint)> for DMat { +impl Shape<(usize, usize)> for DMat { #[inline] - fn shape(&self) -> (uint, uint) { + fn shape(&self) -> (usize, usize) { (self.nrows, self.ncols) } } -impl Index<(uint, uint)> for DMat { +impl Index<(usize, usize)> for DMat { type Output = N; - fn index(&self, &(i, j): &(uint, uint)) -> &N { + fn index(&self, &(i, j): &(usize, usize)) -> &N { assert!(i < self.nrows); assert!(j < self.ncols); @@ -275,10 +275,10 @@ impl Index<(uint, uint)> for DMat { } } -impl IndexMut<(uint, uint)> for DMat { +impl IndexMut<(usize, usize)> for DMat { type Output = N; - fn index_mut(&mut self, &(i, j): &(uint, uint)) -> &mut N { + fn index_mut(&mut self, &(i, j): &(usize, usize)) -> &mut N { assert!(i < self.nrows); assert!(j < self.ncols); @@ -298,12 +298,12 @@ impl + Add + Zero> Mul> for let mut res = unsafe { DMat::new_uninitialized(self.nrows, right.ncols) }; - for i in range(0u, self.nrows) { - for j in range(0u, right.ncols) { + for i in range(0us, self.nrows) { + for j in range(0us, right.ncols) { let mut acc: N = ::zero(); unsafe { - for k in range(0u, self.ncols) { + for k in range(0us, self.ncols) { acc = acc + self.unsafe_at((i, k)) * right.unsafe_at((k, j)); } @@ -325,10 +325,10 @@ impl + Mul + Zero> Mul> for let mut res : DVec = unsafe { DVec::new_uninitialized(self.nrows) }; - for i in range(0u, self.nrows) { + for i in range(0us, self.nrows) { let mut acc: N = ::zero(); - for j in range(0u, self.ncols) { + for j in range(0us, self.ncols) { unsafe { acc = acc + self.unsafe_at((i, j)) * right.unsafe_at(j); } @@ -350,10 +350,10 @@ impl + Mul + Zero> Mul> for let mut res : DVec = unsafe { DVec::new_uninitialized(right.ncols) }; - for i in range(0u, right.ncols) { + for i in range(0us, right.ncols) { let mut acc: N = ::zero(); - for j in range(0u, right.nrows) { + for j in range(0us, right.nrows) { unsafe { acc = acc + self.unsafe_at(j) * right.unsafe_at((j, i)); } @@ -385,7 +385,7 @@ impl Inv for DMat { let mut res: DMat = Eye::new_identity(dim); // inversion using Gauss-Jordan elimination - for k in range(0u, dim) { + for k in range(0us, dim) { // search a non-zero value on the k-th column // FIXME: would it be worth it to spend some more time searching for the // max instead? @@ -406,7 +406,7 @@ impl Inv for DMat { // swap pivot line if n0 != k { - for j in range(0u, dim) { + for j in range(0us, dim) { let off_n0_j = self.offset(n0, j); let off_k_j = self.offset(k, j); @@ -423,12 +423,12 @@ impl Inv for DMat { self.unsafe_set((k, j), selfval); } - for j in range(0u, dim) { + for j in range(0us, dim) { let resval = res.unsafe_at((k, j)) / pivot; res.unsafe_set((k, j), resval); } - for l in range(0u, dim) { + for l in range(0us, dim) { if l != k { let normalizer = self.unsafe_at((l, k)); @@ -437,7 +437,7 @@ impl Inv for DMat { self.unsafe_set((l, j), selfval); } - for j in range(0u, dim) { + for j in range(0us, dim) { let resval = res.unsafe_at((l, j)) - res.unsafe_at((k, j)) * normalizer; res.unsafe_set((l, j), resval); } @@ -465,8 +465,8 @@ impl Transpose for DMat { else { let mut res = unsafe { DMat::new_uninitialized(self.ncols, self.nrows) }; - for i in range(0u, self.nrows) { - for j in range(0u, self.ncols) { + for i in range(0us, self.nrows) { + for j in range(0us, self.ncols) { unsafe { res.unsafe_set((j, i), self.unsafe_at((i, j))) } @@ -480,8 +480,8 @@ impl Transpose for DMat { #[inline] fn transpose(&mut self) { if self.nrows == self.ncols { - for i in range(1u, self.nrows) { - for j in range(0u, self.ncols - 1) { + for i in range(1us, self.nrows) { + for j in range(0us, self.ncols - 1) { let off_i_j = self.offset(i, j); let off_j_i = self.offset(j, i); @@ -503,8 +503,8 @@ impl + Clone> Mean> for DMat { let mut res: DVec = DVec::new_zeros(self.ncols); let normalizer: N = Cast::from(1.0f64 / Cast::from(self.nrows)); - for i in range(0u, self.nrows) { - for j in range(0u, self.ncols) { + for i in range(0us, self.nrows) { + for j in range(0us, self.ncols) { unsafe { let acc = res.unsafe_at(j) + self.unsafe_at((i, j)) * normalizer; res.unsafe_set(j, acc); @@ -525,8 +525,8 @@ impl + Clone> Cov> for DMat { let mean = self.mean(); // FIXME: use the rows iterator when available - for i in range(0u, self.nrows) { - for j in range(0u, self.ncols) { + for i in range(0us, self.nrows) { + for j in range(0us, self.ncols) { unsafe { centered.unsafe_set((i, j), self.unsafe_at((i, j)) - mean.unsafe_at(j)); } @@ -542,7 +542,7 @@ impl + Clone> Cov> for DMat { } impl ColSlice> for DMat { - fn col_slice(&self, col_id :uint, row_start: uint, row_end: uint) -> DVec { + fn col_slice(&self, col_id :usize, row_start: usize, row_end: usize) -> DVec { assert!(col_id < self.ncols); assert!(row_start < row_end); assert!(row_end <= self.nrows); @@ -556,14 +556,14 @@ impl ColSlice> for DMat { } impl RowSlice> for DMat { - fn row_slice(&self, row_id :uint, col_start: uint, col_end: uint) -> DVec { + fn row_slice(&self, row_id :usize, col_start: usize, col_end: usize) -> DVec { assert!(row_id < self.nrows); assert!(col_start < col_end); assert!(col_end <= self.ncols); let mut slice : DVec = unsafe { DVec::new_uninitialized(self.nrows) }; - let mut slice_idx = 0u; + let mut slice_idx = 0us; for col_id in range(col_start, col_end) { unsafe { slice.unsafe_set(slice_idx, self.unsafe_at((row_id, col_id))); @@ -635,8 +635,8 @@ impl> ApproxEq for DMat { impl Show for DMat { fn fmt(&self, form:&mut Formatter) -> Result { - for i in range(0u, self.nrows()) { - for j in range(0u, self.ncols()) { + for i in range(0us, self.nrows()) { + for j in range(0us, self.ncols()) { let _ = write!(form, "{} ", self[(i, j)]); } let _ = write!(form, "\n"); diff --git a/src/structs/dvec.rs b/src/structs/dvec.rs index a8e8a5d8..452234c5 100644 --- a/src/structs/dvec.rs +++ b/src/structs/dvec.rs @@ -22,7 +22,7 @@ pub struct DVec { impl DVec { /// Creates an uninitialized vec. #[inline] - pub unsafe fn new_uninitialized(dim: uint) -> DVec { + pub unsafe fn new_uninitialized(dim: usize) -> DVec { let mut vec = Vec::with_capacity(dim); vec.set_len(dim); @@ -35,7 +35,7 @@ impl DVec { impl DVec { /// Builds a vector filled with a constant. #[inline] - pub fn from_elem(dim: uint, elem: N) -> DVec { + pub fn from_elem(dim: usize, elem: N) -> DVec { DVec { at: repeat(elem).take(dim).collect() } } @@ -43,7 +43,7 @@ impl DVec { /// /// The vector must have at least `dim` elements. #[inline] - pub fn from_slice(dim: uint, vec: &[N]) -> DVec { + pub fn from_slice(dim: usize, vec: &[N]) -> DVec { assert!(dim <= vec.len()); DVec { @@ -55,12 +55,12 @@ impl DVec { impl DVec { /// Builds a vector filled with the result of a function. #[inline(always)] - pub fn from_fn N>(dim: uint, mut f: F) -> DVec { + pub fn from_fn N>(dim: usize, mut f: F) -> DVec { DVec { at: range(0, dim).map(|i| f(i)).collect() } } #[inline] - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.at.len() } } @@ -84,7 +84,7 @@ dvec_impl!(DVec); /// Stack-allocated, dynamically sized vector with a maximum size of 1. pub struct DVec1 { at: [N; 1], - dim: uint + dim: usize } small_dvec_impl!(DVec1, 1, 0); @@ -94,7 +94,7 @@ small_dvec_from_impl!(DVec1, 1, ::zero()); /// Stack-allocated, dynamically sized vector with a maximum size of 2. pub struct DVec2 { at: [N; 2], - dim: uint + dim: usize } small_dvec_impl!(DVec2, 2, 0, 1); @@ -104,7 +104,7 @@ small_dvec_from_impl!(DVec2, 2, ::zero(), ::zero()); /// Stack-allocated, dynamically sized vector with a maximum size of 3. pub struct DVec3 { at: [N; 3], - dim: uint + dim: usize } small_dvec_impl!(DVec3, 3, 0, 1, 2); @@ -114,7 +114,7 @@ small_dvec_from_impl!(DVec3, 3, ::zero(), ::zero(), ::zero()); /// Stack-allocated, dynamically sized vector with a maximum size of 4. pub struct DVec4 { at: [N; 4], - dim: uint + dim: usize } small_dvec_impl!(DVec4, 4, 0, 1, 2, 3); @@ -124,7 +124,7 @@ small_dvec_from_impl!(DVec4, 4, ::zero(), ::zero(), ::zero(), ::zero()); /// Stack-allocated, dynamically sized vector with a maximum size of 5. pub struct DVec5 { at: [N; 5], - dim: uint + dim: usize } small_dvec_impl!(DVec5, 5, 0, 1, 2, 3, 4); @@ -134,7 +134,7 @@ small_dvec_from_impl!(DVec5, 5, ::zero(), ::zero(), ::zero(), ::zero(), ::zero() /// Stack-allocated, dynamically sized vector with a maximum size of 6. pub struct DVec6 { at: [N; 6], - dim: uint + dim: usize } small_dvec_impl!(DVec6, 6, 0, 1, 2, 3, 4, 5); diff --git a/src/structs/dvec_macros.rs b/src/structs/dvec_macros.rs index 3a5587c4..7e25bb83 100644 --- a/src/structs/dvec_macros.rs +++ b/src/structs/dvec_macros.rs @@ -8,7 +8,7 @@ macro_rules! dvec_impl( /// # Arguments /// * `dim` - The dimension of the vector. #[inline] - pub fn new_zeros(dim: uint) -> $dvec { + pub fn new_zeros(dim: usize) -> $dvec { $dvec::from_elem(dim, ::zero()) } @@ -34,16 +34,16 @@ macro_rules! dvec_impl( } } - impl Shape for $dvec { + impl Shape for $dvec { #[inline] - fn shape(&self) -> uint { + fn shape(&self) -> usize { self.len() } } - impl Indexable for $dvec { + impl Indexable for $dvec { #[inline] - fn at(&self, i: uint) -> N { + fn at(&self, i: usize) -> N { assert!(i < self.len()); unsafe { self.unsafe_at(i) @@ -51,7 +51,7 @@ macro_rules! dvec_impl( } #[inline] - fn set(&mut self, i: uint, val: N) { + fn set(&mut self, i: usize, val: N) { assert!(i < self.len()); unsafe { self.unsafe_set(i, val); @@ -59,36 +59,36 @@ macro_rules! dvec_impl( } #[inline] - fn swap(&mut self, i: uint, j: uint) { + fn swap(&mut self, i: usize, j: usize) { assert!(i < self.len()); assert!(j < self.len()); self.as_mut_slice().swap(i, j); } #[inline] - unsafe fn unsafe_at(&self, i: uint) -> N { + unsafe fn unsafe_at(&self, i: usize) -> N { *self.at.as_slice().get_unchecked(i) } #[inline] - unsafe fn unsafe_set(&mut self, i: uint, val: N) { + unsafe fn unsafe_set(&mut self, i: usize, val: N) { *self.at.as_mut_slice().get_unchecked_mut(i) = val } } - impl Index for $dvec { + impl Index for $dvec { type Output = N; - fn index(&self, i: &uint) -> &N { + fn index(&self, i: &usize) -> &N { &self.as_slice()[*i] } } - impl IndexMut for $dvec { + impl IndexMut for $dvec { type Output = N; - fn index_mut(&mut self, i: &uint) -> &mut N { + fn index_mut(&mut self, i: &usize) -> &mut N { &mut self.as_mut_slice()[*i] } } @@ -99,7 +99,7 @@ macro_rules! dvec_impl( /// # Arguments /// * `dim` - The dimension of the vector. #[inline] - pub fn new_ones(dim: uint) -> $dvec { + pub fn new_ones(dim: usize) -> $dvec { $dvec::from_elem(dim, ::one()) } } @@ -107,7 +107,7 @@ macro_rules! dvec_impl( impl $dvec { /// Builds a vector filled with random values. #[inline] - pub fn new_random(dim: uint) -> $dvec { + pub fn new_random(dim: usize) -> $dvec { $dvec::from_fn(dim, |&: _| rand::random()) } } @@ -143,10 +143,10 @@ macro_rules! dvec_impl( /// Computes the canonical basis for the given dimension. A canonical basis is a set of /// vectors, mutually orthogonal, with all its component equal to 0.0 except one which is equal /// to 1.0. - pub fn canonical_basis_with_dim(dim: uint) -> Vec<$dvec> { + pub fn canonical_basis_with_dim(dim: usize) -> Vec<$dvec> { let mut res : Vec<$dvec> = Vec::new(); - for i in range(0u, dim) { + for i in range(0us, dim) { let mut basis_element : $dvec = $dvec::new_zeros(dim); basis_element.set(i, ::one()); @@ -165,7 +165,7 @@ macro_rules! dvec_impl( let dim = self.len(); let mut res : Vec<$dvec> = Vec::new(); - for i in range(0u, dim) { + for i in range(0us, dim) { let mut basis_element : $dvec = $dvec::new_zeros(self.len()); basis_element.set(i, ::one()); @@ -276,7 +276,7 @@ macro_rules! dvec_impl( fn dot(&self, other: &$dvec) -> N { assert!(self.len() == other.len()); let mut res: N = ::zero(); - for i in range(0u, self.len()) { + for i in range(0us, self.len()) { res = res + unsafe { self.unsafe_at(i) * other.unsafe_at(i) }; } res @@ -398,7 +398,7 @@ macro_rules! small_dvec_impl ( ($dvec: ident, $dim: expr, $($idx: expr),*) => ( impl $dvec { #[inline] - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { self.dim } } @@ -440,7 +440,7 @@ macro_rules! small_dvec_from_impl ( impl $dvec { /// Builds a vector filled with a constant. #[inline] - pub fn from_elem(dim: uint, elem: N) -> $dvec { + pub fn from_elem(dim: usize, elem: N) -> $dvec { assert!(dim <= $dim); let mut at: [N; $dim] = [ $( $zeros, )* ]; @@ -461,7 +461,7 @@ macro_rules! small_dvec_from_impl ( /// /// The vector must have at least `dim` elements. #[inline] - pub fn from_slice(dim: uint, vec: &[N]) -> $dvec { + pub fn from_slice(dim: usize, vec: &[N]) -> $dvec { assert!(dim <= vec.len() && dim <= $dim); // FIXME: not safe. @@ -481,7 +481,7 @@ macro_rules! small_dvec_from_impl ( impl $dvec { /// Builds a vector filled with the result of a function. #[inline(always)] - pub fn from_fn N>(dim: uint, mut f: F) -> $dvec { + pub fn from_fn N>(dim: usize, mut f: F) -> $dvec { assert!(dim <= $dim); let mut at: [N; $dim] = [ $( $zeros, )* ]; diff --git a/src/structs/iso.rs b/src/structs/iso.rs index 1005cb96..9dc72adf 100644 --- a/src/structs/iso.rs +++ b/src/structs/iso.rs @@ -52,29 +52,29 @@ pub struct Iso4 { } impl Iso3 { - /// Reorient and translate this transformation such that its local `x` axis points to a given + /// Reorient and translate this transformation such that its local `x` axis poisizes to a given /// direction. Note that the usually known `look_at` function does the same thing but with the /// `z` axis. See `look_at_z` for that. /// /// # Arguments /// * eye - The new translation of the transformation. - /// * at - The point to look at. `at - eye` is the direction the matrix `x` axis will be + /// * at - The poisize to look at. `at - eye` is the direction the matrix `x` axis will be /// aligned with. - /// * up - Vector pointing up. The only requirement of this parameter is to not be colinear + /// * up - Vector poisizeing up. The only requirement of this parameter is to not be colinear /// with `at`. Non-colinearity is not checked. pub fn look_at(&mut self, eye: &Pnt3, at: &Pnt3, up: &Vec3) { self.rotation.look_at(&(*at - *eye), up); self.translation = eye.as_vec().clone(); } - /// Reorient and translate this transformation such that its local `z` axis points to a given + /// Reorient and translate this transformation such that its local `z` axis poisizes to a given /// direction. /// /// # Arguments /// * eye - The new translation of the transformation. - /// * at - The point to look at. `at - eye` is the direction the matrix `x` axis will be + /// * at - The poisize to look at. `at - eye` is the direction the matrix `x` axis will be /// aligned with - /// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear + /// * up - Vector poisizeing `up`. The only requirement of this parameter is to not be colinear /// with `at`. Non-colinearity is not checked. pub fn look_at_z(&mut self, eye: &Pnt3, at: &Pnt3, up: &Vec3) { self.rotation.look_at_z(&(*at - *eye), up); diff --git a/src/structs/iso_macros.rs b/src/structs/iso_macros.rs index 89b64eb5..0bdfd74e 100644 --- a/src/structs/iso_macros.rs +++ b/src/structs/iso_macros.rs @@ -43,7 +43,7 @@ macro_rules! dim_impl( ($t: ident, $dim: expr) => ( impl Dim for $t { #[inline] - fn dim(_: Option<$t>) -> uint { + fn dim(_: Option<$t>) -> usize { $dim } } diff --git a/src/structs/mat_macros.rs b/src/structs/mat_macros.rs index a80fff78..53ae02a5 100644 --- a/src/structs/mat_macros.rs +++ b/src/structs/mat_macros.rs @@ -60,13 +60,13 @@ macro_rules! at_fast_impl( ($t: ident, $dim: expr) => ( impl $t { #[inline] - pub unsafe fn at_fast(&self, (i, j): (uint, uint)) -> N { + pub unsafe fn at_fast(&self, (i, j): (usize, usize)) -> N { (*mem::transmute::<&$t, &[N; $dim * $dim]>(self) .get_unchecked(i + j * $dim)) } #[inline] - pub unsafe fn set_fast(&mut self, (i, j): (uint, uint), val: N) { + pub unsafe fn set_fast(&mut self, (i, j): (usize, usize), val: N) { (*mem::transmute::<&mut $t, &mut [N; $dim * $dim]>(self) .get_unchecked_mut(i + j * $dim)) = val } @@ -154,7 +154,7 @@ macro_rules! mat_add_scalar_impl( macro_rules! eye_impl( ($t: ident, $dim: expr, $($comp_diagN: ident),+) => ( impl Eye for $t { - fn new_identity(dim: uint) -> $t { + fn new_identity(dim: usize) -> $t { assert!(dim == $dim); let mut eye: $t = ::zero(); $(eye.$comp_diagN = ::one();)+ @@ -247,7 +247,7 @@ macro_rules! dim_impl( ($t: ident, $dim: expr) => ( impl Dim for $t { #[inline] - fn dim(_: Option<$t>) -> uint { + fn dim(_: Option<$t>) -> usize { $dim } } @@ -256,30 +256,30 @@ macro_rules! dim_impl( macro_rules! indexable_impl( ($t: ident, $dim: expr) => ( - impl Shape<(uint, uint)> for $t { + impl Shape<(usize, usize)> for $t { #[inline] - fn shape(&self) -> (uint, uint) { + fn shape(&self) -> (usize, usize) { ($dim, $dim) } } - impl Indexable<(uint, uint), N> for $t { + impl Indexable<(usize, usize), N> for $t { #[inline] - fn at(&self, (i, j): (uint, uint)) -> N { + fn at(&self, (i, j): (usize, usize)) -> N { unsafe { mem::transmute::<&$t, &[N; $dim * $dim]>(self)[i + j * $dim] } } #[inline] - fn set(&mut self, (i, j): (uint, uint), val: N) { + fn set(&mut self, (i, j): (usize, usize), val: N) { unsafe { mem::transmute::<&mut $t, &mut [N; $dim * $dim]>(self)[i + j * $dim] = val } } #[inline] - fn swap(&mut self, (i1, j1): (uint, uint), (i2, j2): (uint, uint)) { + fn swap(&mut self, (i1, j1): (usize, usize), (i2, j2): (usize, usize)) { unsafe { mem::transmute::<&mut $t, &mut [N; $dim * $dim]>(self) .swap(i1 + j1 * $dim, i2 + j2 * $dim) @@ -287,12 +287,12 @@ macro_rules! indexable_impl( } #[inline] - unsafe fn unsafe_at(&self, (i, j): (uint, uint)) -> N { + unsafe fn unsafe_at(&self, (i, j): (usize, usize)) -> N { (*mem::transmute::<&$t, &[N; $dim * $dim]>(self).get_unchecked(i + j * $dim)) } #[inline] - unsafe fn unsafe_set(&mut self, (i, j): (uint, uint), val: N) { + unsafe fn unsafe_set(&mut self, (i, j): (usize, usize), val: N) { (*mem::transmute::<&mut $t, &mut [N; $dim * $dim]>(self).get_unchecked_mut(i + j * $dim)) = val } } @@ -301,20 +301,20 @@ macro_rules! indexable_impl( macro_rules! index_impl( ($t: ident, $dim: expr) => ( - impl Index<(uint, uint)> for $t { + impl Index<(usize, usize)> for $t { type Output = N; - fn index(&self, &(i, j): &(uint, uint)) -> &N { + fn index(&self, &(i, j): &(usize, usize)) -> &N { unsafe { &mem::transmute::<&$t, &mut [N; $dim * $dim]>(self)[i + j * $dim] } } } - impl IndexMut<(uint, uint)> for $t { + impl IndexMut<(usize, usize)> for $t { type Output = N; - fn index_mut(&mut self, &(i, j): &(uint, uint)) -> &mut N { + fn index_mut(&mut self, &(i, j): &(usize, usize)) -> &mut N { unsafe { &mut mem::transmute::<&mut $t, &mut [N; $dim * $dim]>(self)[i + j * $dim] } @@ -326,7 +326,7 @@ macro_rules! index_impl( macro_rules! col_slice_impl( ($t: ident, $tv: ident, $slice: ident, $dim: expr) => ( impl ColSlice<$slice> for $t { - fn col_slice(&self, cid: uint, rstart: uint, rend: uint) -> $slice { + fn col_slice(&self, cid: usize, rstart: usize, rend: usize) -> $slice { let col = self.col(cid); $slice::from_slice(rend - rstart, col.as_array().slice(rstart, rend)) @@ -339,19 +339,19 @@ macro_rules! row_impl( ($t: ident, $tv: ident, $dim: expr) => ( impl Row<$tv> for $t { #[inline] - fn nrows(&self) -> uint { + fn nrows(&self) -> usize { Dim::dim(None::<$t>) } #[inline] - fn set_row(&mut self, row: uint, v: $tv) { + fn set_row(&mut self, row: usize, v: $tv) { for (i, e) in v.iter().enumerate() { self.set((row, i), *e); } } #[inline] - fn row(&self, row: uint) -> $tv { + fn row(&self, row: usize) -> $tv { let mut res: $tv = ::zero(); for (i, e) in res.iter_mut().enumerate() { @@ -367,7 +367,7 @@ macro_rules! row_impl( macro_rules! row_slice_impl( ($t: ident, $tv: ident, $slice: ident, $dim: expr) => ( impl RowSlice<$slice> for $t { - fn row_slice(&self, rid: uint, cstart: uint, cend: uint) -> $slice { + fn row_slice(&self, rid: usize, cstart: usize, cend: usize) -> $slice { let row = self.row(rid); $slice::from_slice(cend - cstart, row.as_array().slice(cstart, cend)) @@ -380,19 +380,19 @@ macro_rules! col_impl( ($t: ident, $tv: ident, $dim: expr) => ( impl Col<$tv> for $t { #[inline] - fn ncols(&self) -> uint { + fn ncols(&self) -> usize { Dim::dim(None::<$t>) } #[inline] - fn set_col(&mut self, col: uint, v: $tv) { + fn set_col(&mut self, col: usize, v: $tv) { for (i, e) in v.iter().enumerate() { self.set((i, col), *e); } } #[inline] - fn col(&self, col: uint) -> $tv { + fn col(&self, col: usize) -> $tv { let mut res: $tv = ::zero(); for (i, e) in res.iter_mut().enumerate() { @@ -447,12 +447,12 @@ macro_rules! mat_mul_mat_impl( // careful! we need to comute other * self here (self is the rhs). let mut res: $t = ::zero(); - for i in range(0u, $dim) { - for j in range(0u, $dim) { + for i in range(0us, $dim) { + for j in range(0us, $dim) { let mut acc: N = ::zero(); unsafe { - for k in range(0u, $dim) { + for k in range(0us, $dim) { acc = acc + self.at_fast((i, k)) * right.at_fast((k, j)); } @@ -476,8 +476,8 @@ macro_rules! vec_mul_mat_impl( fn mul(self, right: $t) -> $v { let mut res : $v = $zero(); - for i in range(0u, $dim) { - for j in range(0u, $dim) { + for i in range(0us, $dim) { + for j in range(0us, $dim) { unsafe { let val = res.at_fast(i) + self.at_fast(j) * right.at_fast((j, i)); res.set_fast(i, val) @@ -500,8 +500,8 @@ macro_rules! mat_mul_vec_impl( fn mul(self, right: $v) -> $v { let mut res : $v = $zero(); - for i in range(0u, $dim) { - for j in range(0u, $dim) { + for i in range(0us, $dim) { + for j in range(0us, $dim) { unsafe { let val = res.at_fast(i) + self.at_fast((i, j)) * right.at_fast(j); res.set_fast(i, val) @@ -546,7 +546,7 @@ macro_rules! inv_impl( let mut res: $t = ::one(); // inversion using Gauss-Jordan elimination - for k in range(0u, $dim) { + for k in range(0us, $dim) { // search a non-zero value on the k-th column // FIXME: would it be worth it to spend some more time searching for the // max instead? @@ -567,7 +567,7 @@ macro_rules! inv_impl( // swap pivot line if n0 != k { - for j in range(0u, $dim) { + for j in range(0us, $dim) { self.swap((n0, j), (k, j)); res.swap((n0, j), (k, j)); } @@ -580,12 +580,12 @@ macro_rules! inv_impl( self.set((k, j), selfval); } - for j in range(0u, $dim) { + for j in range(0us, $dim) { let resval = res.at((k, j)) / pivot; res.set((k, j), resval); } - for l in range(0u, $dim) { + for l in range(0us, $dim) { if l != k { let normalizer = self.at((l, k)); @@ -594,7 +594,7 @@ macro_rules! inv_impl( self.set((l, j), selfval); } - for j in range(0u, $dim) { + for j in range(0us, $dim) { let resval = res.at((l, j)) - res.at((k, j)) * normalizer; res.set((l, j), resval); } @@ -623,8 +623,8 @@ macro_rules! transpose_impl( #[inline] fn transpose(&mut self) { - for i in range(1u, $dim) { - for j in range(0u, i) { + for i in range(1us, $dim) { + for j in range(0us, i) { self.swap((i, j), (j, i)) } } @@ -668,8 +668,8 @@ macro_rules! to_homogeneous_impl( fn to_homogeneous(&self) -> $t2 { let mut res: $t2 = ::one(); - for i in range(0u, $dim) { - for j in range(0u, $dim) { + for i in range(0us, $dim) { + for j in range(0us, $dim) { res.set((i, j), self.at((i, j))) } } @@ -687,8 +687,8 @@ macro_rules! from_homogeneous_impl( fn from(m: &$t2) -> $t { let mut res: $t = ::one(); - for i in range(0u, $dim2) { - for j in range(0u, $dim2) { + for i in range(0us, $dim2) { + for j in range(0us, $dim2) { res.set((i, j), m.at((i, j))) } } @@ -708,8 +708,8 @@ macro_rules! outer_impl( #[inline] fn outer(&self, other: &$t) -> $m { let mut res: $m = ::zero(); - for i in range(0u, Dim::dim(None::<$t>)) { - for j in range(0u, Dim::dim(None::<$t>)) { + for i in range(0us, Dim::dim(None::<$t>)) { + for j in range(0us, Dim::dim(None::<$t>)) { res.set((i, j), self.at(i) * other.at(j)) } } @@ -723,7 +723,7 @@ macro_rules! eigen_qr_impl( ($t: ident, $v: ident) => ( impl EigenQR> for $t where N: BaseFloat + ApproxEq + Clone { - fn eigen_qr(&self, eps: &N, niter: uint) -> ($t, $v) { + fn eigen_qr(&self, eps: &N, niter: usize) -> ($t, $v) { linalg::eigen_qr(self, eps, niter) } } diff --git a/src/structs/ortho.rs b/src/structs/ortho.rs index fd030bec..dc500561 100644 --- a/src/structs/ortho.rs +++ b/src/structs/ortho.rs @@ -96,7 +96,7 @@ impl Ortho3 { self.zfar = zfar } - /// Projects a point. + /// Projects a poisize. #[inline] pub fn project_pnt(&self, p: &Pnt3) -> Pnt3 { // FIXME: optimize that @@ -204,7 +204,7 @@ impl OrthoMat3 { self.mat.m34 = -(zfar + znear) / (zfar - znear); } - /// Projects a point. + /// Projects a poisize. #[inline] pub fn project_pnt(&self, p: &Pnt3) -> Pnt3 { Pnt3::new( diff --git a/src/structs/persp.rs b/src/structs/persp.rs index b4b98d70..dc43beb0 100644 --- a/src/structs/persp.rs +++ b/src/structs/persp.rs @@ -102,7 +102,7 @@ impl Persp3 { self.zfar = zfar; } - /// Projects a point. + /// Projects a poisize. #[inline] pub fn project_pnt(&self, p: &Pnt3) -> Pnt3 { // FIXME: optimize that @@ -231,7 +231,7 @@ impl PerspMat3 { self.mat.m34 = zfar * znear * _2 / (znear - zfar); } - /// Projects a point. + /// Projects a poisize. #[inline] pub fn project_pnt(&self, p: &Pnt3) -> Pnt3 { let _1: N = ::one(); diff --git a/src/structs/pnt.rs b/src/structs/pnt.rs index 4995c954..49bcf7a1 100644 --- a/src/structs/pnt.rs +++ b/src/structs/pnt.rs @@ -1,6 +1,6 @@ -//! Points with dimensions known at compile-time. +//! Poisizes with dimensions known at compile-time. -#![allow(missing_docs)] // we allow missing to avoid having to document the point components. +#![allow(missing_docs)] // we allow missing to avoid having to document the poisize components. use std::mem; use std::slice::{Iter, IterMut}; @@ -14,28 +14,28 @@ use traits::geometry::{Orig, FromHomogeneous, ToHomogeneous}; use structs::vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6}; -/// Point of dimension 0. +/// Poisize of dimension 0. #[derive(Eq, PartialEq, RustcDecodable, Clone, Rand, Show, Copy)] pub struct Pnt0; impl Pnt0 { - /// Creates a new point. + /// Creates a new poisize. #[inline] pub fn new() -> Pnt0 { Pnt0 } - /// Creates a new point. The parameter is not taken in account. + /// Creates a new poisize. The parameter is not taken in account. #[inline] pub fn new_repeat(_: N) -> Pnt0 { Pnt0 } } -/// Point of dimension 1. +/// Poisize of dimension 1. #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)] pub struct Pnt1 { - /// First component of the point. + /// First component of the poisize. pub x: N } @@ -70,12 +70,12 @@ pnt_to_homogeneous_impl!(Pnt1, Pnt2, y, x); pnt_from_homogeneous_impl!(Pnt1, Pnt2, y, x); num_float_pnt_impl!(Pnt1, Vec1); -/// Point of dimension 2. +/// Poisize of dimension 2. #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)] pub struct Pnt2 { - /// First component of the point. + /// First component of the poisize. pub x: N, - /// Second component of the point. + /// Second component of the poisize. pub y: N } @@ -110,14 +110,14 @@ pnt_to_homogeneous_impl!(Pnt2, Pnt3, z, x, y); pnt_from_homogeneous_impl!(Pnt2, Pnt3, z, x, y); num_float_pnt_impl!(Pnt2, Vec2); -/// Point of dimension 3. +/// Poisize of dimension 3. #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)] pub struct Pnt3 { - /// First component of the point. + /// First component of the poisize. pub x: N, - /// Second component of the point. + /// Second component of the poisize. pub y: N, - /// Third component of the point. + /// Third component of the poisize. pub z: N } @@ -152,16 +152,16 @@ pnt_to_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z); pnt_from_homogeneous_impl!(Pnt3, Pnt4, w, x, y, z); num_float_pnt_impl!(Pnt3, Vec3); -/// Point of dimension 4. +/// Poisize of dimension 4. #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)] pub struct Pnt4 { - /// First component of the point. + /// First component of the poisize. pub x: N, - /// Second component of the point. + /// Second component of the poisize. pub y: N, - /// Third component of the point. + /// Third component of the poisize. pub z: N, - /// Fourth component of the point. + /// Fourth component of the poisize. pub w: N } @@ -196,18 +196,18 @@ pnt_to_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w); pnt_from_homogeneous_impl!(Pnt4, Pnt5, a, x, y, z, w); num_float_pnt_impl!(Pnt4, Vec4); -/// Point of dimension 5. +/// Poisize of dimension 5. #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)] pub struct Pnt5 { - /// First component of the point. + /// First component of the poisize. pub x: N, - /// Second component of the point. + /// Second component of the poisize. pub y: N, - /// Third component of the point. + /// Third component of the poisize. pub z: N, - /// Fourth component of the point. + /// Fourth component of the poisize. pub w: N, - /// Fifth of the point. + /// Fifth of the poisize. pub a: N } @@ -242,20 +242,20 @@ pnt_to_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a); pnt_from_homogeneous_impl!(Pnt5, Pnt6, b, x, y, z, w, a); num_float_pnt_impl!(Pnt5, Vec5); -/// Point of dimension 6. +/// Poisize of dimension 6. #[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)] pub struct Pnt6 { - /// First component of the point. + /// First component of the poisize. pub x: N, - /// Second component of the point. + /// Second component of the poisize. pub y: N, - /// Third component of the point. + /// Third component of the poisize. pub z: N, - /// Fourth component of the point. + /// Fourth component of the poisize. pub w: N, - /// Fifth of the point. + /// Fifth of the poisize. pub a: N, - /// Sixth component of the point. + /// Sixth component of the poisize. pub b: N } diff --git a/src/structs/pnt_macros.rs b/src/structs/pnt_macros.rs index f026a246..e9d40e0f 100644 --- a/src/structs/pnt_macros.rs +++ b/src/structs/pnt_macros.rs @@ -60,7 +60,7 @@ macro_rules! pnt_sub_vec_impl( macro_rules! pnt_as_vec_impl( ($t: ident, $tv: ident, $($compN: ident),+) => ( impl $t { - /// Converts this point to its associated vector. + /// Converts this poisize to its associated vector. #[inline] pub fn to_vec(self) -> $tv { $tv::new( @@ -68,7 +68,7 @@ macro_rules! pnt_as_vec_impl( ) } - /// Converts a reference to this point to a reference to its associated vector. + /// Converts a reference to this poisize to a reference to its associated vector. #[inline] pub fn as_vec<'a>(&'a self) -> &'a $tv { unsafe { diff --git a/src/structs/rot.rs b/src/structs/rot.rs index 7c507e2a..e80733a0 100644 --- a/src/structs/rot.rs +++ b/src/structs/rot.rs @@ -167,14 +167,14 @@ impl Rot3 { } impl Rot3 { - /// Reorient this matrix such that its local `x` axis points to a given point. Note that the + /// Reorient this matrix such that its local `x` axis poisizes to a given poisize. Note that the /// usually known `look_at` function does the same thing but with the `z` axis. See `look_at_z` /// for that. /// /// # Arguments - /// * at - The point to look at. It is also the direction the matrix `x` axis will be aligned + /// * at - The poisize to look at. It is also the direction the matrix `x` axis will be aligned /// with - /// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear + /// * up - Vector poisizeing `up`. The only requirement of this parameter is to not be colinear /// with `at`. Non-colinearity is not checked. pub fn look_at(&mut self, at: &Vec3, up: &Vec3) { let xaxis = Norm::normalize_cpy(at); @@ -187,11 +187,11 @@ impl Rot3 { xaxis.z , yaxis.z , zaxis.z) } - /// Reorient this matrix such that its local `z` axis points to a given point. + /// Reorient this matrix such that its local `z` axis poisizes to a given poisize. /// /// # Arguments /// * at - The look direction, that is, direction the matrix `y` axis will be aligned with - /// * up - Vector pointing `up`. The only requirement of this parameter is to not be colinear + /// * up - Vector poisizeing `up`. The only requirement of this parameter is to not be colinear /// with `at`. Non-colinearity is not checked. pub fn look_at_z(&mut self, at: &Vec3, up: &Vec3) { let zaxis = Norm::normalize_cpy(at); diff --git a/src/structs/rot_macros.rs b/src/structs/rot_macros.rs index c49c8ac2..8c2077af 100644 --- a/src/structs/rot_macros.rs +++ b/src/structs/rot_macros.rs @@ -71,7 +71,7 @@ macro_rules! dim_impl( ($t: ident, $dim: expr) => ( impl Dim for $t { #[inline] - fn dim(_: Option<$t>) -> uint { + fn dim(_: Option<$t>) -> usize { $dim } } @@ -193,16 +193,16 @@ macro_rules! row_impl( ($t: ident, $tv: ident) => ( impl Row<$tv> for $t { #[inline] - fn nrows(&self) -> uint { + fn nrows(&self) -> usize { self.submat.nrows() } #[inline] - fn row(&self, i: uint) -> $tv { + fn row(&self, i: usize) -> $tv { self.submat.row(i) } #[inline] - fn set_row(&mut self, i: uint, row: $tv) { + fn set_row(&mut self, i: usize, row: $tv) { self.submat.set_row(i, row); } } @@ -213,16 +213,16 @@ macro_rules! col_impl( ($t: ident, $tv: ident) => ( impl Col<$tv> for $t { #[inline] - fn ncols(&self) -> uint { + fn ncols(&self) -> usize { self.submat.ncols() } #[inline] - fn col(&self, i: uint) -> $tv { + fn col(&self, i: usize) -> $tv { self.submat.col(i) } #[inline] - fn set_col(&mut self, i: uint, col: $tv) { + fn set_col(&mut self, i: usize, col: $tv) { self.submat.set_col(i, col); } } @@ -231,10 +231,10 @@ macro_rules! col_impl( macro_rules! index_impl( ($t: ident) => ( - impl Index<(uint, uint)> for $t { + impl Index<(usize, usize)> for $t { type Output = N; - fn index(&self, i: &(uint, uint)) -> &N { + fn index(&self, i: &(usize, usize)) -> &N { &self.submat[*i] } } diff --git a/src/structs/spec/complex.rs b/src/structs/spec/complex.rs index 7a06d180..2855ab7e 100644 --- a/src/structs/spec/complex.rs +++ b/src/structs/spec/complex.rs @@ -45,7 +45,7 @@ impl Inv for Cmplx { impl Dim for Cmplx { #[inline] - fn dim(unsused_self: Option>) -> uint { + fn dim(unsused_self: Option>) -> usize { 2 } } diff --git a/src/structs/spec/mat.rs b/src/structs/spec/mat.rs index 96635906..000b2ba9 100644 --- a/src/structs/spec/mat.rs +++ b/src/structs/spec/mat.rs @@ -132,12 +132,12 @@ impl Det for Mat3 { impl Row> for Mat3 { #[inline] - fn nrows(&self) -> uint { + fn nrows(&self) -> usize { 3 } #[inline] - fn row(&self, i: uint) -> Vec3 { + fn row(&self, i: usize) -> Vec3 { match i { 0 => Vec3::new(self.m11, self.m12, self.m13), 1 => Vec3::new(self.m21, self.m22, self.m23), @@ -147,7 +147,7 @@ impl Row> for Mat3 { } #[inline] - fn set_row(&mut self, i: uint, r: Vec3) { + fn set_row(&mut self, i: usize, r: Vec3) { match i { 0 => { self.m11 = r.x; @@ -172,12 +172,12 @@ impl Row> for Mat3 { impl Col> for Mat3 { #[inline] - fn ncols(&self) -> uint { + fn ncols(&self) -> usize { 3 } #[inline] - fn col(&self, i: uint) -> Vec3 { + fn col(&self, i: usize) -> Vec3 { match i { 0 => Vec3::new(self.m11, self.m21, self.m31), 1 => Vec3::new(self.m12, self.m22, self.m32), @@ -187,7 +187,7 @@ impl Col> for Mat3 { } #[inline] - fn set_col(&mut self, i: uint, r: Vec3) { + fn set_col(&mut self, i: usize, r: Vec3) { match i { 0 => { self.m11 = r.x; diff --git a/src/structs/spec/primitives.rs b/src/structs/spec/primitives.rs index e32fb15c..de9e6195 100644 --- a/src/structs/spec/primitives.rs +++ b/src/structs/spec/primitives.rs @@ -46,8 +46,8 @@ primitive_double_dispatch_cast_decl_trait!(u64, u64Cast); primitive_double_dispatch_cast_decl_trait!(u32, u32Cast); primitive_double_dispatch_cast_decl_trait!(u16, u16Cast); primitive_double_dispatch_cast_decl_trait!(u8, u8Cast); -primitive_double_dispatch_cast_decl_trait!(int, intCast); -primitive_double_dispatch_cast_decl_trait!(uint, uintCast); +primitive_double_dispatch_cast_decl_trait!(isize, isizeCast); +primitive_double_dispatch_cast_decl_trait!(usize, usizeCast); primitive_cast_redispatch_impl!(f64, f64Cast); primitive_cast_redispatch_impl!(f32, f32Cast); @@ -59,8 +59,8 @@ primitive_cast_redispatch_impl!(u64, u64Cast); primitive_cast_redispatch_impl!(u32, u32Cast); primitive_cast_redispatch_impl!(u16, u16Cast); primitive_cast_redispatch_impl!(u8, u8Cast); -primitive_cast_redispatch_impl!(int, intCast); -primitive_cast_redispatch_impl!(uint, uintCast); +primitive_cast_redispatch_impl!(isize, isizeCast); +primitive_cast_redispatch_impl!(usize, usizeCast); primitive_double_dispatch_cast_impl!(f64, f64, f64Cast); primitive_double_dispatch_cast_impl!(f64, f32, f64Cast); @@ -72,8 +72,8 @@ primitive_double_dispatch_cast_impl!(f64, u64, f64Cast); primitive_double_dispatch_cast_impl!(f64, u32, f64Cast); primitive_double_dispatch_cast_impl!(f64, u16, f64Cast); primitive_double_dispatch_cast_impl!(f64, u8, f64Cast); -primitive_double_dispatch_cast_impl!(f64, int, f64Cast); -primitive_double_dispatch_cast_impl!(f64, uint, f64Cast); +primitive_double_dispatch_cast_impl!(f64, isize, f64Cast); +primitive_double_dispatch_cast_impl!(f64, usize, f64Cast); primitive_double_dispatch_cast_impl!(f32, f64, f32Cast); primitive_double_dispatch_cast_impl!(f32, f32, f32Cast); @@ -85,8 +85,8 @@ primitive_double_dispatch_cast_impl!(f32, u64, f32Cast); primitive_double_dispatch_cast_impl!(f32, u32, f32Cast); primitive_double_dispatch_cast_impl!(f32, u16, f32Cast); primitive_double_dispatch_cast_impl!(f32, u8, f32Cast); -primitive_double_dispatch_cast_impl!(f32, int, f32Cast); -primitive_double_dispatch_cast_impl!(f32, uint, f32Cast); +primitive_double_dispatch_cast_impl!(f32, isize, f32Cast); +primitive_double_dispatch_cast_impl!(f32, usize, f32Cast); primitive_double_dispatch_cast_impl!(i64, f64, i64Cast); primitive_double_dispatch_cast_impl!(i64, f32, i64Cast); @@ -98,8 +98,8 @@ primitive_double_dispatch_cast_impl!(i64, u64, i64Cast); primitive_double_dispatch_cast_impl!(i64, u32, i64Cast); primitive_double_dispatch_cast_impl!(i64, u16, i64Cast); primitive_double_dispatch_cast_impl!(i64, u8, i64Cast); -primitive_double_dispatch_cast_impl!(i64, int, i64Cast); -primitive_double_dispatch_cast_impl!(i64, uint, i64Cast); +primitive_double_dispatch_cast_impl!(i64, isize, i64Cast); +primitive_double_dispatch_cast_impl!(i64, usize, i64Cast); primitive_double_dispatch_cast_impl!(i32, f64, i32Cast); primitive_double_dispatch_cast_impl!(i32, f32, i32Cast); @@ -111,8 +111,8 @@ primitive_double_dispatch_cast_impl!(i32, u64, i32Cast); primitive_double_dispatch_cast_impl!(i32, u32, i32Cast); primitive_double_dispatch_cast_impl!(i32, u16, i32Cast); primitive_double_dispatch_cast_impl!(i32, u8, i32Cast); -primitive_double_dispatch_cast_impl!(i32, int, i32Cast); -primitive_double_dispatch_cast_impl!(i32, uint, i32Cast); +primitive_double_dispatch_cast_impl!(i32, isize, i32Cast); +primitive_double_dispatch_cast_impl!(i32, usize, i32Cast); primitive_double_dispatch_cast_impl!(i16, f64, i16Cast); primitive_double_dispatch_cast_impl!(i16, f32, i16Cast); @@ -124,8 +124,8 @@ primitive_double_dispatch_cast_impl!(i16, u64, i16Cast); primitive_double_dispatch_cast_impl!(i16, u32, i16Cast); primitive_double_dispatch_cast_impl!(i16, u16, i16Cast); primitive_double_dispatch_cast_impl!(i16, u8, i16Cast); -primitive_double_dispatch_cast_impl!(i16, int, i16Cast); -primitive_double_dispatch_cast_impl!(i16, uint, i16Cast); +primitive_double_dispatch_cast_impl!(i16, isize, i16Cast); +primitive_double_dispatch_cast_impl!(i16, usize, i16Cast); primitive_double_dispatch_cast_impl!(i8, f64, i8Cast); primitive_double_dispatch_cast_impl!(i8, f32, i8Cast); @@ -137,8 +137,8 @@ primitive_double_dispatch_cast_impl!(i8, u64, i8Cast); primitive_double_dispatch_cast_impl!(i8, u32, i8Cast); primitive_double_dispatch_cast_impl!(i8, u16, i8Cast); primitive_double_dispatch_cast_impl!(i8, u8, i8Cast); -primitive_double_dispatch_cast_impl!(i8, int, i8Cast); -primitive_double_dispatch_cast_impl!(i8, uint, i8Cast); +primitive_double_dispatch_cast_impl!(i8, isize, i8Cast); +primitive_double_dispatch_cast_impl!(i8, usize, i8Cast); primitive_double_dispatch_cast_impl!(u64, f64, u64Cast); primitive_double_dispatch_cast_impl!(u64, f32, u64Cast); @@ -150,8 +150,8 @@ primitive_double_dispatch_cast_impl!(u64, u64, u64Cast); primitive_double_dispatch_cast_impl!(u64, u32, u64Cast); primitive_double_dispatch_cast_impl!(u64, u16, u64Cast); primitive_double_dispatch_cast_impl!(u64, u8, u64Cast); -primitive_double_dispatch_cast_impl!(u64, int, u64Cast); -primitive_double_dispatch_cast_impl!(u64, uint, u64Cast); +primitive_double_dispatch_cast_impl!(u64, isize, u64Cast); +primitive_double_dispatch_cast_impl!(u64, usize, u64Cast); primitive_double_dispatch_cast_impl!(u32, f64, u32Cast); primitive_double_dispatch_cast_impl!(u32, f32, u32Cast); @@ -163,8 +163,8 @@ primitive_double_dispatch_cast_impl!(u32, u64, u32Cast); primitive_double_dispatch_cast_impl!(u32, u32, u32Cast); primitive_double_dispatch_cast_impl!(u32, u16, u32Cast); primitive_double_dispatch_cast_impl!(u32, u8, u32Cast); -primitive_double_dispatch_cast_impl!(u32, int, u32Cast); -primitive_double_dispatch_cast_impl!(u32, uint, u32Cast); +primitive_double_dispatch_cast_impl!(u32, isize, u32Cast); +primitive_double_dispatch_cast_impl!(u32, usize, u32Cast); primitive_double_dispatch_cast_impl!(u16, f64, u16Cast); primitive_double_dispatch_cast_impl!(u16, f32, u16Cast); @@ -176,8 +176,8 @@ primitive_double_dispatch_cast_impl!(u16, u64, u16Cast); primitive_double_dispatch_cast_impl!(u16, u32, u16Cast); primitive_double_dispatch_cast_impl!(u16, u16, u16Cast); primitive_double_dispatch_cast_impl!(u16, u8, u16Cast); -primitive_double_dispatch_cast_impl!(u16, int, u16Cast); -primitive_double_dispatch_cast_impl!(u16, uint, u16Cast); +primitive_double_dispatch_cast_impl!(u16, isize, u16Cast); +primitive_double_dispatch_cast_impl!(u16, usize, u16Cast); primitive_double_dispatch_cast_impl!(u8, f64, u8Cast); primitive_double_dispatch_cast_impl!(u8, f32, u8Cast); @@ -189,31 +189,31 @@ primitive_double_dispatch_cast_impl!(u8, u64, u8Cast); primitive_double_dispatch_cast_impl!(u8, u32, u8Cast); primitive_double_dispatch_cast_impl!(u8, u16, u8Cast); primitive_double_dispatch_cast_impl!(u8, u8, u8Cast); -primitive_double_dispatch_cast_impl!(u8, int, u8Cast); -primitive_double_dispatch_cast_impl!(u8, uint, u8Cast); +primitive_double_dispatch_cast_impl!(u8, isize, u8Cast); +primitive_double_dispatch_cast_impl!(u8, usize, u8Cast); -primitive_double_dispatch_cast_impl!(uint, f64, uintCast); -primitive_double_dispatch_cast_impl!(uint, f32, uintCast); -primitive_double_dispatch_cast_impl!(uint, i64, uintCast); -primitive_double_dispatch_cast_impl!(uint, i32, uintCast); -primitive_double_dispatch_cast_impl!(uint, i16, uintCast); -primitive_double_dispatch_cast_impl!(uint, i8, uintCast); -primitive_double_dispatch_cast_impl!(uint, u64, uintCast); -primitive_double_dispatch_cast_impl!(uint, u32, uintCast); -primitive_double_dispatch_cast_impl!(uint, u16, uintCast); -primitive_double_dispatch_cast_impl!(uint, u8, uintCast); -primitive_double_dispatch_cast_impl!(uint, int, uintCast); -primitive_double_dispatch_cast_impl!(uint, uint, uintCast); +primitive_double_dispatch_cast_impl!(usize, f64, usizeCast); +primitive_double_dispatch_cast_impl!(usize, f32, usizeCast); +primitive_double_dispatch_cast_impl!(usize, i64, usizeCast); +primitive_double_dispatch_cast_impl!(usize, i32, usizeCast); +primitive_double_dispatch_cast_impl!(usize, i16, usizeCast); +primitive_double_dispatch_cast_impl!(usize, i8, usizeCast); +primitive_double_dispatch_cast_impl!(usize, u64, usizeCast); +primitive_double_dispatch_cast_impl!(usize, u32, usizeCast); +primitive_double_dispatch_cast_impl!(usize, u16, usizeCast); +primitive_double_dispatch_cast_impl!(usize, u8, usizeCast); +primitive_double_dispatch_cast_impl!(usize, isize, usizeCast); +primitive_double_dispatch_cast_impl!(usize, usize, usizeCast); -primitive_double_dispatch_cast_impl!(int, f64, intCast); -primitive_double_dispatch_cast_impl!(int, f32, intCast); -primitive_double_dispatch_cast_impl!(int, i64, intCast); -primitive_double_dispatch_cast_impl!(int, i32, intCast); -primitive_double_dispatch_cast_impl!(int, i16, intCast); -primitive_double_dispatch_cast_impl!(int, i8, intCast); -primitive_double_dispatch_cast_impl!(int, u64, intCast); -primitive_double_dispatch_cast_impl!(int, u32, intCast); -primitive_double_dispatch_cast_impl!(int, u16, intCast); -primitive_double_dispatch_cast_impl!(int, u8, intCast); -primitive_double_dispatch_cast_impl!(int, int, intCast); -primitive_double_dispatch_cast_impl!(int, uint, intCast); +primitive_double_dispatch_cast_impl!(isize, f64, isizeCast); +primitive_double_dispatch_cast_impl!(isize, f32, isizeCast); +primitive_double_dispatch_cast_impl!(isize, i64, isizeCast); +primitive_double_dispatch_cast_impl!(isize, i32, isizeCast); +primitive_double_dispatch_cast_impl!(isize, i16, isizeCast); +primitive_double_dispatch_cast_impl!(isize, i8, isizeCast); +primitive_double_dispatch_cast_impl!(isize, u64, isizeCast); +primitive_double_dispatch_cast_impl!(isize, u32, isizeCast); +primitive_double_dispatch_cast_impl!(isize, u16, isizeCast); +primitive_double_dispatch_cast_impl!(isize, u8, isizeCast); +primitive_double_dispatch_cast_impl!(isize, isize, isizeCast); +primitive_double_dispatch_cast_impl!(isize, usize, isizeCast); diff --git a/src/structs/spec/vec.rs b/src/structs/spec/vec.rs index c1485536..adc04f6a 100644 --- a/src/structs/spec/vec.rs +++ b/src/structs/spec/vec.rs @@ -48,12 +48,12 @@ impl + Zero + Copy> CrossMatrix> for Vec3 { // FIXME: implement this for all other vectors impl Row> for Vec2 { #[inline] - fn nrows(&self) -> uint { + fn nrows(&self) -> usize { 2 } #[inline] - fn row(&self, i: uint) -> Vec1 { + fn row(&self, i: usize) -> Vec1 { match i { 0 => Vec1::new(self.x), 1 => Vec1::new(self.y), @@ -62,7 +62,7 @@ impl Row> for Vec2 { } #[inline] - fn set_row(&mut self, i: uint, r: Vec1) { + fn set_row(&mut self, i: usize, r: Vec1) { match i { 0 => self.x = r.x, 1 => self.y = r.x, @@ -82,7 +82,7 @@ impl Basis for Vec1 { fn orthonormal_subspace_basis) -> bool>(_: &Vec1, _: F) { } #[inline] - fn canonical_basis_element(i: uint) -> Option> { + fn canonical_basis_element(i: usize) -> Option> { if i == 0 { Some(Vec1::new(::one())) } @@ -105,7 +105,7 @@ impl> Basis for Vec2 { } #[inline] - fn canonical_basis_element(i: uint) -> Option> { + fn canonical_basis_element(i: usize) -> Option> { if i == 0 { Some(Vec2::new(::one(), ::zero())) } @@ -141,7 +141,7 @@ impl Basis for Vec3 { } #[inline] - fn canonical_basis_element(i: uint) -> Option> { + fn canonical_basis_element(i: usize) -> Option> { if i == 0 { Some(Vec3::new(::one(), ::zero(), ::zero())) } diff --git a/src/structs/spec/vec0.rs b/src/structs/spec/vec0.rs index 713c874e..90d4b3d9 100644 --- a/src/structs/spec/vec0.rs +++ b/src/structs/spec/vec0.rs @@ -20,52 +20,52 @@ impl Zero for vec::Vec0 { } } -impl Index for vec::Vec0 { +impl Index for vec::Vec0 { type Output = N; #[inline] - fn index(&self, _: &uint) -> &N { + fn index(&self, _: &usize) -> &N { panic!("Canot index a Vec0.") } } -impl IndexMut for vec::Vec0 { +impl IndexMut for vec::Vec0 { type Output = N; #[inline] - fn index_mut(&mut self, _: &uint) -> &mut N { + fn index_mut(&mut self, _: &usize) -> &mut N { panic!("Canot index a Vec0.") } } -impl Shape for vec::Vec0 { +impl Shape for vec::Vec0 { #[inline] - fn shape(&self) -> uint { + fn shape(&self) -> usize { 0 } } -impl Indexable for vec::Vec0 { +impl Indexable for vec::Vec0 { #[inline] - fn at(&self, _: uint) -> N { + fn at(&self, _: usize) -> N { panic!("Cannot index a Vec0.") } #[inline] - fn set(&mut self, _: uint, _: N) { + fn set(&mut self, _: usize, _: N) { } #[inline] - fn swap(&mut self, _: uint, _: uint) { + fn swap(&mut self, _: usize, _: usize) { } #[inline] - unsafe fn unsafe_at(&self, _: uint) -> N { + unsafe fn unsafe_at(&self, _: usize) -> N { panic!("Cannot index a Vec0.") } #[inline] - unsafe fn unsafe_set(&mut self, _: uint, _: N) { + unsafe fn unsafe_set(&mut self, _: usize, _: N) { } } @@ -85,7 +85,7 @@ impl IterableMut for vec::Vec0 { impl Dim for vec::Vec0 { #[inline] - fn dim(_: Option>) -> uint { + fn dim(_: Option>) -> usize { 0 } } @@ -98,7 +98,7 @@ impl Basis for vec::Vec0 { fn orthonormal_subspace_basis) -> bool>(_: &vec::Vec0, _: F) { } #[inline(always)] - fn canonical_basis_element(_: uint) -> Option> { + fn canonical_basis_element(_: usize) -> Option> { None } } diff --git a/src/structs/vec_macros.rs b/src/structs/vec_macros.rs index 8c781e74..58b59f80 100644 --- a/src/structs/vec_macros.rs +++ b/src/structs/vec_macros.rs @@ -62,13 +62,13 @@ macro_rules! at_fast_impl( impl $t { /// Unsafe read access to a vector element by index. #[inline] - pub unsafe fn at_fast(&self, i: uint) -> N { + pub unsafe fn at_fast(&self, i: usize) -> N { (*self.as_array().get_unchecked(i)) } /// Unsafe write access to a vector element by index. #[inline] - pub unsafe fn set_fast(&mut self, i: uint, val: N) { + pub unsafe fn set_fast(&mut self, i: usize, val: N) { (*self.as_array_mut().get_unchecked_mut(i)) = val } } @@ -182,42 +182,42 @@ macro_rules! vec_cast_impl( macro_rules! indexable_impl( ($t: ident, $dim: expr) => ( - impl Shape for $t { + impl Shape for $t { #[inline] - fn shape(&self) -> uint { + fn shape(&self) -> usize { $dim } } - impl Indexable for $t { + impl Indexable for $t { #[inline] - fn at(&self, i: uint) -> N { + fn at(&self, i: usize) -> N { unsafe { mem::transmute::<&$t, &[N; $dim]>(self)[i] } } #[inline] - fn set(&mut self, i: uint, val: N) { + fn set(&mut self, i: usize, val: N) { unsafe { mem::transmute::<&mut $t, &mut [N; $dim]>(self)[i] = val } } #[inline] - fn swap(&mut self, i1: uint, i2: uint) { + fn swap(&mut self, i1: usize, i2: usize) { unsafe { mem::transmute::<&mut $t, &mut [N; $dim]>(self).swap(i1, i2) } } #[inline] - unsafe fn unsafe_at(&self, i: uint) -> N { + unsafe fn unsafe_at(&self, i: usize) -> N { (*mem::transmute::<&$t, &[N; $dim]>(self).get_unchecked(i)) } #[inline] - unsafe fn unsafe_set(&mut self, i: uint, val: N) { + unsafe fn unsafe_set(&mut self, i: usize, val: N) { (*mem::transmute::<&mut $t, &mut [N; $dim]>(self).get_unchecked_mut(i)) = val } } @@ -226,18 +226,18 @@ macro_rules! indexable_impl( macro_rules! index_impl( ($t: ident) => ( - impl Index for $t { + impl Index for $t { type Output = N; - fn index(&self, i: &uint) -> &N { + fn index(&self, i: &usize) -> &N { &self.as_array()[*i] } } - impl IndexMut for $t { + impl IndexMut for $t { type Output = N; - fn index_mut(&mut self, i: &uint) -> &mut N { + fn index_mut(&mut self, i: &usize) -> &mut N { &mut self.as_array_mut()[*i] } } @@ -288,7 +288,7 @@ macro_rules! dim_impl( ($t: ident, $dim: expr) => ( impl Dim for $t { #[inline] - fn dim(_: Option<$t>) -> uint { + fn dim(_: Option<$t>) -> usize { $dim } } @@ -299,7 +299,7 @@ macro_rules! container_impl( ($t: ident) => ( impl $t { #[inline] - pub fn len(&self) -> uint { + pub fn len(&self) -> usize { Dim::dim(None::<$t>) } } @@ -311,7 +311,7 @@ macro_rules! basis_impl( impl> Basis for $t { #[inline] fn canonical_basis) -> bool>(mut f: F) { - for i in range(0u, $dim) { + for i in range(0us, $dim) { if !f(Basis::canonical_basis_element(i).unwrap()) { return } } } @@ -322,7 +322,7 @@ macro_rules! basis_impl( // orthogonalization algorithm let mut basis: Vec<$t> = Vec::new(); - for i in range(0u, $dim) { + for i in range(0us, $dim) { let mut basis_element : $t = ::zero(); unsafe { @@ -352,7 +352,7 @@ macro_rules! basis_impl( } #[inline] - fn canonical_basis_element(i: uint) -> Option<$t> { + fn canonical_basis_element(i: usize) -> Option<$t> { if i < $dim { let mut basis_element : $t = ::zero(); diff --git a/src/traits/geometry.rs b/src/traits/geometry.rs index f797db14..e5c1d67b 100644 --- a/src/traits/geometry.rs +++ b/src/traits/geometry.rs @@ -30,7 +30,7 @@ pub trait Translation { } /// Trait of objects able to translate other objects. This is typically -/// implemented by vectors to translate points. +/// implemented by vectors to translate poisizes. pub trait Translate { /// Apply a translation to an object. fn translate(&self, &V) -> V; @@ -77,20 +77,20 @@ pub trait Rotate { /// Various composition of rotation and translation. /// -/// Utilities to make rotations with regard to a point different than the origin. All those +/// Utilities to make rotations with regard to a poisize different than the origin. All those /// operations are the composition of rotations and translations. /// /// Those operations are automatically implemented in term of the `Rotation` and `Translation` /// traits. pub trait RotationWithTranslation + Copy, AV>: Rotation + Translation + Sized { - /// Applies a rotation centered on a specific point. + /// Applies a rotation centered on a specific poisize. /// /// # Arguments /// * `t` - the object to be rotated. /// * `amount` - the rotation to apply. - /// * `point` - the center of rotation. + /// * `poisize` - the center of rotation. #[inline] - fn append_rotation_wrt_point_cpy(&self, amount: &AV, center: &LV) -> Self { + fn append_rotation_wrt_poisize_cpy(&self, amount: &AV, center: &LV) -> Self { let mut res = Translation::append_translation_cpy(self, &-*center); res.append_rotation(amount); @@ -107,7 +107,7 @@ pub trait RotationWithTranslation + Copy, AV>: Rotation /// * `amount` - the rotation to be applied /// * `center` - the new center of rotation #[inline] - fn append_rotation_wrt_point(&mut self, amount: &AV, center: &LV) { + fn append_rotation_wrt_poisize(&mut self, amount: &AV, center: &LV) { self.append_translation(&-*center); self.append_rotation(amount); self.append_translation(center); @@ -120,7 +120,7 @@ pub trait RotationWithTranslation + Copy, AV>: Rotation /// * `amount` - the rotation to apply. #[inline] fn append_rotation_wrt_center_cpy(&self, amount: &AV) -> Self { - RotationWithTranslation::append_rotation_wrt_point_cpy(self, amount, &self.translation()) + RotationWithTranslation::append_rotation_wrt_poisize_cpy(self, amount, &self.translation()) } /// Applies a rotation centered on the translation of `m`. @@ -132,7 +132,7 @@ pub trait RotationWithTranslation + Copy, AV>: Rotation #[inline] fn append_rotation_wrt_center(&mut self, amount: &AV) { let center = self.translation(); - self.append_rotation_wrt_point(amount, ¢er) + self.append_rotation_wrt_poisize(amount, ¢er) } } @@ -274,6 +274,6 @@ pub trait UniformSphereSample { pub trait Orig { /// The trivial origin. fn orig() -> Self; - /// Returns true if this points is exactly the trivial origin. + /// Returns true if this poisizes is exactly the trivial origin. fn is_orig(&self) -> bool; } diff --git a/src/traits/operations.rs b/src/traits/operations.rs index 75281e71..b04e5f47 100644 --- a/src/traits/operations.rs +++ b/src/traits/operations.rs @@ -71,7 +71,7 @@ impl POrdering { } } -/// Pointwise ordering operations. +/// Poisizewise ordering operations. pub trait POrd { /// Returns the infimum of this value and another fn inf(&self, other: &Self) -> Self; @@ -193,8 +193,8 @@ impl ApproxEq for f32 { // Otherwise, differing signs should be not-equal, even if within ulps if self.signum() != other.signum() { return false; } - // IEEE754 floats are in the same order as 2s complement ints - // so this trick (subtracting the ints) works. + // IEEE754 floats are in the same order as 2s complement isizes + // so this trick (subtracting the isizes) works. let iself: i32 = unsafe { ::std::mem::transmute(*self) }; let iother: i32 = unsafe { ::std::mem::transmute(*other) }; @@ -298,7 +298,7 @@ pub trait Mean { /// Trait for computing the eigenvector and eigenvalues of a square matrix usin the QR algorithm. pub trait EigenQR: SquareMat { /// Computes the eigenvectors and eigenvalues of this matrix. - fn eigen_qr(&self, eps: &N, niter: uint) -> (Self, V); + fn eigen_qr(&self, eps: &N, niter: usize) -> (Self, V); } // XXX: those two traits should not exist since there is generalized operator overloading of Add @@ -404,12 +404,12 @@ impl_absolute!(i8); impl_absolute!(i16); impl_absolute!(i32); impl_absolute!(i64); -impl_absolute!(int); +impl_absolute!(isize); impl_absolute_id!(u8); impl_absolute_id!(u16); impl_absolute_id!(u32); impl_absolute_id!(u64); -impl_absolute_id!(uint); +impl_absolute_id!(usize); macro_rules! impl_axpy( ($n: ty) => { @@ -428,9 +428,9 @@ impl_axpy!(i8); impl_axpy!(i16); impl_axpy!(i32); impl_axpy!(i64); -impl_axpy!(int); +impl_axpy!(isize); impl_axpy!(u8); impl_axpy!(u16); impl_axpy!(u32); impl_axpy!(u64); -impl_axpy!(uint); +impl_axpy!(usize); diff --git a/src/traits/structure.rs b/src/traits/structure.rs index 3aeaa7dd..4fd20c7d 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -8,7 +8,7 @@ use std::ops::{Add, Sub, Mul, Div, Neg, Rem, Index, IndexMut}; use traits::operations::{RMul, LMul, Axpy, Transpose, Inv, Absolute}; use traits::geometry::{Dot, Norm, Orig}; -/// Basic integral numeric trait. +/// Basic isizeegral numeric trait. pub trait BaseNum: Copy + Zero + One + Add + Sub + Mul + Div + @@ -16,7 +16,7 @@ pub trait BaseNum: Copy + Zero + One + Absolute + Axpy { } -/// Basic floating-point number numeric trait. +/// Basic floating-poisize number numeric trait. pub trait BaseFloat: Float + BaseNum { /// Archimedes' constant. fn pi() -> Self; @@ -60,10 +60,10 @@ pub trait Cast { /// Trait of matrices. /// /// A matrix has rows and columns and are able to multiply them. -pub trait Mat: Row + Col + RMul + LMul + Index<(uint, uint), Output = N> { } +pub trait Mat: Row + Col + RMul + LMul + Index<(usize, usize), Output = N> { } impl Mat for M - where M: Row + Col + RMul + LMul + Index<(uint, uint), Output = N> { + where M: Row + Col + RMul + LMul + Index<(usize, usize), Output = N> { } /// Trait implemented by square matrices. @@ -78,7 +78,7 @@ impl SquareMat for M /// Trait for constructing the identity matrix pub trait Eye { /// Return the identity matrix of specified dimension - fn new_identity(dim: uint) -> Self; + fn new_identity(dim: usize) -> Self; } /// Additive identity. @@ -115,17 +115,17 @@ pub trait Basis { fn orthonormal_subspace_basis bool>(&Self, F); /// Gets the ith element of the canonical basis. - fn canonical_basis_element(i: uint) -> Option; + fn canonical_basis_element(i: usize) -> Option; } /// Trait to access rows of a matrix or a vector. pub trait Row { /// The number of column of `self`. - fn nrows(&self) -> uint; + fn nrows(&self) -> usize; /// Reads the `i`-th row of `self`. - fn row(&self, i: uint) -> R; + fn row(&self, i: usize) -> R; /// Writes the `i`-th row of `self`. - fn set_row(&mut self, i: uint, R); + fn set_row(&mut self, i: usize, R); // FIXME: add iterators on rows: this could be a very good way to generalize _and_ optimize // a lot of operations. @@ -134,13 +134,13 @@ pub trait Row { /// Trait to access columns of a matrix or vector. pub trait Col { /// The number of column of this matrix or vector. - fn ncols(&self) -> uint; + fn ncols(&self) -> usize; /// Reads the `i`-th column of `self`. - fn col(&self, i: uint) -> C; + fn col(&self, i: usize) -> C; /// Writes the `i`-th column of `self`. - fn set_col(&mut self, i: uint, C); + fn set_col(&mut self, i: usize, C); // FIXME: add iterators on columns: this could be a very good way to generalize _and_ optimize // a lot of operations. @@ -149,19 +149,19 @@ pub trait Col { /// Trait to access part of a column of a matrix pub trait ColSlice { /// Returns a view to a slice of a column of a matrix. - fn col_slice(&self, col_id: uint, row_start: uint, row_end: uint) -> C; + fn col_slice(&self, col_id: usize, row_start: usize, row_end: usize) -> C; } /// Trait to access part of a row of a matrix pub trait RowSlice { /// Returns a view to a slice of a row of a matrix. - fn row_slice(&self, row_id: uint, col_start: uint, col_end: uint) -> R; + fn row_slice(&self, row_id: usize, col_start: usize, col_end: usize) -> R; } /// Trait of objects having a spacial dimension known at compile time. pub trait Dim { /// The dimension of the object. - fn dim(unused_self: Option) -> uint; + fn dim(unused_self: Option) -> usize; } /// Trait to get the diagonal of square matrices. @@ -226,13 +226,13 @@ pub trait IterableMut { /* * Vec related traits. */ -/// Trait that relates a point of an affine space to a vector of the associated vector space. -#[deprecated = "This will be removed in the future. Use point + vector operations instead."] +/// Trait that relates a poisize of an affine space to a vector of the associated vector space. +#[deprecated = "This will be removed in the future. Use poisize + vector operations instead."] pub trait VecAsPnt

{ - /// Converts this point to its associated vector. + /// Converts this poisize to its associated vector. fn to_pnt(self) -> P; - /// Converts a reference to this point to a reference to its associated vector. + /// Converts a reference to this poisize to a reference to its associated vector. fn as_pnt<'a>(&'a self) -> &'a P; } @@ -241,7 +241,7 @@ pub trait NumVec: Dim + Sub + Add + Mul + Div + Neg + - Index + + Index + Zero + PartialEq + Dot + Axpy { } @@ -252,21 +252,21 @@ pub trait FloatVec: NumVec + Norm + Basis { /* * Pnt related traits. */ -/// Trait that relates a point of an affine space to a vector of the associated vector space. +/// Trait that relates a poisize of an affine space to a vector of the associated vector space. pub trait PntAsVec { - /// Converts this point to its associated vector. + /// Converts this poisize to its associated vector. fn to_vec(self) -> V; - /// Converts a reference to this point to a reference to its associated vector. + /// Converts a reference to this poisize to a reference to its associated vector. fn as_vec<'a>(&'a self) -> &'a V; // NOTE: this is used in some places to overcome some limitations untill the trait reform is // done on rustc. - /// Sets the coordinates of this point to match those of a given vector. + /// Sets the coordinates of this poisize to match those of a given vector. fn set_coords(&mut self, coords: V); } -/// Trait grouping most common operations on points. +/// Trait grouping most common operations on poisizes. // XXX: the vector space element `V` should be an associated type. Though this would prevent V from // having bounds (they are not supported yet). So, for now, we will just use a type parameter. pub trait NumPnt: @@ -281,18 +281,18 @@ pub trait NumPnt: Mul + Div + Add + - Index { // FIXME: + Sub + Index { // FIXME: + Sub } -/// Trait of points with components implementing the `BaseFloat` trait. +/// Trait of poisizes with components implementing the `BaseFloat` trait. pub trait FloatPnt>: NumPnt + Sized { - /// Computes the square distance between two points. + /// Computes the square distance between two poisizes. #[inline] fn sqdist(&self, other: &Self) -> N { (*self - *other).sqnorm() } - /// Computes the distance between two points. + /// Computes the distance between two poisizes. #[inline] fn dist(&self, other: &Self) -> N { (*self - *other).norm() @@ -338,12 +338,12 @@ impl_zero_one!(i8, 0, 1); impl_zero_one!(i16, 0, 1); impl_zero_one!(i32, 0, 1); impl_zero_one!(i64, 0, 1); -impl_zero_one!(int, 0, 1); +impl_zero_one!(isize, 0, 1); impl_zero_one!(u8, 0, 1); impl_zero_one!(u16, 0, 1); impl_zero_one!(u32, 0, 1); impl_zero_one!(u64, 0, 1); -impl_zero_one!(uint, 0, 1); +impl_zero_one!(usize, 0, 1); // Bounded @@ -369,12 +369,12 @@ impl_bounded!(i8, Int::min_value(), Int::max_value()); impl_bounded!(i16, Int::min_value(), Int::max_value()); impl_bounded!(i32, Int::min_value(), Int::max_value()); impl_bounded!(i64, Int::min_value(), Int::max_value()); -impl_bounded!(int, Int::min_value(), Int::max_value()); +impl_bounded!(isize, Int::min_value(), Int::max_value()); impl_bounded!(u8, Int::min_value(), Int::max_value()); impl_bounded!(u16, Int::min_value(), Int::max_value()); impl_bounded!(u32, Int::min_value(), Int::max_value()); impl_bounded!(u64, Int::min_value(), Int::max_value()); -impl_bounded!(uint, Int::min_value(), Int::max_value()); +impl_bounded!(usize, Int::min_value(), Int::max_value()); // BaseFloat diff --git a/tests/mat.rs b/tests/mat.rs index 5755b394..b1c884fc 100644 --- a/tests/mat.rs +++ b/tests/mat.rs @@ -6,7 +6,7 @@ use na::{Vec1, Vec3, Mat1, Mat2, Mat3, Mat4, Mat5, Mat6, Rot3, Persp3, PerspMat3 macro_rules! test_inv_mat_impl( ($t: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let randmat : $t = random(); match na::inv(&randmat) { @@ -19,7 +19,7 @@ macro_rules! test_inv_mat_impl( macro_rules! test_transpose_mat_impl( ($t: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let randmat : $t = random(); assert!(na::transpose(&na::transpose(&randmat)) == randmat); @@ -29,7 +29,7 @@ macro_rules! test_transpose_mat_impl( macro_rules! test_qr_impl( ($t: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let randmat : $t = random(); let (q, r) = na::qr(&randmat); @@ -43,7 +43,7 @@ macro_rules! test_qr_impl( // NOTE: deactivated untile we get a better convergence rate. // macro_rules! test_eigen_qr_impl( // ($t: ty) => { -// for _ in range(0u, 10000) { +// for _ in range(0us, 10000) { // let randmat : $t = random(); // // Make it symetric so that we can recompose the matrix to test at the end. // let randmat = na::transpose(&randmat) * randmat; @@ -54,9 +54,9 @@ macro_rules! test_qr_impl( // // let recomp = eigenvectors * diag * na::transpose(&eigenvectors); // -// println!("eigenvalues: {}", eigenvalues); -// println!(" mat: {}", randmat); -// println!("recomp: {}", recomp); +// prisizeln!("eigenvalues: {}", eigenvalues); +// prisizeln!(" mat: {}", randmat); +// prisizeln!("recomp: {}", recomp); // // assert!(na::approx_eq_eps(&randmat, &recomp, &1.0e-2)); // } @@ -125,7 +125,7 @@ fn test_inv_mat6() { #[test] fn test_rotation2() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let randmat: na::Rot2 = na::one(); let ang = Vec1::new(na::abs(&random::()) % BaseFloat::pi()); @@ -142,7 +142,7 @@ fn test_index_mat2() { #[test] fn test_inv_rotation3() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let randmat: Rot3 = na::one(); let dir: Vec3 = random(); let ang = na::normalize(&dir) * (na::abs(&random::()) % BaseFloat::pi()); @@ -200,7 +200,7 @@ fn test_transpose_dmat() { 8, 4, &[ - 1u32,2, 3, 4, + 1us32,2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, @@ -242,7 +242,7 @@ fn test_dmat_from_vec() { ] ); - println!("mat1: {:?}, mat2: {:?}", mat1, mat2); + prisizeln!("mat1: {:?}, mat2: {:?}", mat1, mat2); assert!(mat1 == mat2); } @@ -250,9 +250,9 @@ fn test_dmat_from_vec() { /* FIXME: review qr decomposition to make it work with DMat. #[test] fn test_qr() { - for _ in range(0u, 10) { - let dim1: uint = random(); - let dim2: uint = random(); + for _ in range(0us, 10) { + let dim1: usize = random(); + let dim2: usize = random(); let rows = min(40, max(dim1, dim2)); let cols = min(40, min(dim1, dim2)); let randmat: DMat = DMat::new_random(rows, cols); @@ -327,8 +327,8 @@ fn test_qr_mat6() { #[test] fn test_from_fn() { - let actual: DMat = DMat::from_fn(3, 4, |i, j| 10 * i + j); - let expected: DMat = DMat::from_row_vec(3, 4, + let actual: DMat = DMat::from_fn(3, 4, |i, j| 10 * i + j); + let expected: DMat = DMat::from_row_vec(3, 4, &[ 0_0, 0_1, 0_2, 0_3, 1_0, 1_1, 1_2, 1_3, 2_0, 2_1, 2_2, 2_3 ]); diff --git a/tests/quat.rs b/tests/quat.rs index 11ec293f..df8a34c0 100644 --- a/tests/quat.rs +++ b/tests/quat.rs @@ -5,7 +5,7 @@ use std::rand::random; #[test] fn test_quat_as_mat() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let axis_angle: Vec3 = random(); assert!(na::approx_eq(&UnitQuat::new(axis_angle).to_rot(), &Rot3::new(axis_angle))) @@ -14,7 +14,7 @@ fn test_quat_as_mat() { #[test] fn test_quat_mul_vec_or_pnt_as_mat() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let axis_angle: Vec3 = random(); let vec: Vec3 = random(); let pnt: Pnt3 = random(); @@ -31,7 +31,7 @@ fn test_quat_mul_vec_or_pnt_as_mat() { #[test] fn test_quat_div_quat() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let axis_angle1: Vec3 = random(); let axis_angle2: Vec3 = random(); @@ -47,19 +47,19 @@ fn test_quat_div_quat() { #[test] fn test_quat_to_axis_angle() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let axis_angle: Vec3 = random(); let q = UnitQuat::new(axis_angle); - println!("{:?} {:?}", q.rotation(), axis_angle); + prisizeln!("{:?} {:?}", q.rotation(), axis_angle); assert!(na::approx_eq(&q.rotation(), &axis_angle)) } } #[test] fn test_quat_euler_angles() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let angles: Vec3 = random(); let q = UnitQuat::new_with_euler_angles(angles.x, angles.y, angles.z); diff --git a/tests/vec.rs b/tests/vec.rs index 8af66537..44105f08 100644 --- a/tests/vec.rs +++ b/tests/vec.rs @@ -5,7 +5,7 @@ use na::{Vec0, Vec1, Vec2, Vec3, Vec4, Vec5, Vec6, Mat3, Iterable, IterableMut}; macro_rules! test_iterator_impl( ($t: ty, $n: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let v: $t = random(); let mut mv: $t = v.clone(); let n: $n = random(); @@ -23,7 +23,7 @@ macro_rules! test_iterator_impl( macro_rules! test_commut_dot_impl( ($t: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let v1 : $t = random(); let v2 : $t = random(); @@ -34,7 +34,7 @@ macro_rules! test_commut_dot_impl( macro_rules! test_scalar_op_impl( ($t: ty, $n: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let v1 : $t = random(); let n : $n = random(); @@ -57,7 +57,7 @@ macro_rules! test_scalar_op_impl( macro_rules! test_basis_impl( ($t: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { na::canonical_basis(|e1: $t| { na::canonical_basis(|e2: $t| { assert!(e1 == e2 || na::approx_eq(&na::dot(&e1, &e2), &na::zero())); @@ -75,7 +75,7 @@ macro_rules! test_basis_impl( macro_rules! test_subspace_basis_impl( ($t: ty) => ( - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let v : $t = random(); let v1 = na::normalize(&v); @@ -99,7 +99,7 @@ macro_rules! test_subspace_basis_impl( #[test] fn test_cross_vec3() { - for _ in range(0u, 10000) { + for _ in range(0us, 10000) { let v1 : Vec3 = random(); let v2 : Vec3 = random(); let v3 : Vec3 = na::cross(&v1, &v2);