From ca3c4e73c5bbb6ec22903a55ee63719425a03c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Crozet?= Date: Thu, 20 Aug 2015 21:41:40 +0200 Subject: [PATCH] Fix warnings generated by the last rust-nightly. --- src/lib.rs | 11 +++++++---- src/linalg/decompositions.rs | 2 ++ src/traits/geometry.rs | 6 +++--- src/traits/operations.rs | 5 +++-- src/traits/structure.rs | 15 +++++++++------ 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1c8a738c..595da543 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,7 +81,7 @@ extern crate num; extern crate quickcheck; use std::cmp; -use std::ops::Neg; +use std::ops::{Neg, Mul}; use num::{Zero, One}; pub use traits::{ Absolute, @@ -301,7 +301,7 @@ pub fn orig() -> P { /// Returns the center of two points. #[inline] -pub fn center, V: Copy>(a: &P, b: &P) -> P { +pub fn center, V: Copy + Norm>(a: &P, b: &P) -> P { let _2 = one::() + one(); (*a + *b.as_vec()) / _2 } @@ -582,7 +582,8 @@ pub fn rotation_between(a: &V, b: &V) -> V::DeltaRotationType { #[inline(always)] pub fn to_rot_mat(r: &R) -> M where R: RotationMatrix, - M: SquareMat + Rotation + Copy + M: SquareMat + Rotation + Copy, + LV: Mul { // FIXME: rust-lang/rust#20413 r.to_rot_mat() @@ -819,7 +820,9 @@ pub fn mean>(observations: &M) -> N { */ /// Computes the eigenvalues and eigenvectors of a square matrix usin the QR algorithm. #[inline(always)] -pub fn eigen_qr>(m: &M, eps: &N, niter: usize) -> (M, V) { +pub fn eigen_qr(m: &M, eps: &N, niter: usize) -> (M, V) + where V: Mul, + M: EigenQR { EigenQR::eigen_qr(m, eps, niter) } diff --git a/src/linalg/decompositions.rs b/src/linalg/decompositions.rs index 9a5b2db2..5cbcc63b 100644 --- a/src/linalg/decompositions.rs +++ b/src/linalg/decompositions.rs @@ -74,6 +74,7 @@ pub fn qr(m: &M) -> (M, M) /// Eigendecomposition of a square matrix using the qr algorithm. pub fn eigen_qr(m: &M, eps: &N, niter: usize) -> (M, V) where N: BaseFloat, + V: Mul, VS: Indexable + Norm, M: Indexable<(usize, usize), N> + SquareMat + Add + Sub + ColSlice + @@ -122,6 +123,7 @@ pub fn eigen_qr(m: &M, eps: &N, niter: usize) -> (M, V) /// * `m` - square symmetric positive definite matrix to decompose pub fn cholesky(m: &M) -> Result where N: BaseFloat, + V: Mul, VS: Indexable + Norm, M: Indexable<(usize, usize), N> + SquareMat + Add + Sub + ColSlice + diff --git a/src/traits/geometry.rs b/src/traits/geometry.rs index ffc2db7e..e4b996a7 100644 --- a/src/traits/geometry.rs +++ b/src/traits/geometry.rs @@ -1,6 +1,6 @@ //! 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}; /// Trait of object which represent a translation, and to wich new translation @@ -157,7 +157,7 @@ impl + Copy, AV, M: Rotation + Translation> Rotatio /// 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. -pub trait RotationMatrix : Rotation { +pub trait RotationMatrix, AV> : Rotation { /// The output rotation matrix type. type Output: SquareMat + Rotation; @@ -282,7 +282,7 @@ pub trait FromHomogeneous { /// /// The number of sample must be sufficient to approximate a sphere using a support mapping /// function. -pub trait UniformSphereSample { +pub trait UniformSphereSample : Sized { /// Iterate through the samples. fn sample(F); } diff --git a/src/traits/operations.rs b/src/traits/operations.rs index f8a7ca74..80c899ce 100644 --- a/src/traits/operations.rs +++ b/src/traits/operations.rs @@ -1,6 +1,7 @@ //! Low level operations on vectors and matrices. use num::{Float, Signed}; +use std::ops::Mul; use std::cmp::Ordering; use traits::structure::SquareMat; @@ -275,7 +276,7 @@ pub trait Absolute { } /// Trait of objects having an inverse. Typically used to implement matrix inverse. -pub trait Inv { +pub trait Inv: Sized { /// Returns the inverse of `m`. fn inv(&self) -> Option; @@ -334,7 +335,7 @@ pub trait Mean { } /// Trait for computing the eigenvector and eigenvalues of a square matrix usin the QR algorithm. -pub trait EigenQR: SquareMat { +pub trait EigenQR>: SquareMat { /// Computes the eigenvectors and eigenvalues of this matrix. fn eigen_qr(&self, eps: &N, niter: usize) -> (Self, V); } diff --git a/src/traits/structure.rs b/src/traits/structure.rs index f579cdbe..13f7a943 100644 --- a/src/traits/structure.rs +++ b/src/traits/structure.rs @@ -59,7 +59,8 @@ pub trait Cast { /// Trait of matrices. /// /// A matrix has rows and columns and are able to multiply them. -pub trait Mat>: Row + Col + Mul + +pub trait Mat>: Sized + + Row + Col + Mul + Index<(usize, usize), Output = N> { } @@ -69,12 +70,14 @@ impl Mat for M { } /// Trait implemented by square matrices. -pub trait SquareMat: Mat + - Mul + Eye + Transpose + Diag + Inv + Dim + One { +pub trait SquareMat>: Mat + + Mul + + Eye + Transpose + Diag + Inv + Dim + One { } impl SquareMat for M - where M: Mat + Mul + Eye + Transpose + Diag + Inv + Dim + One { + where M: Mat + Mul + Eye + Transpose + Diag + Inv + Dim + One, + V: Mul { } /// Trait for constructing the identity matrix @@ -101,7 +104,7 @@ pub trait Bounded { // FIXME: return an iterator instead /// 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. fn canonical_basis bool>(F); @@ -153,7 +156,7 @@ pub trait RowSlice { } /// Trait of objects having a spacial dimension known at compile time. -pub trait Dim { +pub trait Dim: Sized { /// The dimension of the object. fn dim(unused_mut: Option) -> usize; }