Fix warnings generated by the last rust-nightly.

This commit is contained in:
Sébastien Crozet 2015-08-20 21:41:40 +02:00
parent a862444c07
commit ca3c4e73c5
5 changed files with 24 additions and 15 deletions

View File

@ -81,7 +81,7 @@ extern crate num;
extern crate quickcheck; extern crate quickcheck;
use std::cmp; use std::cmp;
use std::ops::Neg; use std::ops::{Neg, Mul};
use num::{Zero, One}; use num::{Zero, One};
pub use traits::{ pub use traits::{
Absolute, Absolute,
@ -301,7 +301,7 @@ pub fn orig<P: Orig>() -> P {
/// Returns the center of two points. /// Returns the center of two points.
#[inline] #[inline]
pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy>(a: &P, b: &P) -> P { pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy + Norm<N>>(a: &P, b: &P) -> P {
let _2 = one::<N>() + one(); let _2 = one::<N>() + one();
(*a + *b.as_vec()) / _2 (*a + *b.as_vec()) / _2
} }
@ -582,7 +582,8 @@ pub fn rotation_between<V: RotationTo>(a: &V, b: &V) -> V::DeltaRotationType {
#[inline(always)] #[inline(always)]
pub fn to_rot_mat<N, LV, AV, R, M>(r: &R) -> M pub fn to_rot_mat<N, LV, AV, R, M>(r: &R) -> M
where R: RotationMatrix<N, LV, AV, Output = M>, where R: RotationMatrix<N, LV, AV, Output = M>,
M: SquareMat<N, LV> + Rotation<AV> + Copy M: SquareMat<N, LV> + Rotation<AV> + Copy,
LV: Mul<M, Output = LV>
{ {
// FIXME: rust-lang/rust#20413 // FIXME: rust-lang/rust#20413
r.to_rot_mat() r.to_rot_mat()
@ -819,7 +820,9 @@ pub fn mean<N, M: Mean<N>>(observations: &M) -> N {
*/ */
/// Computes the eigenvalues and eigenvectors of a square matrix usin the QR algorithm. /// Computes the eigenvalues and eigenvectors of a square matrix usin the QR algorithm.
#[inline(always)] #[inline(always)]
pub fn eigen_qr<N, V, M: EigenQR<N, V>>(m: &M, eps: &N, niter: usize) -> (M, V) { pub fn eigen_qr<N, V, M>(m: &M, eps: &N, niter: usize) -> (M, V)
where V: Mul<M, Output = V>,
M: EigenQR<N, V> {
EigenQR::eigen_qr(m, eps, niter) EigenQR::eigen_qr(m, eps, niter)
} }

View File

@ -74,6 +74,7 @@ pub fn qr<N, V, M>(m: &M) -> (M, M)
/// Eigendecomposition of a square matrix using the qr algorithm. /// Eigendecomposition of a square matrix using the qr algorithm.
pub fn eigen_qr<N, V, VS, M>(m: &M, eps: &N, niter: usize) -> (M, V) pub fn eigen_qr<N, V, VS, M>(m: &M, eps: &N, niter: usize) -> (M, V)
where N: BaseFloat, where N: BaseFloat,
V: Mul<M, Output = V>,
VS: Indexable<usize, N> + Norm<N>, VS: Indexable<usize, N> + Norm<N>,
M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> + M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> +
Sub<M, Output = M> + ColSlice<VS> + Sub<M, Output = M> + ColSlice<VS> +
@ -122,6 +123,7 @@ pub fn eigen_qr<N, V, VS, M>(m: &M, eps: &N, niter: usize) -> (M, V)
/// * `m` - square symmetric positive definite matrix to decompose /// * `m` - square symmetric positive definite matrix to decompose
pub fn cholesky<N, V, VS, M>(m: &M) -> Result<M, &'static str> pub fn cholesky<N, V, VS, M>(m: &M) -> Result<M, &'static str>
where N: BaseFloat, where N: BaseFloat,
V: Mul<M, Output = V>,
VS: Indexable<usize, N> + Norm<N>, VS: Indexable<usize, N> + Norm<N>,
M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> + M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> +
Sub<M, Output = M> + ColSlice<VS> + Sub<M, Output = M> + ColSlice<VS> +

View File

@ -1,6 +1,6 @@
//! Traits of operations having a well-known or explicit geometric meaning. //! Traits of operations having a well-known or explicit geometric meaning.
use std::ops::Neg; use std::ops::{Neg, Mul};
use traits::structure::{BaseFloat, SquareMat}; use traits::structure::{BaseFloat, SquareMat};
/// Trait of object which represent a translation, and to wich new translation /// Trait of object which represent a translation, and to wich new translation
@ -157,7 +157,7 @@ impl<LV: Neg<Output = LV> + Copy, AV, M: Rotation<AV> + Translation<LV>> Rotatio
/// Trait of transformation having a rotation extractable as a rotation matrix. This can typically /// Trait of transformation having a rotation extractable as a rotation matrix. This can typically
/// be implemented by quaternions to convert them to a rotation matrix. /// be implemented by quaternions to convert them to a rotation matrix.
pub trait RotationMatrix<N, LV, AV> : Rotation<AV> { pub trait RotationMatrix<N, LV: Mul<Self::Output, Output = LV>, AV> : Rotation<AV> {
/// The output rotation matrix type. /// The output rotation matrix type.
type Output: SquareMat<N, LV> + Rotation<AV>; type Output: SquareMat<N, LV> + Rotation<AV>;
@ -282,7 +282,7 @@ pub trait FromHomogeneous<U> {
/// ///
/// The number of sample must be sufficient to approximate a sphere using a support mapping /// The number of sample must be sufficient to approximate a sphere using a support mapping
/// function. /// function.
pub trait UniformSphereSample { pub trait UniformSphereSample : Sized {
/// Iterate through the samples. /// Iterate through the samples.
fn sample<F: FnMut(Self)>(F); fn sample<F: FnMut(Self)>(F);
} }

View File

@ -1,6 +1,7 @@
//! Low level operations on vectors and matrices. //! Low level operations on vectors and matrices.
use num::{Float, Signed}; use num::{Float, Signed};
use std::ops::Mul;
use std::cmp::Ordering; use std::cmp::Ordering;
use traits::structure::SquareMat; use traits::structure::SquareMat;
@ -275,7 +276,7 @@ pub trait Absolute<A> {
} }
/// Trait of objects having an inverse. Typically used to implement matrix inverse. /// Trait of objects having an inverse. Typically used to implement matrix inverse.
pub trait Inv { pub trait Inv: Sized {
/// Returns the inverse of `m`. /// Returns the inverse of `m`.
fn inv(&self) -> Option<Self>; fn inv(&self) -> Option<Self>;
@ -334,7 +335,7 @@ pub trait Mean<N> {
} }
/// Trait for computing the eigenvector and eigenvalues of a square matrix usin the QR algorithm. /// Trait for computing the eigenvector and eigenvalues of a square matrix usin the QR algorithm.
pub trait EigenQR<N, V>: SquareMat<N, V> { pub trait EigenQR<N, V: Mul<Self, Output = V>>: SquareMat<N, V> {
/// Computes the eigenvectors and eigenvalues of this matrix. /// Computes the eigenvectors and eigenvalues of this matrix.
fn eigen_qr(&self, eps: &N, niter: usize) -> (Self, V); fn eigen_qr(&self, eps: &N, niter: usize) -> (Self, V);
} }

View File

@ -59,7 +59,8 @@ pub trait Cast<T> {
/// Trait of matrices. /// Trait of matrices.
/// ///
/// A matrix has rows and columns and are able to multiply them. /// A matrix has rows and columns and are able to multiply them.
pub trait Mat<N, R, C: Mul<Self, Output = R>>: Row<R> + Col<C> + Mul<R, Output = C> + pub trait Mat<N, R, C: Mul<Self, Output = R>>: Sized +
Row<R> + Col<C> + Mul<R, Output = C> +
Index<(usize, usize), Output = N> Index<(usize, usize), Output = N>
{ } { }
@ -69,12 +70,14 @@ impl<N, M, R, C> Mat<N, R, C> for M
{ } { }
/// Trait implemented by square matrices. /// Trait implemented by square matrices.
pub trait SquareMat<N, V>: Mat<N, V, V> + pub trait SquareMat<N, V: Mul<Self, Output = V>>: Mat<N, V, V> +
Mul<Self, Output = Self> + Eye + Transpose + Diag<V> + Inv + Dim + One { Mul<Self, Output = Self> +
Eye + Transpose + Diag<V> + Inv + Dim + One {
} }
impl<N, V, M> SquareMat<N, V> for M impl<N, V, M> SquareMat<N, V> for M
where M: Mat<N, V, V> + Mul<M, Output = M> + Eye + Transpose + Diag<V> + Inv + Dim + One { where M: Mat<N, V, V> + Mul<M, Output = M> + Eye + Transpose + Diag<V> + Inv + Dim + One,
V: Mul<M, Output = V> {
} }
/// Trait for constructing the identity matrix /// Trait for constructing the identity matrix
@ -101,7 +104,7 @@ pub trait Bounded {
// FIXME: return an iterator instead // FIXME: return an iterator instead
/// Traits of objects which can form a basis (typically vectors). /// Traits of objects which can form a basis (typically vectors).
pub trait Basis { pub trait Basis: Sized {
/// Iterates through the canonical basis of the space in which this object lives. /// Iterates through the canonical basis of the space in which this object lives.
fn canonical_basis<F: FnMut(Self) -> bool>(F); fn canonical_basis<F: FnMut(Self) -> bool>(F);
@ -153,7 +156,7 @@ pub trait RowSlice<R> {
} }
/// Trait of objects having a spacial dimension known at compile time. /// Trait of objects having a spacial dimension known at compile time.
pub trait Dim { pub trait Dim: Sized {
/// The dimension of the object. /// The dimension of the object.
fn dim(unused_mut: Option<Self>) -> usize; fn dim(unused_mut: Option<Self>) -> usize;
} }