forked from M-Labs/nalgebra
Moved DivisionRing to ring.rs.
This commit is contained in:
parent
344d761be5
commit
cead4f8410
@ -1,7 +1,7 @@
|
|||||||
use std::num::{One, Zero};
|
use std::num::{One, Zero};
|
||||||
use std::rand::{Rand, Rng, RngUtil};
|
use std::rand::{Rand, Rng, RngUtil};
|
||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
use traits::division_ring::DivisionRing;
|
use traits::ring::DivisionRing;
|
||||||
use traits::rlmul::{RMul, LMul};
|
use traits::rlmul::{RMul, LMul};
|
||||||
use traits::cross::Cross;
|
use traits::cross::Cross;
|
||||||
use traits::dim::Dim;
|
use traits::dim::Dim;
|
||||||
|
@ -3,7 +3,7 @@ use std::rand::{Rand, Rng, RngUtil};
|
|||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
use traits::dim::Dim;
|
use traits::dim::Dim;
|
||||||
use traits::inv::Inv;
|
use traits::inv::Inv;
|
||||||
use traits::division_ring::DivisionRing;
|
use traits::ring::DivisionRing;
|
||||||
use traits::rotation::{Rotation, Rotate, Rotatable};
|
use traits::rotation::{Rotation, Rotate, Rotatable};
|
||||||
use traits::translation::{Translation, Translate, Translatable};
|
use traits::translation::{Translation, Translate, Translatable};
|
||||||
use Ts = traits::transformation::Transform;
|
use Ts = traits::transformation::Transform;
|
||||||
|
@ -2,7 +2,7 @@ use std::num::{One, Zero};
|
|||||||
use std::vec::from_elem;
|
use std::vec::from_elem;
|
||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
use traits::inv::Inv;
|
use traits::inv::Inv;
|
||||||
use traits::division_ring::DivisionRing;
|
use traits::ring::DivisionRing;
|
||||||
use traits::transpose::Transpose;
|
use traits::transpose::Transpose;
|
||||||
use traits::rlmul::{RMul, LMul};
|
use traits::rlmul::{RMul, LMul};
|
||||||
use dvec::{DVec, zero_vec_with_dim};
|
use dvec::{DVec, zero_vec_with_dim};
|
||||||
|
@ -4,8 +4,7 @@ use std::vec::from_elem;
|
|||||||
use std::cmp::ApproxEq;
|
use std::cmp::ApproxEq;
|
||||||
use std::iterator::FromIterator;
|
use std::iterator::FromIterator;
|
||||||
use traits::iterable::{Iterable, IterableMut};
|
use traits::iterable::{Iterable, IterableMut};
|
||||||
use traits::ring::Ring;
|
use traits::ring::{Ring, DivisionRing};
|
||||||
use traits::division_ring::DivisionRing;
|
|
||||||
use traits::dot::Dot;
|
use traits::dot::Dot;
|
||||||
use traits::sub_dot::SubDot;
|
use traits::sub_dot::SubDot;
|
||||||
use traits::norm::Norm;
|
use traits::norm::Norm;
|
||||||
|
@ -6,9 +6,8 @@ use std::cmp::ApproxEq;
|
|||||||
use std::vec::{VecIterator, VecMutIterator};
|
use std::vec::{VecIterator, VecMutIterator};
|
||||||
use vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
|
use vec::{Vec1, Vec2, Vec3, Vec4, Vec5, Vec6};
|
||||||
use traits::dim::Dim;
|
use traits::dim::Dim;
|
||||||
use traits::ring::Ring;
|
use traits::ring::{Ring, DivisionRing};
|
||||||
use traits::inv::Inv;
|
use traits::inv::Inv;
|
||||||
use traits::division_ring::DivisionRing;
|
|
||||||
use traits::transpose::Transpose;
|
use traits::transpose::Transpose;
|
||||||
use traits::rlmul::{RMul, LMul};
|
use traits::rlmul::{RMul, LMul};
|
||||||
use traits::transformation::Transform;
|
use traits::transformation::Transform;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::num::{Zero, One};
|
use std::num::{Zero, One};
|
||||||
use mat::{Mat1, Mat2, Mat3};
|
use mat::{Mat1, Mat2, Mat3};
|
||||||
use traits::division_ring::DivisionRing;
|
use traits::ring::DivisionRing;
|
||||||
use traits::inv::Inv;
|
use traits::inv::Inv;
|
||||||
|
|
||||||
// some specializations:
|
// some specializations:
|
||||||
@ -52,7 +52,8 @@ Inv for Mat2<N> {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
*self = Mat2::new(self.m22 / det , -self.m12 / det,
|
*self = Mat2::new(
|
||||||
|
self.m22 / det , -self.m12 / det,
|
||||||
-self.m21 / det, self.m11 / det);
|
-self.m21 / det, self.m11 / det);
|
||||||
|
|
||||||
true
|
true
|
||||||
|
@ -64,7 +64,6 @@ pub mod traits
|
|||||||
pub mod transformation;
|
pub mod transformation;
|
||||||
pub mod vector_space;
|
pub mod vector_space;
|
||||||
pub mod ring;
|
pub mod ring;
|
||||||
pub mod division_ring;
|
|
||||||
pub mod sub_dot;
|
pub mod sub_dot;
|
||||||
pub mod rlmul;
|
pub mod rlmul;
|
||||||
pub mod scalar_op;
|
pub mod scalar_op;
|
||||||
|
@ -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<Self, Self>
|
|
||||||
{ }
|
|
||||||
|
|
||||||
impl<N: Ring + Div<N, N>> DivisionRing for N;
|
|
@ -11,3 +11,12 @@ Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Mul<Self, Self> + One + Zero { }
|
|||||||
|
|
||||||
impl<N: Sub<N, N> + Add<N, N> + Neg<N> + Mul<N, N> + One + Zero>
|
impl<N: Sub<N, N> + Add<N, N> + Neg<N> + Mul<N, N> + One + Zero>
|
||||||
Ring for N;
|
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<Self, Self>
|
||||||
|
{ }
|
||||||
|
|
||||||
|
impl<N: Ring + Div<N, N>> DivisionRing for N;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use std::num::Zero;
|
use std::num::Zero;
|
||||||
use traits::division_ring::DivisionRing;
|
use traits::ring::DivisionRing;
|
||||||
use traits::scalar_op::{ScalarMul, ScalarDiv};
|
use traits::scalar_op::{ScalarMul, ScalarDiv};
|
||||||
|
|
||||||
/// Trait of elements of a vector space. A vector space is an algebraic
|
/// 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
|
/// scalar multiplication (the scalar being a element of a `DivisionRing`), and
|
||||||
/// has a distinct element (`Zero`) neutral wrt the addition.
|
/// has a distinct element (`Zero`) neutral wrt the addition.
|
||||||
pub trait VectorSpace<N>
|
pub trait VectorSpace<N>
|
||||||
: Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Zero +
|
: Sub<Self, Self> + Add<Self, Self> + Neg<Self> + Zero + ScalarMul<N> + ScalarDiv<N> { }
|
||||||
ScalarMul<N> + ScalarDiv<N> { }
|
|
||||||
|
|
||||||
impl<V: Sub<V, V> + Add<V, V> + Neg<V> + Zero + ScalarMul<N> + ScalarDiv<N>,
|
impl<V: Sub<V, V> + Add<V, V> + Neg<V> + Zero + ScalarMul<N> + ScalarDiv<N>,
|
||||||
N: DivisionRing> VectorSpace<N> for V;
|
N: DivisionRing> VectorSpace<N> for V;
|
||||||
|
@ -7,8 +7,7 @@ use std::cmp::ApproxEq;
|
|||||||
use traits::basis::Basis;
|
use traits::basis::Basis;
|
||||||
use traits::dim::Dim;
|
use traits::dim::Dim;
|
||||||
use traits::translation::{Translation, Translatable};
|
use traits::translation::{Translation, Translatable};
|
||||||
use traits::ring::Ring;
|
use traits::ring::{Ring, DivisionRing};
|
||||||
use traits::division_ring::DivisionRing;
|
|
||||||
use traits::homogeneous::{FromHomogeneous, ToHomogeneous};
|
use traits::homogeneous::{FromHomogeneous, ToHomogeneous};
|
||||||
use traits::indexable::Indexable;
|
use traits::indexable::Indexable;
|
||||||
|
|
||||||
|
@ -11,8 +11,7 @@ use traits::sub_dot::SubDot;
|
|||||||
use traits::norm::Norm;
|
use traits::norm::Norm;
|
||||||
use traits::translation::{Translation, Translatable};
|
use traits::translation::{Translation, Translatable};
|
||||||
use traits::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
|
use traits::scalar_op::{ScalarMul, ScalarDiv, ScalarAdd, ScalarSub};
|
||||||
use traits::ring::Ring;
|
use traits::ring::{Ring, DivisionRing};
|
||||||
use traits::division_ring::DivisionRing;
|
|
||||||
use traits::indexable::Indexable;
|
use traits::indexable::Indexable;
|
||||||
use vec;
|
use vec;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::num::{Zero, One};
|
use std::num::{Zero, One};
|
||||||
use traits::basis::Basis;
|
use traits::basis::Basis;
|
||||||
use traits::cross::Cross;
|
use traits::cross::Cross;
|
||||||
use traits::division_ring::DivisionRing;
|
use traits::ring::DivisionRing;
|
||||||
use traits::norm::Norm;
|
use traits::norm::Norm;
|
||||||
use traits::sample::UniformSphereSample;
|
use traits::sample::UniformSphereSample;
|
||||||
use vec::{Vec1, Vec2, Vec3};
|
use vec::{Vec1, Vec2, Vec3};
|
||||||
|
Loading…
Reference in New Issue
Block a user