forked from M-Labs/nalgebra
Fix warnings generated by the last rust-nightly.
This commit is contained in:
parent
a862444c07
commit
ca3c4e73c5
11
src/lib.rs
11
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: Orig>() -> P {
|
||||
|
||||
/// Returns the center of two points.
|
||||
#[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();
|
||||
(*a + *b.as_vec()) / _2
|
||||
}
|
||||
@ -582,7 +582,8 @@ pub fn rotation_between<V: RotationTo>(a: &V, b: &V) -> V::DeltaRotationType {
|
||||
#[inline(always)]
|
||||
pub fn to_rot_mat<N, LV, AV, R, M>(r: &R) -> 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
|
||||
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.
|
||||
#[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)
|
||||
}
|
||||
|
||||
|
@ -74,6 +74,7 @@ pub fn qr<N, V, M>(m: &M) -> (M, M)
|
||||
/// 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)
|
||||
where N: BaseFloat,
|
||||
V: Mul<M, Output = V>,
|
||||
VS: Indexable<usize, N> + Norm<N>,
|
||||
M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> +
|
||||
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
|
||||
pub fn cholesky<N, V, VS, M>(m: &M) -> Result<M, &'static str>
|
||||
where N: BaseFloat,
|
||||
V: Mul<M, Output = V>,
|
||||
VS: Indexable<usize, N> + Norm<N>,
|
||||
M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> +
|
||||
Sub<M, Output = M> + ColSlice<VS> +
|
||||
|
@ -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<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
|
||||
/// 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.
|
||||
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
|
||||
/// function.
|
||||
pub trait UniformSphereSample {
|
||||
pub trait UniformSphereSample : Sized {
|
||||
/// Iterate through the samples.
|
||||
fn sample<F: FnMut(Self)>(F);
|
||||
}
|
||||
|
@ -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<A> {
|
||||
}
|
||||
|
||||
/// 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<Self>;
|
||||
|
||||
@ -334,7 +335,7 @@ pub trait Mean<N> {
|
||||
}
|
||||
|
||||
/// 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.
|
||||
fn eigen_qr(&self, eps: &N, niter: usize) -> (Self, V);
|
||||
}
|
||||
|
@ -59,7 +59,8 @@ pub trait Cast<T> {
|
||||
/// Trait of matrices.
|
||||
///
|
||||
/// 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>
|
||||
{ }
|
||||
|
||||
@ -69,12 +70,14 @@ impl<N, M, R, C> Mat<N, R, C> for M
|
||||
{ }
|
||||
|
||||
/// Trait implemented by square matrices.
|
||||
pub trait SquareMat<N, V>: Mat<N, V, V> +
|
||||
Mul<Self, Output = Self> + Eye + Transpose + Diag<V> + Inv + Dim + One {
|
||||
pub trait SquareMat<N, V: Mul<Self, Output = V>>: Mat<N, V, V> +
|
||||
Mul<Self, Output = Self> +
|
||||
Eye + Transpose + Diag<V> + Inv + Dim + One {
|
||||
}
|
||||
|
||||
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
|
||||
@ -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<F: FnMut(Self) -> bool>(F);
|
||||
|
||||
@ -153,7 +156,7 @@ pub trait RowSlice<R> {
|
||||
}
|
||||
|
||||
/// 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<Self>) -> usize;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user