Update to the last rust-nightly.
Version of rustc: 0.11.0-nightly (459f155f81291c46633e86a480628b50304ffb1c 2014-07-04 23:46:44 +0000).
This commit is contained in:
parent
997cd4f888
commit
7b9a3f2bb9
|
@ -2,7 +2,7 @@
|
|||
|
||||
name = "nalgebra"
|
||||
version = "0.1.0"
|
||||
authors = [ "developer@crozet.re" ]
|
||||
authors = [ "Sébastien Crozet <developer@crozet.re>" ] # FIXME: add the contributors.
|
||||
|
||||
[[lib]]
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ macro_rules! bench_mul_mat(
|
|||
let mut b: $t = random();
|
||||
|
||||
$bh.iter(|| {
|
||||
for _ in range(0, 1000) {
|
||||
for _ in range(0u, 1000) {
|
||||
b = a * b;
|
||||
}
|
||||
})
|
||||
|
@ -49,7 +49,7 @@ macro_rules! bench_mul_dmat(
|
|||
let mut b: DMat<f64> = DMat::new_random($nrows, $ncols);
|
||||
|
||||
$bh.iter(|| {
|
||||
for _ in range(0, 1000) {
|
||||
for _ in range(0u, 1000) {
|
||||
b = a * b;
|
||||
}
|
||||
})
|
||||
|
@ -89,7 +89,7 @@ macro_rules! bench_mul_mat_vec(
|
|||
let mut v : $tv = random();
|
||||
|
||||
$bh.iter(|| {
|
||||
for _ in range(0, 1000) {
|
||||
for _ in range(0u, 1000) {
|
||||
v = m * v
|
||||
}
|
||||
})
|
||||
|
@ -129,7 +129,7 @@ macro_rules! bench_mul_dmat_dvec(
|
|||
let mut v : DVec<f64> = DVec::new_random($ncols);
|
||||
|
||||
$bh.iter(|| {
|
||||
for _ in range(0, 1000) {
|
||||
for _ in range(0u, 1000) {
|
||||
v = m * v
|
||||
}
|
||||
})
|
||||
|
|
|
@ -11,7 +11,7 @@ macro_rules! bench_dot_vec(
|
|||
let mut d = 0.0;
|
||||
|
||||
$bh.iter(|| {
|
||||
for _ in range(0, 1000) {
|
||||
for _ in range(0u, 1000) {
|
||||
d = d + na::dot(&a, &b);
|
||||
}
|
||||
})
|
||||
|
|
|
@ -63,10 +63,10 @@ fn main() {
|
|||
let v: Vec3<f64> = na::zero();
|
||||
let m: Mat3<f64> = na::one();
|
||||
|
||||
let _ = m * v; // matrix-vector multiplication.
|
||||
let _ = v * m; // vector-matrix multiplication.
|
||||
let _ = m * m; // matrix-matrix multiplication.
|
||||
let _ = v * 2.0; // vector-scalar multiplication.
|
||||
let _ = m * v; // matrix-vector multiplication.
|
||||
let _ = v * m; // vector-matrix multiplication.
|
||||
let _ = m * m; // matrix-matrix multiplication.
|
||||
let _ = v * 2.0f64; // vector-scalar multiplication.
|
||||
}
|
||||
```
|
||||
|
||||
|
|
20
src/na.rs
20
src/na.rs
|
@ -245,7 +245,7 @@ pub fn perspective3d<N: FloatMath + Cast<f32> + Zero + One>(width: N, height: N,
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero());
|
||||
/// let t = Iso3::new(Vec3::new(1.0f64, 1.0, 1.0), na::zero());
|
||||
/// let trans = na::translation(&t);
|
||||
///
|
||||
/// assert!(trans == Vec3::new(1.0, 1.0, 1.0));
|
||||
|
@ -264,7 +264,7 @@ pub fn translation<V, M: Translation<V>>(m: &M) -> V {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero());
|
||||
/// let t = Iso3::new(Vec3::new(1.0f64, 1.0, 1.0), na::zero());
|
||||
/// let itrans = na::inv_translation(&t);
|
||||
///
|
||||
/// assert!(itrans == Vec3::new(-1.0, -1.0, -1.0));
|
||||
|
@ -293,7 +293,7 @@ pub fn append_translation<V, M: Translation<V>>(m: &M, v: &V) -> M {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero());
|
||||
/// let t = Iso3::new(Vec3::new(1.0f64, 1.0, 1.0), na::zero());
|
||||
/// let v = Vec3::new(2.0, 2.0, 2.0);
|
||||
///
|
||||
/// let tv = na::translate(&t, &v);
|
||||
|
@ -314,7 +314,7 @@ pub fn translate<V, M: Translate<V>>(m: &M, v: &V) -> V {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Iso3::new(Vec3::new(1.0, 1.0, 1.0), na::zero());
|
||||
/// let t = Iso3::new(Vec3::new(1.0f64, 1.0, 1.0), na::zero());
|
||||
/// let v = Vec3::new(2.0, 2.0, 2.0);
|
||||
///
|
||||
/// let tv = na::inv_translate(&t, &v);
|
||||
|
@ -338,7 +338,7 @@ pub fn inv_translate<V, M: Translate<V>>(m: &M, v: &V) -> V {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Rot3::new(Vec3::new(1.0, 1.0, 1.0));
|
||||
/// let t = Rot3::new(Vec3::new(1.0f64, 1.0, 1.0));
|
||||
///
|
||||
/// assert!(na::approx_eq(&na::rotation(&t), &Vec3::new(1.0, 1.0, 1.0)));
|
||||
/// }
|
||||
|
@ -357,7 +357,7 @@ pub fn rotation<V, M: Rotation<V>>(m: &M) -> V {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Rot3::new(Vec3::new(1.0, 1.0, 1.0));
|
||||
/// let t = Rot3::new(Vec3::new(1.0f64, 1.0, 1.0));
|
||||
///
|
||||
/// assert!(na::approx_eq(&na::inv_rotation(&t), &Vec3::new(-1.0, -1.0, -1.0)));
|
||||
/// }
|
||||
|
@ -376,7 +376,7 @@ pub fn inv_rotation<V, M: Rotation<V>>(m: &M) -> V {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.0));
|
||||
/// let t = Rot3::new(Vec3::new(0.0f64, 0.0, 0.0));
|
||||
/// let v = Vec3::new(1.0, 1.0, 1.0);
|
||||
/// let rt = na::append_rotation(&t, &v);
|
||||
///
|
||||
|
@ -397,7 +397,7 @@ pub fn append_rotation<V, M: Rotation<V>>(m: &M, v: &V) -> M {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.0));
|
||||
/// let t = Rot3::new(Vec3::new(0.0f64, 0.0, 0.0));
|
||||
/// let v = Vec3::new(1.0, 1.0, 1.0);
|
||||
/// let rt = na::prepend_rotation(&t, &v);
|
||||
///
|
||||
|
@ -422,7 +422,7 @@ pub fn prepend_rotation<V, M: Rotation<V>>(m: &M, v: &V) -> M {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.5 * Float::pi()));
|
||||
/// let t = Rot3::new(Vec3::new(0.0f64, 0.0, 0.5 * Float::pi()));
|
||||
/// let v = Vec3::new(1.0, 0.0, 0.0);
|
||||
///
|
||||
/// let tv = na::rotate(&t, &v);
|
||||
|
@ -445,7 +445,7 @@ pub fn rotate<V, M: Rotate<V>>(m: &M, v: &V) -> V {
|
|||
/// use nalgebra::na;
|
||||
///
|
||||
/// fn main() {
|
||||
/// let t = Rot3::new(Vec3::new(0.0, 0.0, 0.5 * Float::pi()));
|
||||
/// let t = Rot3::new(Vec3::new(0.0f64, 0.0, 0.5 * Float::pi()));
|
||||
/// let v = Vec3::new(1.0, 0.0, 0.0);
|
||||
///
|
||||
/// let tv = na::inv_rotate(&t, &v);
|
||||
|
|
|
@ -5,7 +5,7 @@ macro_rules! submat_impl(
|
|||
impl<N> $t<N> {
|
||||
#[inline]
|
||||
pub fn submat<'r>(&'r self) -> &'r $submat<N> {
|
||||
&'r self.submat
|
||||
&self.submat
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -7,7 +7,7 @@ use std::cmp::{min, max};
|
|||
|
||||
macro_rules! test_inv_mat_impl(
|
||||
($t: ty) => (
|
||||
for _ in range(0, 10000) {
|
||||
for _ in range(0u, 10000) {
|
||||
let randmat : $t = random();
|
||||
|
||||
assert!(na::approx_eq(&(na::inv(&randmat).unwrap() * randmat), &na::one()));
|
||||
|
@ -17,7 +17,7 @@ macro_rules! test_inv_mat_impl(
|
|||
|
||||
macro_rules! test_transpose_mat_impl(
|
||||
($t: ty) => (
|
||||
for _ in range(0, 10000) {
|
||||
for _ in range(0u, 10000) {
|
||||
let randmat : $t = random();
|
||||
|
||||
assert!(na::transpose(&na::transpose(&randmat)) == randmat);
|
||||
|
@ -27,7 +27,7 @@ macro_rules! test_transpose_mat_impl(
|
|||
|
||||
macro_rules! test_decomp_qr_impl(
|
||||
($t: ty) => (
|
||||
for _ in range(0, 10000) {
|
||||
for _ in range(0u, 10000) {
|
||||
let randmat : $t = random();
|
||||
|
||||
let (q, r) = decomp_qr(&randmat);
|
||||
|
@ -100,7 +100,7 @@ fn test_inv_mat6() {
|
|||
|
||||
#[test]
|
||||
fn test_rotation2() {
|
||||
for _ in range(0, 10000) {
|
||||
for _ in range(0u, 10000) {
|
||||
let randmat: na::Rot2<f64> = na::one();
|
||||
let ang = Vec1::new(abs::<f64>(random()) % Float::pi());
|
||||
|
||||
|
@ -117,7 +117,7 @@ fn test_index_mat2() {
|
|||
|
||||
#[test]
|
||||
fn test_inv_rotation3() {
|
||||
for _ in range(0, 10000) {
|
||||
for _ in range(0u, 10000) {
|
||||
let randmat: Rot3<f64> = na::one();
|
||||
let dir: Vec3<f64> = random();
|
||||
let ang = na::normalize(&dir) * (abs::<f64>(random()) % Float::pi());
|
||||
|
@ -148,11 +148,11 @@ fn test_cov_dmat() {
|
|||
5,
|
||||
3,
|
||||
[
|
||||
4.0, 2.0, 0.60,
|
||||
4.2, 2.1, 0.59,
|
||||
3.9, 2.0, 0.58,
|
||||
4.3, 2.1, 0.62,
|
||||
4.1, 2.2, 0.63
|
||||
4.0f64, 2.0, 0.60,
|
||||
4.2f64, 2.1, 0.59,
|
||||
3.9f64, 2.0, 0.58,
|
||||
4.3f64, 2.1, 0.62,
|
||||
4.1f64, 2.2, 0.63
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -160,9 +160,9 @@ fn test_cov_dmat() {
|
|||
3,
|
||||
3,
|
||||
[
|
||||
0.025, 0.0075, 0.00175,
|
||||
0.0075, 0.007, 0.00135,
|
||||
0.00175, 0.00135, 0.00043
|
||||
0.025f64, 0.0075, 0.00175,
|
||||
0.0075f64, 0.007, 0.00135,
|
||||
0.00175f64, 0.00135, 0.00043
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -175,14 +175,14 @@ fn test_transpose_dmat() {
|
|||
8,
|
||||
4,
|
||||
[
|
||||
1, 2, 3, 4,
|
||||
5, 6, 7, 8,
|
||||
9, 10, 11, 12,
|
||||
13, 14, 15, 16,
|
||||
17, 18, 19, 20,
|
||||
21, 22, 23, 24,
|
||||
25, 26, 27, 28,
|
||||
29, 30, 31, 32
|
||||
1u32,2, 3, 4,
|
||||
5, 6, 7, 8,
|
||||
9, 10, 11, 12,
|
||||
13, 14, 15, 16,
|
||||
17, 18, 19, 20,
|
||||
21, 22, 23, 24,
|
||||
25, 26, 27, 28,
|
||||
29, 30, 31, 32
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -195,14 +195,14 @@ fn test_dmat_from_vec() {
|
|||
8,
|
||||
4,
|
||||
[
|
||||
1, 2, 3, 4,
|
||||
5, 6, 7, 8,
|
||||
9, 10, 11, 12,
|
||||
13, 14, 15, 16,
|
||||
17, 18, 19, 20,
|
||||
21, 22, 23, 24,
|
||||
25, 26, 27, 28,
|
||||
29, 30, 31, 32
|
||||
1i32, 2, 3, 4,
|
||||
5, 6, 7, 8,
|
||||
9, 10, 11, 12,
|
||||
13, 14, 15, 16,
|
||||
17, 18, 19, 20,
|
||||
21, 22, 23, 24,
|
||||
25, 26, 27, 28,
|
||||
29, 30, 31, 32
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -210,10 +210,10 @@ fn test_dmat_from_vec() {
|
|||
8,
|
||||
4,
|
||||
[
|
||||
1, 5, 9, 13, 17, 21, 25, 29,
|
||||
2, 6, 10, 14, 18, 22, 26, 30,
|
||||
3, 7, 11, 15, 19, 23, 27, 31,
|
||||
4, 8, 12, 16, 20, 24, 28, 32
|
||||
1i32, 5, 9, 13, 17, 21, 25, 29,
|
||||
2i32, 6, 10, 14, 18, 22, 26, 30,
|
||||
3i32, 7, 11, 15, 19, 23, 27, 31,
|
||||
4i32, 8, 12, 16, 20, 24, 28, 32
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -224,7 +224,7 @@ fn test_dmat_from_vec() {
|
|||
|
||||
#[test]
|
||||
fn test_decomp_qr() {
|
||||
for _ in range(0, 10) {
|
||||
for _ in range(0u, 10) {
|
||||
let dim1: uint = random();
|
||||
let dim2: uint = random();
|
||||
let rows = min(40, max(dim1, dim2));
|
||||
|
|
|
@ -5,7 +5,7 @@ use na;
|
|||
|
||||
macro_rules! test_iterator_impl(
|
||||
($t: ty, $n: ty) => (
|
||||
for _ in range(0, 10000) {
|
||||
for _ in range(0u, 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(0, 10000) {
|
||||
for _ in range(0u, 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(0, 10000) {
|
||||
for _ in range(0u, 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(0, 10000) {
|
||||
for _ in range(0u, 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(0, 10000) {
|
||||
for _ in range(0u, 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(0, 10000) {
|
||||
for _ in range(0u, 10000) {
|
||||
let v1 : Vec3<f64> = random();
|
||||
let v2 : Vec3<f64> = random();
|
||||
let v3 : Vec3<f64> = na::cross(&v1, &v2);
|
||||
|
@ -287,30 +287,30 @@ fn test_iterator_vec6() {
|
|||
#[test]
|
||||
fn test_ord_vec3() {
|
||||
// equality
|
||||
assert!(Vec3::new(0.5, 0.5, 0.5) == Vec3::new(0.5, 0.5, 0.5));
|
||||
assert!(!(Vec3::new(1.5, 0.5, 0.5) == Vec3::new(0.5, 0.5, 0.5)));
|
||||
assert!(Vec3::new(1.5, 0.5, 0.5) != Vec3::new(0.5, 0.5, 0.5));
|
||||
assert!(Vec3::new(0.5f64, 0.5, 0.5) == Vec3::new(0.5, 0.5, 0.5));
|
||||
assert!(!(Vec3::new(1.5f64, 0.5, 0.5) == Vec3::new(0.5, 0.5, 0.5)));
|
||||
assert!(Vec3::new(1.5f64, 0.5, 0.5) != Vec3::new(0.5, 0.5, 0.5));
|
||||
|
||||
// comparable
|
||||
assert!(na::partial_cmp(&Vec3::new(0.5, 0.3, 0.3), &Vec3::new(1.0, 2.0, 1.0)).is_le());
|
||||
assert!(na::partial_cmp(&Vec3::new(0.5, 0.3, 0.3), &Vec3::new(1.0, 2.0, 1.0)).is_lt());
|
||||
assert!(na::partial_cmp(&Vec3::new(2.0, 4.0, 2.0), &Vec3::new(1.0, 2.0, 1.0)).is_ge());
|
||||
assert!(na::partial_cmp(&Vec3::new(2.0, 4.0, 2.0), &Vec3::new(1.0, 2.0, 1.0)).is_gt());
|
||||
assert!(na::partial_cmp(&Vec3::new(0.5f64, 0.3, 0.3), &Vec3::new(1.0, 2.0, 1.0)).is_le());
|
||||
assert!(na::partial_cmp(&Vec3::new(0.5f64, 0.3, 0.3), &Vec3::new(1.0, 2.0, 1.0)).is_lt());
|
||||
assert!(na::partial_cmp(&Vec3::new(2.0f64, 4.0, 2.0), &Vec3::new(1.0, 2.0, 1.0)).is_ge());
|
||||
assert!(na::partial_cmp(&Vec3::new(2.0f64, 4.0, 2.0), &Vec3::new(1.0, 2.0, 1.0)).is_gt());
|
||||
|
||||
// not comparable
|
||||
assert!(na::partial_cmp(&Vec3::new(0.0, 3.0, 0.0), &Vec3::new(1.0, 2.0, 1.0)).is_not_comparable());
|
||||
assert!(na::partial_cmp(&Vec3::new(0.0f64, 3.0, 0.0), &Vec3::new(1.0, 2.0, 1.0)).is_not_comparable());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_min_max_vec3() {
|
||||
assert_eq!(na::sup(&Vec3::new(1.0, 2.0, 3.0), &Vec3::new(3.0, 2.0, 1.0)), Vec3::new(3.0, 2.0, 3.0));
|
||||
assert_eq!(na::inf(&Vec3::new(1.0, 2.0, 3.0), &Vec3::new(3.0, 2.0, 1.0)), Vec3::new(1.0, 2.0, 1.0));
|
||||
assert_eq!(na::sup(&Vec3::new(1.0f64, 2.0, 3.0), &Vec3::new(3.0, 2.0, 1.0)), Vec3::new(3.0, 2.0, 3.0));
|
||||
assert_eq!(na::inf(&Vec3::new(1.0f64, 2.0, 3.0), &Vec3::new(3.0, 2.0, 1.0)), Vec3::new(1.0, 2.0, 1.0));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_outer_vec3() {
|
||||
assert_eq!(
|
||||
na::outer(&Vec3::new(1.0, 2.0, 3.0), &Vec3::new(4.0, 5.0, 6.0)),
|
||||
na::outer(&Vec3::new(1.0f64, 2.0, 3.0), &Vec3::new(4.0, 5.0, 6.0)),
|
||||
Mat3::new(
|
||||
4.0, 5.0, 6.0,
|
||||
8.0, 10.0, 12.0,
|
||||
|
|
Loading…
Reference in New Issue