Rename Norm associated type to Output

This commit is contained in:
Tinco Andringa 2015-05-09 01:20:31 +02:00
parent 76debe8669
commit 708b9bb341
8 changed files with 17 additions and 17 deletions

View File

@ -320,13 +320,13 @@ pub fn center<N: BaseFloat, P: FloatPnt<N, V>, V: Copy>(a: &P, b: &P) -> P {
*/
/// Returns the distance between two points.
#[inline(always)]
pub fn dist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N=N>>(a: &P, b: &P) -> N {
pub fn dist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<Output=N>>(a: &P, b: &P) -> N {
a.dist(b)
}
/// Returns the squared distance between two points.
#[inline(always)]
pub fn sqdist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<N=N>>(a: &P, b: &P) -> N {
pub fn sqdist<N: BaseFloat, P: FloatPnt<N, V>, V: Norm<Output=N>>(a: &P, b: &P) -> N {
a.sqdist(b)
}
@ -647,19 +647,19 @@ pub fn dot<V: Dot<N>, N>(a: &V, b: &V) -> N {
/// Computes the L2 norm of a vector.
#[inline(always)]
pub fn norm<V: Norm<N=N>, N: BaseFloat>(v: &V) -> N {
pub fn norm<V: Norm<Output=N>, N: BaseFloat>(v: &V) -> N {
Norm::norm(v)
}
/// Computes the squared L2 norm of a vector.
#[inline(always)]
pub fn sqnorm<V: Norm<N=N>, N: BaseFloat>(v: &V) -> N {
pub fn sqnorm<V: Norm<Output=N>, N: BaseFloat>(v: &V) -> N {
Norm::sqnorm(v)
}
/// Gets the normalized version of a vector.
#[inline(always)]
pub fn normalize<V: Norm<N=N>, N: BaseFloat>(v: &V) -> V {
pub fn normalize<V: Norm<Output=N>, N: BaseFloat>(v: &V) -> V {
Norm::normalize(v)
}

View File

@ -40,7 +40,7 @@ pub fn householder_matrix<N, V, M>(dim: usize, start: usize, vec: V) -> M
/// * `m` - matrix to decompose
pub fn qr<N, V, M>(m: &M) -> (M, M)
where N: BaseFloat,
V: Indexable<usize, N> + Norm<N=N>,
V: Indexable<usize, N> + Norm<Output=N>,
M: Copy + Eye + ColSlice<V> + Transpose + Indexable<(usize, usize), N> +
Mul<M, Output = M> {
let (rows, cols) = m.shape();
@ -74,7 +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,
VS: Indexable<usize, N> + Norm<N=N>,
VS: Indexable<usize, N> + Norm<Output=N>,
M: Indexable<(usize, usize), N> + SquareMat<N, V> + Add<M, Output = M> +
Sub<M, Output = M> + ColSlice<VS> +
ApproxEq<N> + Copy {

View File

@ -266,7 +266,7 @@ macro_rules! dvec_impl(
}
impl<N: BaseFloat> Norm for $dvec<N> {
type N = N;
type Output = N;
#[inline]
fn sqnorm(&self) -> N {

View File

@ -109,7 +109,7 @@ impl<N: BaseFloat + ApproxEq<N>> Inv for Quat<N> {
}
impl<N: BaseFloat> Norm for Quat<N> {
type N = N;
type Output = N;
#[inline]
fn sqnorm(&self) -> N {

View File

@ -183,7 +183,7 @@ impl<N: Copy + Add<N, Output = N> + Neg<Output = N>> Translation<vec::Vec0<N>> f
}
impl<N: BaseFloat> Norm for vec::Vec0<N> {
type N = N;
type Output = N;
#[inline]
fn sqnorm(&self) -> N {

View File

@ -548,7 +548,7 @@ macro_rules! translation_impl(
macro_rules! norm_impl(
($t: ident, $($compN: ident),+) => (
impl<N: Copy + BaseFloat> Norm for $t<N> {
type N = N;
type Output = N;
#[inline]
fn sqnorm(&self) -> N {

View File

@ -211,23 +211,23 @@ pub trait Dot<N> {
/// Traits of objects having an euclidian norm.
pub trait Norm {
/// N is the type of the normal
type N: BaseFloat;
type Output: BaseFloat;
/// Computes the norm of `self`.
#[inline]
fn norm(&self) -> Self::N {
fn norm(&self) -> Self::Output {
self.sqnorm().sqrt()
}
/// Computes the squared norm of `self`.
///
/// This is usually faster than computing the norm itself.
fn sqnorm(&self) -> Self::N;
fn sqnorm(&self) -> Self::Output;
/// Gets the normalized version of a copy of `v`.
fn normalize(&self) -> Self;
/// Normalizes `self`.
fn normalize_mut(&mut self) -> Self::N;
fn normalize_mut(&mut self) -> Self::Output;
}
/**

View File

@ -215,7 +215,7 @@ pub trait NumVec<N>: Dim +
}
/// Trait of vector with components implementing the `BaseFloat` trait.
pub trait FloatVec<N: BaseFloat>: NumVec<N> + Norm<N=N> + Neg<Output = Self> + Basis {
pub trait FloatVec<N: BaseFloat>: NumVec<N> + Norm<Output=N> + Neg<Output = Self> + Basis {
}
/*
@ -253,7 +253,7 @@ pub trait NumPnt<N, V>:
}
/// Trait of points with components implementing the `BaseFloat` trait.
pub trait FloatPnt<N: BaseFloat, V: Norm<N=N>>: NumPnt<N, V> + Sized {
pub trait FloatPnt<N: BaseFloat, V: Norm<Output=N>>: NumPnt<N, V> + Sized {
/// Computes the square distance between two points.
#[inline]
fn sqdist(&self, other: &Self) -> N {