Replace int, and uint, by isize and usize.

This commit is contained in:
Sébastien Crozet 2015-01-09 22:26:05 +01:00
parent 59316d7ca1
commit e6e099b7c4
28 changed files with 395 additions and 395 deletions

View File

@ -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();

View File

@ -11,7 +11,7 @@ macro_rules! bench_mul_dmat(
let a: DMat<f64> = DMat::new_random($nrows, $ncols);
let mut b: DMat<f64> = 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<f64> = DMat::new_random($nrows, $ncols);
let mut v : DVec<f64> = 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
}

View File

@ -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>() -> P {
Orig::orig()
}
/// Returns the center of two points.
/// Returns the center of two poisizes.
#[inline]
pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy>(a: &P, b: &P) -> P {
let _2 = one::<N>() + one();
@ -324,13 +324,13 @@ pub fn center<N: BaseFloat, P: FloatPnt<N, V>, 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<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N>>(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<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N>>(a: &P, b: &P) -> N {
a.sqdist(b)
@ -408,7 +408,7 @@ pub fn append_translation<V, M: Translation<V>>(m: &M, v: &V) -> M {
* Translate<P>
*/
/// 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<P, M: Translate<P>>(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<V, M: Rotate<V>>(m: &M, v: &V) -> V {
* RotationWithTranslation<LV, AV>
*/
/// 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<LV: Neg<Output = LV> + Copy,
pub fn append_rotation_wrt_poisize<LV: Neg<Output = LV> + Copy,
AV,
M: RotationWithTranslation<LV, AV>>(
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<LV: Neg<Output = LV> + Copy,
AV,
@ -744,7 +744,7 @@ pub fn from_homogeneous<M, Res: FromHomogeneous<M>>(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<V: UniformSphereSample, F: FnMut(V)>(f: F) {
UniformSphereSample::sample(f)
@ -837,7 +837,7 @@ pub fn mean<N, M: Mean<N>>(observations: &M) -> N {
*/
/// Computes the eigenvalues and eigenvectors of a square matrix usin the QR algorithm.
#[inline(always)]
pub fn eigen_qr<N, V, M: EigenQR<N, V>>(m: &M, eps: &N, niter: uint) -> (M, V) {
pub fn eigen_qr<N, V, M: EigenQR<N, V>>(m: &M, eps: &N, niter: usize) -> (M, V) {
EigenQR::eigen_qr(m, eps, niter)
}
@ -852,7 +852,7 @@ pub fn eigen_qr<N, V, M: EigenQR<N, V>>(m: &M, eps: &N, niter: uint) -> (M, V) {
*/
/// Construct the identity matrix for a given dimension
#[inline(always)]
pub fn new_identity<M: Eye>(dim: uint) -> M {
pub fn new_identity<M: Eye>(dim: usize) -> M {
Eye::new_identity(dim)
}
@ -874,7 +874,7 @@ pub fn orthonormal_subspace_basis<V: Basis, F: FnMut(V) -> bool>(v: &V, f: F) {
/// Gets the (0-based) i-th element of the canonical basis of V.
#[inline]
pub fn canonical_basis_element<V: Basis>(i: uint) -> Option<V> {
pub fn canonical_basis_element<V: Basis>(i: usize) -> Option<V> {
Basis::canonical_basis_element(i)
}
@ -902,7 +902,7 @@ pub fn diag<M: Diag<V>, V>(m: &M) -> V {
///
/// Same as `Dim::dim::(None::<V>)`.
#[inline(always)]
pub fn dim<V: Dim>() -> uint {
pub fn dim<V: Dim>() -> usize {
Dim::dim(None::<V>)
}

View File

@ -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<N, V, M>(dim: uint, start: uint, vec: V) -> M
pub fn householder_matrix<N, V, M>(dim: usize, start: usize, vec: V) -> M
where N: BaseFloat,
M: Eye + Indexable<(uint, uint), N>,
V: Indexable<uint, N> {
M: Eye + Indexable<(usize, usize), N>,
V: Indexable<usize, N> {
let mut qk : M = Eye::new_identity(dim);
let subdim = vec.shape();
@ -40,8 +40,8 @@ pub fn householder_matrix<N, V, M>(dim: uint, start: uint, vec: V) -> M
/// * `m` - matrix to decompose
pub fn qr<N, V, M>(m: &M) -> (M, M)
where N: BaseFloat,
V: Indexable<uint, N> + Norm<N>,
M: Copy + Eye + ColSlice<V> + Transpose + Indexable<(uint, uint), N> +
V: Indexable<usize, N> + Norm<N>,
M: Copy + Eye + ColSlice<V> + Transpose + Indexable<(usize, usize), N> +
Mul<M, Output = M> {
let (rows, cols) = m.shape();
assert!(rows >= cols);
@ -50,7 +50,7 @@ pub fn qr<N, V, M>(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<N, V, M>(m: &M) -> (M, M)
}
/// Eigendecomposition of a square matrix using the qr algorithm.
pub fn eigen_qr<N, V, VS, M>(m: &M, eps: &N, niter: uint) -> (M, V)
pub fn eigen_qr<N, V, VS, M>(m: &M, eps: &N, niter: usize) -> (M, V)
where N: BaseFloat,
VS: Indexable<uint, N> + Norm<N>,
M: Indexable<(uint, uint), N> + SquareMat<N, V> + Add<M, Output = M> +
VS: Indexable<usize, N> + Norm<N>,
M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> +
Sub<M, Output = M> + ColSlice<VS> +
ApproxEq<N> + Copy {
let mut eigenvectors: M = ::one::<M>();
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;

View File

@ -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<N> {
nrows: uint,
ncols: uint,
nrows: usize,
ncols: usize,
mij: Vec<N>
}
impl<N> DMat<N> {
/// Creates an uninitialized matrix.
#[inline]
pub unsafe fn new_uninitialized(nrows: uint, ncols: uint) -> DMat<N> {
pub unsafe fn new_uninitialized(nrows: usize, ncols: usize) -> DMat<N> {
let mut vec = Vec::with_capacity(nrows * ncols);
vec.set_len(nrows * ncols);
@ -45,7 +45,7 @@ impl<N: Zero + Clone + Copy> DMat<N> {
/// * `dim` - The dimension of the matrix. A `dim`-dimensional matrix contains `dim * dim`
/// components.
#[inline]
pub fn new_zeros(nrows: uint, ncols: uint) -> DMat<N> {
pub fn new_zeros(nrows: usize, ncols: usize) -> DMat<N> {
DMat::from_elem(nrows, ncols, ::zero())
}
@ -66,7 +66,7 @@ impl<N: Zero + Clone + Copy> DMat<N> {
impl<N: Rand> DMat<N> {
/// Builds a matrix filled with random values.
#[inline]
pub fn new_random(nrows: uint, ncols: uint) -> DMat<N> {
pub fn new_random(nrows: usize, ncols: usize) -> DMat<N> {
DMat::from_fn(nrows, ncols, |_, _| rand::random())
}
}
@ -74,7 +74,7 @@ impl<N: Rand> DMat<N> {
impl<N: One + Clone + Copy> DMat<N> {
/// Builds a matrix filled with a given constant.
#[inline]
pub fn new_ones(nrows: uint, ncols: uint) -> DMat<N> {
pub fn new_ones(nrows: usize, ncols: usize) -> DMat<N> {
DMat::from_elem(nrows, ncols, ::one())
}
}
@ -82,7 +82,7 @@ impl<N: One + Clone + Copy> DMat<N> {
impl<N: Clone + Copy> DMat<N> {
/// Builds a matrix filled with a given constant.
#[inline]
pub fn from_elem(nrows: uint, ncols: uint, val: N) -> DMat<N> {
pub fn from_elem(nrows: usize, ncols: usize, val: N) -> DMat<N> {
DMat {
nrows: nrows,
ncols: ncols,
@ -97,7 +97,7 @@ impl<N: Clone + Copy> DMat<N> {
///
/// The vector must have at least `nrows * ncols` elements.
#[inline]
pub fn from_row_vec(nrows: uint, ncols: uint, vec: &[N]) -> DMat<N> {
pub fn from_row_vec(nrows: usize, ncols: usize, vec: &[N]) -> DMat<N> {
let mut res = DMat::from_col_vec(ncols, nrows, vec);
// we transpose because the buffer is row_major
@ -113,7 +113,7 @@ impl<N: Clone + Copy> DMat<N> {
///
/// The vector must have at least `nrows * ncols` elements.
#[inline]
pub fn from_col_vec(nrows: uint, ncols: uint, vec: &[N]) -> DMat<N> {
pub fn from_col_vec(nrows: usize, ncols: usize, vec: &[N]) -> DMat<N> {
assert!(nrows * ncols == vec.len());
DMat {
@ -127,7 +127,7 @@ impl<N: Clone + Copy> DMat<N> {
impl<N> DMat<N> {
/// Builds a matrix filled with a given constant.
#[inline(always)]
pub fn from_fn<F: FnMut(uint, uint) -> N>(nrows: uint, ncols: uint, mut f: F) -> DMat<N> {
pub fn from_fn<F: FnMut(usize, usize) -> N>(nrows: usize, ncols: usize, mut f: F) -> DMat<N> {
DMat {
nrows: nrows,
ncols: ncols,
@ -137,17 +137,17 @@ impl<N> DMat<N> {
/// 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<N> {
@ -178,10 +178,10 @@ impl<N: One + Zero + Clone + Copy> Eye for DMat<N> {
/// * `dim` - The dimension of the matrix. A `dim`-dimensional matrix contains `dim * dim`
/// components.
#[inline]
fn new_identity(dim: uint) -> DMat<N> {
fn new_identity(dim: usize) -> DMat<N> {
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<N: One + Zero + Clone + Copy> Eye for DMat<N> {
impl<N> DMat<N> {
#[inline(always)]
fn offset(&self, i: uint, j: uint) -> uint {
fn offset(&self, i: usize, j: usize) -> usize {
i + j * self.nrows
}
}
impl<N: Copy> Indexable<(uint, uint), N> for DMat<N> {
impl<N: Copy> Indexable<(usize, usize), N> for DMat<N> {
/// 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<N: Copy> Indexable<(uint, uint), N> for DMat<N> {
/// 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<N: Copy> Indexable<(uint, uint), N> for DMat<N> {
/// # 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<N: Copy> Indexable<(uint, uint), N> for DMat<N> {
/// 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<N: Copy> Indexable<(uint, uint), N> for DMat<N> {
}
impl<N> Shape<(uint, uint)> for DMat<N> {
impl<N> Shape<(usize, usize)> for DMat<N> {
#[inline]
fn shape(&self) -> (uint, uint) {
fn shape(&self) -> (usize, usize) {
(self.nrows, self.ncols)
}
}
impl<N> Index<(uint, uint)> for DMat<N> {
impl<N> Index<(usize, usize)> for DMat<N> {
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<N> Index<(uint, uint)> for DMat<N> {
}
}
impl<N> IndexMut<(uint, uint)> for DMat<N> {
impl<N> IndexMut<(usize, usize)> for DMat<N> {
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<N: Copy + Mul<N, Output = N> + Add<N, Output = N> + Zero> Mul<DMat<N>> 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<N: Copy + Add<N, Output = N> + Mul<N, Output = N> + Zero> Mul<DVec<N>> for
let mut res : DVec<N> = 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<N: Copy + Add<N, Output = N> + Mul<N, Output = N> + Zero> Mul<DMat<N>> for
let mut res : DVec<N> = 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<N: BaseNum + Clone> Inv for DMat<N> {
let mut res: DMat<N> = 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<N: BaseNum + Clone> Inv for DMat<N> {
// 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<N: BaseNum + Clone> Inv for DMat<N> {
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<N: BaseNum + Clone> Inv for DMat<N> {
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<N: Clone + Copy> Transpose for DMat<N> {
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<N: Clone + Copy> Transpose for DMat<N> {
#[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<N: BaseNum + Cast<f64> + Clone> Mean<DVec<N>> for DMat<N> {
let mut res: DVec<N> = 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<N: BaseNum + Cast<f64> + Clone> Cov<DMat<N>> for DMat<N> {
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<N: BaseNum + Cast<f64> + Clone> Cov<DMat<N>> for DMat<N> {
}
impl<N: Copy + Clone> ColSlice<DVec<N>> for DMat<N> {
fn col_slice(&self, col_id :uint, row_start: uint, row_end: uint) -> DVec<N> {
fn col_slice(&self, col_id :usize, row_start: usize, row_end: usize) -> DVec<N> {
assert!(col_id < self.ncols);
assert!(row_start < row_end);
assert!(row_end <= self.nrows);
@ -556,14 +556,14 @@ impl<N: Copy + Clone> ColSlice<DVec<N>> for DMat<N> {
}
impl<N: Copy> RowSlice<DVec<N>> for DMat<N> {
fn row_slice(&self, row_id :uint, col_start: uint, col_end: uint) -> DVec<N> {
fn row_slice(&self, row_id :usize, col_start: usize, col_end: usize) -> DVec<N> {
assert!(row_id < self.nrows);
assert!(col_start < col_end);
assert!(col_end <= self.ncols);
let mut slice : DVec<N> = 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<N: ApproxEq<N>> ApproxEq<N> for DMat<N> {
impl<N: Show + Copy + String> Show for DMat<N> {
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");

View File

@ -22,7 +22,7 @@ pub struct DVec<N> {
impl<N> DVec<N> {
/// Creates an uninitialized vec.
#[inline]
pub unsafe fn new_uninitialized(dim: uint) -> DVec<N> {
pub unsafe fn new_uninitialized(dim: usize) -> DVec<N> {
let mut vec = Vec::with_capacity(dim);
vec.set_len(dim);
@ -35,7 +35,7 @@ impl<N> DVec<N> {
impl<N: Clone> DVec<N> {
/// Builds a vector filled with a constant.
#[inline]
pub fn from_elem(dim: uint, elem: N) -> DVec<N> {
pub fn from_elem(dim: usize, elem: N) -> DVec<N> {
DVec { at: repeat(elem).take(dim).collect() }
}
@ -43,7 +43,7 @@ impl<N: Clone> DVec<N> {
///
/// The vector must have at least `dim` elements.
#[inline]
pub fn from_slice(dim: uint, vec: &[N]) -> DVec<N> {
pub fn from_slice(dim: usize, vec: &[N]) -> DVec<N> {
assert!(dim <= vec.len());
DVec {
@ -55,12 +55,12 @@ impl<N: Clone> DVec<N> {
impl<N> DVec<N> {
/// Builds a vector filled with the result of a function.
#[inline(always)]
pub fn from_fn<F: FnMut(uint) -> N>(dim: uint, mut f: F) -> DVec<N> {
pub fn from_fn<F: FnMut(usize) -> N>(dim: usize, mut f: F) -> DVec<N> {
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<N> {
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<N> {
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<N> {
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<N> {
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<N> {
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<N> {
at: [N; 6],
dim: uint
dim: usize
}
small_dvec_impl!(DVec6, 6, 0, 1, 2, 3, 4, 5);

View File

@ -8,7 +8,7 @@ macro_rules! dvec_impl(
/// # Arguments
/// * `dim` - The dimension of the vector.
#[inline]
pub fn new_zeros(dim: uint) -> $dvec<N> {
pub fn new_zeros(dim: usize) -> $dvec<N> {
$dvec::from_elem(dim, ::zero())
}
@ -34,16 +34,16 @@ macro_rules! dvec_impl(
}
}
impl<N> Shape<uint> for $dvec<N> {
impl<N> Shape<usize> for $dvec<N> {
#[inline]
fn shape(&self) -> uint {
fn shape(&self) -> usize {
self.len()
}
}
impl<N: Copy> Indexable<uint, N> for $dvec<N> {
impl<N: Copy> Indexable<usize, N> for $dvec<N> {
#[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<N> Index<uint> for $dvec<N> {
impl<N> Index<usize> for $dvec<N> {
type Output = N;
fn index(&self, i: &uint) -> &N {
fn index(&self, i: &usize) -> &N {
&self.as_slice()[*i]
}
}
impl<N> IndexMut<uint> for $dvec<N> {
impl<N> IndexMut<usize> for $dvec<N> {
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<N> {
pub fn new_ones(dim: usize) -> $dvec<N> {
$dvec::from_elem(dim, ::one())
}
}
@ -107,7 +107,7 @@ macro_rules! dvec_impl(
impl<N: Rand + Zero> $dvec<N> {
/// Builds a vector filled with random values.
#[inline]
pub fn new_random(dim: uint) -> $dvec<N> {
pub fn new_random(dim: usize) -> $dvec<N> {
$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<N>> {
pub fn canonical_basis_with_dim(dim: usize) -> Vec<$dvec<N>> {
let mut res : Vec<$dvec<N>> = Vec::new();
for i in range(0u, dim) {
for i in range(0us, dim) {
let mut basis_element : $dvec<N> = $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<N>> = Vec::new();
for i in range(0u, dim) {
for i in range(0us, dim) {
let mut basis_element : $dvec<N> = $dvec::new_zeros(self.len());
basis_element.set(i, ::one());
@ -276,7 +276,7 @@ macro_rules! dvec_impl(
fn dot(&self, other: &$dvec<N>) -> 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<N> $dvec<N> {
#[inline]
pub fn len(&self) -> uint {
pub fn len(&self) -> usize {
self.dim
}
}
@ -440,7 +440,7 @@ macro_rules! small_dvec_from_impl (
impl<N: Copy + Zero> $dvec<N> {
/// Builds a vector filled with a constant.
#[inline]
pub fn from_elem(dim: uint, elem: N) -> $dvec<N> {
pub fn from_elem(dim: usize, elem: N) -> $dvec<N> {
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<N> {
pub fn from_slice(dim: usize, vec: &[N]) -> $dvec<N> {
assert!(dim <= vec.len() && dim <= $dim);
// FIXME: not safe.
@ -481,7 +481,7 @@ macro_rules! small_dvec_from_impl (
impl<N: Zero> $dvec<N> {
/// Builds a vector filled with the result of a function.
#[inline(always)]
pub fn from_fn<F: FnMut(uint) -> N>(dim: uint, mut f: F) -> $dvec<N> {
pub fn from_fn<F: FnMut(usize) -> N>(dim: usize, mut f: F) -> $dvec<N> {
assert!(dim <= $dim);
let mut at: [N; $dim] = [ $( $zeros, )* ];

View File

@ -52,29 +52,29 @@ pub struct Iso4<N> {
}
impl<N: Clone + BaseFloat> Iso3<N> {
/// 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<N>, at: &Pnt3<N>, up: &Vec3<N>) {
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<N>, at: &Pnt3<N>, up: &Vec3<N>) {
self.rotation.look_at_z(&(*at - *eye), up);

View File

@ -43,7 +43,7 @@ macro_rules! dim_impl(
($t: ident, $dim: expr) => (
impl<N> Dim for $t<N> {
#[inline]
fn dim(_: Option<$t<N>>) -> uint {
fn dim(_: Option<$t<N>>) -> usize {
$dim
}
}

View File

@ -60,13 +60,13 @@ macro_rules! at_fast_impl(
($t: ident, $dim: expr) => (
impl<N: Copy> $t<N> {
#[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>, &[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<N>, &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<N: Zero + One> Eye for $t<N> {
fn new_identity(dim: uint) -> $t<N> {
fn new_identity(dim: usize) -> $t<N> {
assert!(dim == $dim);
let mut eye: $t<N> = ::zero();
$(eye.$comp_diagN = ::one();)+
@ -247,7 +247,7 @@ macro_rules! dim_impl(
($t: ident, $dim: expr) => (
impl<N> Dim for $t<N> {
#[inline]
fn dim(_: Option<$t<N>>) -> uint {
fn dim(_: Option<$t<N>>) -> usize {
$dim
}
}
@ -256,30 +256,30 @@ macro_rules! dim_impl(
macro_rules! indexable_impl(
($t: ident, $dim: expr) => (
impl<N> Shape<(uint, uint)> for $t<N> {
impl<N> Shape<(usize, usize)> for $t<N> {
#[inline]
fn shape(&self) -> (uint, uint) {
fn shape(&self) -> (usize, usize) {
($dim, $dim)
}
}
impl<N: Copy> Indexable<(uint, uint), N> for $t<N> {
impl<N: Copy> Indexable<(usize, usize), N> for $t<N> {
#[inline]
fn at(&self, (i, j): (uint, uint)) -> N {
fn at(&self, (i, j): (usize, usize)) -> N {
unsafe {
mem::transmute::<&$t<N>, &[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<N>, &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<N>, &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>, &[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<N>, &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<N> Index<(uint, uint)> for $t<N> {
impl<N> Index<(usize, usize)> for $t<N> {
type Output = N;
fn index(&self, &(i, j): &(uint, uint)) -> &N {
fn index(&self, &(i, j): &(usize, usize)) -> &N {
unsafe {
&mem::transmute::<&$t<N>, &mut [N; $dim * $dim]>(self)[i + j * $dim]
}
}
}
impl<N> IndexMut<(uint, uint)> for $t<N> {
impl<N> IndexMut<(usize, usize)> for $t<N> {
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<N>, &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<N: Clone + Copy + Zero> ColSlice<$slice<N>> for $t<N> {
fn col_slice(&self, cid: uint, rstart: uint, rend: uint) -> $slice<N> {
fn col_slice(&self, cid: usize, rstart: usize, rend: usize) -> $slice<N> {
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<N: Copy + Zero> Row<$tv<N>> for $t<N> {
#[inline]
fn nrows(&self) -> uint {
fn nrows(&self) -> usize {
Dim::dim(None::<$t<N>>)
}
#[inline]
fn set_row(&mut self, row: uint, v: $tv<N>) {
fn set_row(&mut self, row: usize, v: $tv<N>) {
for (i, e) in v.iter().enumerate() {
self.set((row, i), *e);
}
}
#[inline]
fn row(&self, row: uint) -> $tv<N> {
fn row(&self, row: usize) -> $tv<N> {
let mut res: $tv<N> = ::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<N: Clone + Copy + Zero> RowSlice<$slice<N>> for $t<N> {
fn row_slice(&self, rid: uint, cstart: uint, cend: uint) -> $slice<N> {
fn row_slice(&self, rid: usize, cstart: usize, cend: usize) -> $slice<N> {
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<N: Copy + Zero> Col<$tv<N>> for $t<N> {
#[inline]
fn ncols(&self) -> uint {
fn ncols(&self) -> usize {
Dim::dim(None::<$t<N>>)
}
#[inline]
fn set_col(&mut self, col: uint, v: $tv<N>) {
fn set_col(&mut self, col: usize, v: $tv<N>) {
for (i, e) in v.iter().enumerate() {
self.set((i, col), *e);
}
}
#[inline]
fn col(&self, col: uint) -> $tv<N> {
fn col(&self, col: usize) -> $tv<N> {
let mut res: $tv<N> = ::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<N> = ::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<N>) -> $v<N> {
let mut res : $v<N> = $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<N>) -> $v<N> {
let mut res : $v<N> = $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<N> = ::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<N> {
let mut res: $t2<N> = ::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<N>) -> $t<N> {
let mut res: $t<N> = ::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<N>) -> $m<N> {
let mut res: $m<N> = ::zero();
for i in range(0u, Dim::dim(None::<$t<N>>)) {
for j in range(0u, Dim::dim(None::<$t<N>>)) {
for i in range(0us, Dim::dim(None::<$t<N>>)) {
for j in range(0us, Dim::dim(None::<$t<N>>)) {
res.set((i, j), self.at(i) * other.at(j))
}
}
@ -723,7 +723,7 @@ macro_rules! eigen_qr_impl(
($t: ident, $v: ident) => (
impl<N> EigenQR<N, $v<N>> for $t<N>
where N: BaseFloat + ApproxEq<N> + Clone {
fn eigen_qr(&self, eps: &N, niter: uint) -> ($t<N>, $v<N>) {
fn eigen_qr(&self, eps: &N, niter: usize) -> ($t<N>, $v<N>) {
linalg::eigen_qr(self, eps, niter)
}
}

View File

@ -96,7 +96,7 @@ impl<N: BaseFloat + Clone> Ortho3<N> {
self.zfar = zfar
}
/// Projects a point.
/// Projects a poisize.
#[inline]
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
// FIXME: optimize that
@ -204,7 +204,7 @@ impl<N: BaseFloat> OrthoMat3<N> {
self.mat.m34 = -(zfar + znear) / (zfar - znear);
}
/// Projects a point.
/// Projects a poisize.
#[inline]
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
Pnt3::new(

View File

@ -102,7 +102,7 @@ impl<N: BaseFloat + Clone> Persp3<N> {
self.zfar = zfar;
}
/// Projects a point.
/// Projects a poisize.
#[inline]
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
// FIXME: optimize that
@ -231,7 +231,7 @@ impl<N: BaseFloat> PerspMat3<N> {
self.mat.m34 = zfar * znear * _2 / (znear - zfar);
}
/// Projects a point.
/// Projects a poisize.
#[inline]
pub fn project_pnt(&self, p: &Pnt3<N>) -> Pnt3<N> {
let _1: N = ::one();

View File

@ -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<N>;
impl<N> Pnt0<N> {
/// Creates a new point.
/// Creates a new poisize.
#[inline]
pub fn new() -> Pnt0<N> {
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<N> {
Pnt0
}
}
/// Point of dimension 1.
/// Poisize of dimension 1.
#[derive(Eq, PartialEq, RustcEncodable, RustcDecodable, Clone, Hash, Rand, Show, Copy)]
pub struct Pnt1<N> {
/// 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<N> {
/// 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<N> {
/// 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<N> {
/// 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<N> {
/// 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<N> {
/// 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
}

View File

@ -60,7 +60,7 @@ macro_rules! pnt_sub_vec_impl(
macro_rules! pnt_as_vec_impl(
($t: ident, $tv: ident, $($compN: ident),+) => (
impl<N> $t<N> {
/// Converts this point to its associated vector.
/// Converts this poisize to its associated vector.
#[inline]
pub fn to_vec(self) -> $tv<N> {
$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<N> {
unsafe {

View File

@ -167,14 +167,14 @@ impl<N: Clone + BaseFloat> Rot3<N> {
}
impl<N: Clone + BaseFloat> Rot3<N> {
/// 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<N>, up: &Vec3<N>) {
let xaxis = Norm::normalize_cpy(at);
@ -187,11 +187,11 @@ impl<N: Clone + BaseFloat> Rot3<N> {
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<N>, up: &Vec3<N>) {
let zaxis = Norm::normalize_cpy(at);

View File

@ -71,7 +71,7 @@ macro_rules! dim_impl(
($t: ident, $dim: expr) => (
impl<N> Dim for $t<N> {
#[inline]
fn dim(_: Option<$t<N>>) -> uint {
fn dim(_: Option<$t<N>>) -> usize {
$dim
}
}
@ -193,16 +193,16 @@ macro_rules! row_impl(
($t: ident, $tv: ident) => (
impl<N: Copy + Zero> Row<$tv<N>> for $t<N> {
#[inline]
fn nrows(&self) -> uint {
fn nrows(&self) -> usize {
self.submat.nrows()
}
#[inline]
fn row(&self, i: uint) -> $tv<N> {
fn row(&self, i: usize) -> $tv<N> {
self.submat.row(i)
}
#[inline]
fn set_row(&mut self, i: uint, row: $tv<N>) {
fn set_row(&mut self, i: usize, row: $tv<N>) {
self.submat.set_row(i, row);
}
}
@ -213,16 +213,16 @@ macro_rules! col_impl(
($t: ident, $tv: ident) => (
impl<N: Copy + Zero> Col<$tv<N>> for $t<N> {
#[inline]
fn ncols(&self) -> uint {
fn ncols(&self) -> usize {
self.submat.ncols()
}
#[inline]
fn col(&self, i: uint) -> $tv<N> {
fn col(&self, i: usize) -> $tv<N> {
self.submat.col(i)
}
#[inline]
fn set_col(&mut self, i: uint, col: $tv<N>) {
fn set_col(&mut self, i: usize, col: $tv<N>) {
self.submat.set_col(i, col);
}
}
@ -231,10 +231,10 @@ macro_rules! col_impl(
macro_rules! index_impl(
($t: ident) => (
impl<N> Index<(uint, uint)> for $t<N> {
impl<N> Index<(usize, usize)> for $t<N> {
type Output = N;
fn index(&self, i: &(uint, uint)) -> &N {
fn index(&self, i: &(usize, usize)) -> &N {
&self.submat[*i]
}
}

View File

@ -45,7 +45,7 @@ impl<N: Clone + BaseNum + BaseNumCast + Zero> Inv for Cmplx<N> {
impl<N> Dim for Cmplx<N> {
#[inline]
fn dim(unsused_self: Option<Cmplx<N>>) -> uint {
fn dim(unsused_self: Option<Cmplx<N>>) -> usize {
2
}
}

View File

@ -132,12 +132,12 @@ impl<N: BaseNum> Det<N> for Mat3<N> {
impl<N: Copy> Row<Vec3<N>> for Mat3<N> {
#[inline]
fn nrows(&self) -> uint {
fn nrows(&self) -> usize {
3
}
#[inline]
fn row(&self, i: uint) -> Vec3<N> {
fn row(&self, i: usize) -> Vec3<N> {
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<N: Copy> Row<Vec3<N>> for Mat3<N> {
}
#[inline]
fn set_row(&mut self, i: uint, r: Vec3<N>) {
fn set_row(&mut self, i: usize, r: Vec3<N>) {
match i {
0 => {
self.m11 = r.x;
@ -172,12 +172,12 @@ impl<N: Copy> Row<Vec3<N>> for Mat3<N> {
impl<N: Copy> Col<Vec3<N>> for Mat3<N> {
#[inline]
fn ncols(&self) -> uint {
fn ncols(&self) -> usize {
3
}
#[inline]
fn col(&self, i: uint) -> Vec3<N> {
fn col(&self, i: usize) -> Vec3<N> {
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<N: Copy> Col<Vec3<N>> for Mat3<N> {
}
#[inline]
fn set_col(&mut self, i: uint, r: Vec3<N>) {
fn set_col(&mut self, i: usize, r: Vec3<N>) {
match i {
0 => {
self.m11 = r.x;

View File

@ -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);

View File

@ -48,12 +48,12 @@ impl<N: Neg<Output = N> + Zero + Copy> CrossMatrix<Mat3<N>> for Vec3<N> {
// FIXME: implement this for all other vectors
impl<N: Copy> Row<Vec1<N>> for Vec2<N> {
#[inline]
fn nrows(&self) -> uint {
fn nrows(&self) -> usize {
2
}
#[inline]
fn row(&self, i: uint) -> Vec1<N> {
fn row(&self, i: usize) -> Vec1<N> {
match i {
0 => Vec1::new(self.x),
1 => Vec1::new(self.y),
@ -62,7 +62,7 @@ impl<N: Copy> Row<Vec1<N>> for Vec2<N> {
}
#[inline]
fn set_row(&mut self, i: uint, r: Vec1<N>) {
fn set_row(&mut self, i: usize, r: Vec1<N>) {
match i {
0 => self.x = r.x,
1 => self.y = r.x,
@ -82,7 +82,7 @@ impl<N: One> Basis for Vec1<N> {
fn orthonormal_subspace_basis<F: FnMut(Vec1<N>) -> bool>(_: &Vec1<N>, _: F) { }
#[inline]
fn canonical_basis_element(i: uint) -> Option<Vec1<N>> {
fn canonical_basis_element(i: usize) -> Option<Vec1<N>> {
if i == 0 {
Some(Vec1::new(::one()))
}
@ -105,7 +105,7 @@ impl<N: Copy + One + Zero + Neg<Output = N>> Basis for Vec2<N> {
}
#[inline]
fn canonical_basis_element(i: uint) -> Option<Vec2<N>> {
fn canonical_basis_element(i: usize) -> Option<Vec2<N>> {
if i == 0 {
Some(Vec2::new(::one(), ::zero()))
}
@ -141,7 +141,7 @@ impl<N: BaseFloat> Basis for Vec3<N> {
}
#[inline]
fn canonical_basis_element(i: uint) -> Option<Vec3<N>> {
fn canonical_basis_element(i: usize) -> Option<Vec3<N>> {
if i == 0 {
Some(Vec3::new(::one(), ::zero(), ::zero()))
}

View File

@ -20,52 +20,52 @@ impl<N> Zero for vec::Vec0<N> {
}
}
impl<N> Index<uint> for vec::Vec0<N> {
impl<N> Index<usize> for vec::Vec0<N> {
type Output = N;
#[inline]
fn index(&self, _: &uint) -> &N {
fn index(&self, _: &usize) -> &N {
panic!("Canot index a Vec0.")
}
}
impl<N> IndexMut<uint> for vec::Vec0<N> {
impl<N> IndexMut<usize> for vec::Vec0<N> {
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<N> Shape<uint> for vec::Vec0<N> {
impl<N> Shape<usize> for vec::Vec0<N> {
#[inline]
fn shape(&self) -> uint {
fn shape(&self) -> usize {
0
}
}
impl<N> Indexable<uint, N> for vec::Vec0<N> {
impl<N> Indexable<usize, N> for vec::Vec0<N> {
#[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<N: 'static> IterableMut<N> for vec::Vec0<N> {
impl<N> Dim for vec::Vec0<N> {
#[inline]
fn dim(_: Option<vec::Vec0<N>>) -> uint {
fn dim(_: Option<vec::Vec0<N>>) -> usize {
0
}
}
@ -98,7 +98,7 @@ impl<N> Basis for vec::Vec0<N> {
fn orthonormal_subspace_basis<F: FnMut(vec::Vec0<N>) -> bool>(_: &vec::Vec0<N>, _: F) { }
#[inline(always)]
fn canonical_basis_element(_: uint) -> Option<vec::Vec0<N>> {
fn canonical_basis_element(_: usize) -> Option<vec::Vec0<N>> {
None
}
}

View File

@ -62,13 +62,13 @@ macro_rules! at_fast_impl(
impl<N: Copy> $t<N> {
/// 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<N> Shape<uint> for $t<N> {
impl<N> Shape<usize> for $t<N> {
#[inline]
fn shape(&self) -> uint {
fn shape(&self) -> usize {
$dim
}
}
impl<N: Copy> Indexable<uint, N> for $t<N> {
impl<N: Copy> Indexable<usize, N> for $t<N> {
#[inline]
fn at(&self, i: uint) -> N {
fn at(&self, i: usize) -> N {
unsafe {
mem::transmute::<&$t<N>, &[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<N>, &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<N>, &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>, &[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<N>, &mut [N; $dim]>(self).get_unchecked_mut(i)) = val
}
}
@ -226,18 +226,18 @@ macro_rules! indexable_impl(
macro_rules! index_impl(
($t: ident) => (
impl<N> Index<uint> for $t<N> {
impl<N> Index<usize> for $t<N> {
type Output = N;
fn index(&self, i: &uint) -> &N {
fn index(&self, i: &usize) -> &N {
&self.as_array()[*i]
}
}
impl<N> IndexMut<uint> for $t<N> {
impl<N> IndexMut<usize> for $t<N> {
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<N> Dim for $t<N> {
#[inline]
fn dim(_: Option<$t<N>>) -> uint {
fn dim(_: Option<$t<N>>) -> usize {
$dim
}
}
@ -299,7 +299,7 @@ macro_rules! container_impl(
($t: ident) => (
impl<N> $t<N> {
#[inline]
pub fn len(&self) -> uint {
pub fn len(&self) -> usize {
Dim::dim(None::<$t<N>>)
}
}
@ -311,7 +311,7 @@ macro_rules! basis_impl(
impl<N: Copy + BaseFloat + ApproxEq<N>> Basis for $t<N> {
#[inline]
fn canonical_basis<F: FnMut($t<N>) -> 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<N>> = Vec::new();
for i in range(0u, $dim) {
for i in range(0us, $dim) {
let mut basis_element : $t<N> = ::zero();
unsafe {
@ -352,7 +352,7 @@ macro_rules! basis_impl(
}
#[inline]
fn canonical_basis_element(i: uint) -> Option<$t<N>> {
fn canonical_basis_element(i: usize) -> Option<$t<N>> {
if i < $dim {
let mut basis_element : $t<N> = ::zero();

View File

@ -30,7 +30,7 @@ pub trait Translation<V> {
}
/// 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<V> {
/// Apply a translation to an object.
fn translate(&self, &V) -> V;
@ -77,20 +77,20 @@ pub trait Rotate<V> {
/// 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<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV> + Translation<LV> + 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<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV>
/// * `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<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV>
/// * `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<LV: Neg<Output = LV> + Copy, AV>: Rotation<AV>
#[inline]
fn append_rotation_wrt_center(&mut self, amount: &AV) {
let center = self.translation();
self.append_rotation_wrt_point(amount, &center)
self.append_rotation_wrt_poisize(amount, &center)
}
}
@ -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;
}

View File

@ -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<f32> 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<N> {
/// Trait for computing the eigenvector and eigenvalues of a square matrix usin the QR algorithm.
pub trait EigenQR<N, V>: SquareMat<N, V> {
/// 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);

View File

@ -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<Self, Output = Self> + Sub<Self, Output = Self> +
Mul<Self, Output = Self> + Div<Self, Output = Self> +
@ -16,7 +16,7 @@ pub trait BaseNum: Copy + Zero + One +
Absolute<Self> + Axpy<Self> {
}
/// 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<T> {
/// Trait of matrices.
///
/// A matrix has rows and columns and are able to multiply them.
pub trait Mat<N, R, C>: Row<R> + Col<C> + RMul<R> + LMul<C> + Index<(uint, uint), Output = N> { }
pub trait Mat<N, R, C>: Row<R> + Col<C> + RMul<R> + LMul<C> + Index<(usize, usize), Output = N> { }
impl<N, M, R, C> Mat<N, R, C> for M
where M: Row<R> + Col<C> + RMul<R> + LMul<C> + Index<(uint, uint), Output = N> {
where M: Row<R> + Col<C> + RMul<R> + LMul<C> + Index<(usize, usize), Output = N> {
}
/// Trait implemented by square matrices.
@ -78,7 +78,7 @@ impl<N, V, M> SquareMat<N, V> 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<F: FnMut(Self) -> bool>(&Self, F);
/// Gets the ith element of the canonical basis.
fn canonical_basis_element(i: uint) -> Option<Self>;
fn canonical_basis_element(i: usize) -> Option<Self>;
}
/// Trait to access rows of a matrix or a vector.
pub trait Row<R> {
/// 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<R> {
/// Trait to access columns of a matrix or vector.
pub trait Col<C> {
/// 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<C> {
/// Trait to access part of a column of a matrix
pub trait ColSlice<C> {
/// 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<R> {
/// 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<Self>) -> uint;
fn dim(unused_self: Option<Self>) -> usize;
}
/// Trait to get the diagonal of square matrices.
@ -226,13 +226,13 @@ pub trait IterableMut<N> {
/*
* 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<P> {
/// 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<N>: Dim +
Sub<Self, Output = Self> + Add<Self, Output = Self> +
Mul<N, Output = Self> + Div<N, Output = Self> +
Neg<Output = Self> +
Index<uint, Output = N> +
Index<usize, Output = N> +
Zero + PartialEq + Dot<N> + Axpy<N> {
}
@ -252,21 +252,21 @@ pub trait FloatVec<N: BaseFloat>: NumVec<N> + Norm<N> + 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<V> {
/// 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<N, V>:
@ -281,18 +281,18 @@ pub trait NumPnt<N, V>:
Mul<N, Output = Self> +
Div<N, Output = Self> +
Add<V, Output = Self> +
Index<uint, Output = N> { // FIXME: + Sub<V, Self>
Index<usize, Output = N> { // FIXME: + Sub<V, Self>
}
/// Trait of points with components implementing the `BaseFloat` trait.
/// Trait of poisizes with components implementing the `BaseFloat` trait.
pub trait FloatPnt<N: BaseFloat, V: Norm<N>>: NumPnt<N, V> + 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

View File

@ -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<f64> = na::one();
let ang = Vec1::new(na::abs(&random::<f64>()) % 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<f64> = na::one();
let dir: Vec3<f64> = random();
let ang = na::normalize(&dir) * (na::abs(&random::<f64>()) % 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<f64> = DMat::new_random(rows, cols);
@ -327,8 +327,8 @@ fn test_qr_mat6() {
#[test]
fn test_from_fn() {
let actual: DMat<uint> = DMat::from_fn(3, 4, |i, j| 10 * i + j);
let expected: DMat<uint> = DMat::from_row_vec(3, 4,
let actual: DMat<usize> = DMat::from_fn(3, 4, |i, j| 10 * i + j);
let expected: DMat<usize> = 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 ]);

View File

@ -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<f64> = 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<f64> = random();
let vec: Vec3<f64> = random();
let pnt: Pnt3<f64> = 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<f64> = random();
let axis_angle2: Vec3<f64> = 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<f64> = 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<f64> = random();
let q = UnitQuat::new_with_euler_angles(angles.x, angles.y, angles.z);

View File

@ -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<f64> = random();
let v2 : Vec3<f64> = random();
let v3 : Vec3<f64> = na::cross(&v1, &v2);