From 699e4c5bb718f03ac94c18f483c686b1699ec7f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Thu, 16 May 2013 21:44:05 +0000 Subject: [PATCH] Adapted assertions with last rust zero-testing api. --- src/dim2/mat2.rs | 4 ++-- src/dim2/vec2.rs | 7 ++++--- src/dim3/mat3.rs | 5 ++--- src/nalgebra.rc | 9 +++++++++ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/dim2/mat2.rs b/src/dim2/mat2.rs index c257d2ed..ff682b5a 100644 --- a/src/dim2/mat2.rs +++ b/src/dim2/mat2.rs @@ -87,7 +87,7 @@ impl + Mul> LMul> for Mat2 } } -impl + Quot + Sub + Neg + Eq + Zero> +impl + Quot + Sub + Neg + Zero> Inv for Mat2 { fn inverse(&self) -> Mat2 @@ -103,7 +103,7 @@ Inv for Mat2 { let det = self.m11 * self.m22 - self.m21 * self.m12; - assert!(det != Zero::zero()); + assert!(!det.is_zero()); *self = Mat2(self.m22 / det , -self.m12 / det, -self.m21 / det, self.m11 / det) diff --git a/src/dim2/vec2.rs b/src/dim2/vec2.rs index 2a251b1e..b6a89ac1 100644 --- a/src/dim2/vec2.rs +++ b/src/dim2/vec2.rs @@ -2,6 +2,7 @@ use core::num::{Zero, Algebraic}; use traits::dot::Dot; use traits::dim::Dim; use traits::cross::Cross; +use dim1::vec1::Vec1; #[deriving(Eq)] pub struct Vec2 @@ -43,10 +44,10 @@ impl + Add + Algebraic> Dot for Vec2 { self.sqnorm().sqrt() } } -impl + Sub> Cross for Vec2 +impl + Sub> Cross> for Vec2 { - fn cross(&self, other : &Vec2) -> T - { self.x * other.y - self.y * other.x } + fn cross(&self, other : &Vec2) -> Vec1 + { Vec1(self.x * other.y - self.y * other.x) } } impl> Neg> for Vec2 diff --git a/src/dim3/mat3.rs b/src/dim3/mat3.rs index cc58a0c0..00fb0a80 100644 --- a/src/dim3/mat3.rs +++ b/src/dim3/mat3.rs @@ -104,8 +104,7 @@ impl + Mul> LMul> for Mat3 } } -impl + Quot + Sub + Add + Neg - + Eq + Zero> +impl + Quot + Sub + Add + Neg + Zero> Inv for Mat3 { fn inverse(&self) -> Mat3 @@ -127,7 +126,7 @@ Inv for Mat3 - self.m12 * minor_m21_m33 + self.m13 * minor_m21_m32; - assert!(det != Zero::zero()); + assert!(det.is_zero()); *self = Mat3( (minor_m22_m33 / det), diff --git a/src/nalgebra.rc b/src/nalgebra.rc index 695f1e3d..27956944 100644 --- a/src/nalgebra.rc +++ b/src/nalgebra.rc @@ -13,6 +13,9 @@ pub use dim3::mat3::Mat3; pub use dim2::vec2::Vec2; pub use dim2::mat2::Mat2; +pub use dim1::vec1::Vec1; +pub use dim1::mat1::Mat1; + pub use ndim::nvec::NVec; pub use ndim::nmat::NMat; @@ -34,6 +37,12 @@ mod dim2 mod mat2; } +mod dim1 +{ + mod vec1; + mod mat1; +} + mod dim3 { mod vec3;