From cead4f8410a88797c5187fbdafdf3abc95046edf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Sat, 17 Aug 2013 17:50:01 +0200 Subject: [PATCH] Moved DivisionRing to ring.rs. --- src/adaptors/rotmat.rs | 2 +- src/adaptors/transform.rs | 2 +- src/dmat.rs | 2 +- src/dvec.rs | 3 +- src/mat.rs | 3 +- src/mat_spec.rs | 7 +++-- src/nalgebra.rc | 55 ++++++++++++++++++------------------- src/traits/division_ring.rs | 10 ------- src/traits/ring.rs | 9 ++++++ src/traits/vector_space.rs | 5 ++-- src/vec.rs | 3 +- src/vec0_spec.rs | 3 +- src/vec_spec.rs | 2 +- 13 files changed, 50 insertions(+), 56 deletions(-) delete mode 100644 src/traits/division_ring.rs diff --git a/src/adaptors/rotmat.rs b/src/adaptors/rotmat.rs index 6233fb7a..a1085727 100644 --- a/src/adaptors/rotmat.rs +++ b/src/adaptors/rotmat.rs @@ -1,7 +1,7 @@ use std::num::{One, Zero}; use std::rand::{Rand, Rng, RngUtil}; use std::cmp::ApproxEq; -use traits::division_ring::DivisionRing; +use traits::ring::DivisionRing; use traits::rlmul::{RMul, LMul}; use traits::cross::Cross; use traits::dim::Dim; diff --git a/src/adaptors/transform.rs b/src/adaptors/transform.rs index 5e838cff..78df3a11 100644 --- a/src/adaptors/transform.rs +++ b/src/adaptors/transform.rs @@ -3,7 +3,7 @@ use std::rand::{Rand, Rng, RngUtil}; use std::cmp::ApproxEq; use traits::dim::Dim; use traits::inv::Inv; -use traits::division_ring::DivisionRing; +use traits::ring::DivisionRing; use traits::rotation::{Rotation, Rotate, Rotatable}; use traits::translation::{Translation, Translate, Translatable}; use Ts = traits::transformation::Transform; diff --git a/src/dmat.rs b/src/dmat.rs index 79a02715..b60dd88a 100644 --- a/src/dmat.rs +++ b/src/dmat.rs @@ -2,7 +2,7 @@ use std::num::{One, Zero}; use std::vec::from_elem; use std::cmp::ApproxEq; use traits::inv::Inv; -use traits::division_ring::DivisionRing; +use traits::ring::DivisionRing; use traits::transpose::Transpose; use traits::rlmul::{RMul, LMul}; use dvec::{DVec, zero_vec_with_dim}; diff --git a/src/dvec.rs b/src/dvec.rs index ace36cbc..ca7b4be5 100644 --- a/src/dvec.rs +++ b/src/dvec.rs @@ -4,8 +4,7 @@ use std::vec::from_elem; use std::cmp::ApproxEq; use std::iterator::FromIterator; use traits::iterable::{Iterable, IterableMut}; -use traits::ring::Ring; -use traits::division_ring::DivisionRing; +use traits::ring::{Ring, DivisionRing}; use traits::dot::Dot; use traits::sub_dot::SubDot; use traits::norm::Norm; diff --git a/src/mat.rs b/src/mat.rs index 971034eb..d9291c5f 100644 --- a/src/mat.rs +++ b/src/mat.rs @@ -6,9 +6,8 @@ use std::cmp::ApproxEq; use std::vec::{VecIterator, VecMutIterator}; use vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6}; use traits::dim::Dim; -use traits::ring::Ring; +use traits::ring::{Ring, DivisionRing}; use traits::inv::Inv; -use traits::division_ring::DivisionRing; use traits::transpose::Transpose; use traits::rlmul::{RMul, LMul}; use traits::transformation::Transform; diff --git a/src/mat_spec.rs b/src/mat_spec.rs index 2924e046..d0c629ea 100644 --- a/src/mat_spec.rs +++ b/src/mat_spec.rs @@ -1,6 +1,6 @@ use std::num::{Zero, One}; use mat::{Mat1, Mat2, Mat3}; -use traits::division_ring::DivisionRing; +use traits::ring::DivisionRing; use traits::inv::Inv; // some specializations: @@ -52,8 +52,9 @@ Inv for Mat2 { false } else { - *self = Mat2::new(self.m22 / det , -self.m12 / det, - -self.m21 / det, self.m11 / det); + *self = Mat2::new( + self.m22 / det , -self.m12 / det, + -self.m21 / det, self.m11 / det); true } diff --git a/src/nalgebra.rc b/src/nalgebra.rc index fca04815..83bb6088 100644 --- a/src/nalgebra.rc +++ b/src/nalgebra.rc @@ -30,8 +30,8 @@ mod vec0_spec; /// Wrappers around raw matrices to restrict their behaviour. pub mod adaptors { - pub mod rotmat; - pub mod transform; + pub mod rotmat; + pub mod transform; } pub mod types; @@ -47,35 +47,34 @@ pub mod types; // FIXME: it would be better to hide all those from the outside! pub mod traits { - pub mod sample; - pub mod indexable; - pub mod column; - pub mod iterable; - pub mod dot; - pub mod outer; - pub mod cross; - pub mod inv; - pub mod transpose; - pub mod dim; - pub mod basis; - pub mod norm; - pub mod rotation; - pub mod translation; - pub mod transformation; - pub mod vector_space; - pub mod ring; - pub mod division_ring; - pub mod sub_dot; - pub mod rlmul; - pub mod scalar_op; - pub mod homogeneous; - pub mod vec_cast; - pub mod mat_cast; + pub mod sample; + pub mod indexable; + pub mod column; + pub mod iterable; + pub mod dot; + pub mod outer; + pub mod cross; + pub mod inv; + pub mod transpose; + pub mod dim; + pub mod basis; + pub mod norm; + pub mod rotation; + pub mod translation; + pub mod transformation; + pub mod vector_space; + pub mod ring; + pub mod sub_dot; + pub mod rlmul; + pub mod scalar_op; + pub mod homogeneous; + pub mod vec_cast; + pub mod mat_cast; } #[cfg(test)] pub mod tests { - pub mod mat; - pub mod vec; + pub mod mat; + pub mod vec; } diff --git a/src/traits/division_ring.rs b/src/traits/division_ring.rs deleted file mode 100644 index 0fc33343..00000000 --- a/src/traits/division_ring.rs +++ /dev/null @@ -1,10 +0,0 @@ -use traits::ring::Ring; - -/** - * Trait of elements of a division ring. A division ring is an algebraic - * structure like a ring, but with the division operator. - */ -pub trait DivisionRing : Ring + Div -{ } - -impl> DivisionRing for N; diff --git a/src/traits/ring.rs b/src/traits/ring.rs index 87f2f271..95eece7e 100644 --- a/src/traits/ring.rs +++ b/src/traits/ring.rs @@ -11,3 +11,12 @@ Sub + Add + Neg + Mul + One + Zero { } impl + Add + Neg + Mul + One + Zero> Ring for N; + +/** + * Trait of elements of a division ring. A division ring is an algebraic + * structure like a ring, but with the division operator. + */ +pub trait DivisionRing : Ring + Div +{ } + +impl> DivisionRing for N; diff --git a/src/traits/vector_space.rs b/src/traits/vector_space.rs index 2b15fbf0..31738079 100644 --- a/src/traits/vector_space.rs +++ b/src/traits/vector_space.rs @@ -1,5 +1,5 @@ use std::num::Zero; -use traits::division_ring::DivisionRing; +use traits::ring::DivisionRing; use traits::scalar_op::{ScalarMul, ScalarDiv}; /// Trait of elements of a vector space. A vector space is an algebraic @@ -7,8 +7,7 @@ use traits::scalar_op::{ScalarMul, ScalarDiv}; /// scalar multiplication (the scalar being a element of a `DivisionRing`), and /// has a distinct element (`Zero`) neutral wrt the addition. pub trait VectorSpace -: Sub + Add + Neg + Zero + - ScalarMul + ScalarDiv { } +: Sub + Add + Neg + Zero + ScalarMul + ScalarDiv { } impl + Add + Neg + Zero + ScalarMul + ScalarDiv, N: DivisionRing> VectorSpace for V; diff --git a/src/vec.rs b/src/vec.rs index ca723de0..585b2b7d 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -7,8 +7,7 @@ use std::cmp::ApproxEq; use traits::basis::Basis; use traits::dim::Dim; use traits::translation::{Translation, Translatable}; -use traits::ring::Ring; -use traits::division_ring::DivisionRing; +use traits::ring::{Ring, DivisionRing}; use traits::homogeneous::{FromHomogeneous, ToHomogeneous}; use traits::indexable::Indexable; diff --git a/src/vec0_spec.rs b/src/vec0_spec.rs index b7917fd2..c7a4270c 100644 --- a/src/vec0_spec.rs +++ b/src/vec0_spec.rs @@ -11,8 +11,7 @@ use traits::sub_dot::SubDot; use traits::norm::Norm; use traits::translation::{Translation, Translatable}; use traits::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub}; -use traits::ring::Ring; -use traits::division_ring::DivisionRing; +use traits::ring::{Ring, DivisionRing}; use traits::indexable::Indexable; use vec; diff --git a/src/vec_spec.rs b/src/vec_spec.rs index 176aa8b6..1289c009 100644 --- a/src/vec_spec.rs +++ b/src/vec_spec.rs @@ -1,7 +1,7 @@ use std::num::{Zero, One}; use traits::basis::Basis; use traits::cross::Cross; -use traits::division_ring::DivisionRing; +use traits::ring::DivisionRing; use traits::norm::Norm; use traits::sample::UniformSphereSample; use vec::{Vec1, Vec2, Vec3};