Add comments for traits.

This commit is contained in:
Sébastien Crozet 2013-05-16 21:59:41 +00:00
parent 699e4c5bb7
commit 7a58f2c66a
6 changed files with 26 additions and 3 deletions

View File

@ -134,8 +134,7 @@ LMul<NVec<D, T>> for NMat<D, T>
impl<D: Dim, impl<D: Dim,
T: Clone + Copy + Eq + One + Zero + T: Clone + Copy + Eq + One + Zero +
Mul<T, T> + Quot<T, T> + Sub<T, T> + Neg<T> Mul<T, T> + Quot<T, T> + Sub<T, T> + Neg<T>>
>
Inv for NMat<D, T> Inv for NMat<D, T>
{ {
fn inverse(&self) -> NMat<D, T> fn inverse(&self) -> NMat<D, T>
@ -161,7 +160,7 @@ Inv for NMat<D, T>
// instead? // instead?
// FIXME: this is kind of uggly… // FIXME: this is kind of uggly…
// … but we cannot use position_betwee since we are iterating on one // … but we cannot use position_between since we are iterating on one
// columns // columns
let mut n0 = 0u; // index of a non-zero entry let mut n0 = 0u; // index of a non-zero entry

View File

@ -1,4 +1,5 @@
pub trait Cross<Result> pub trait Cross<Result>
{ {
/// Computes the cross product between two elements (usually vectors).
fn cross(&self, other : &Self) -> Result; fn cross(&self, other : &Self) -> Result;
} }

View File

@ -1,14 +1,25 @@
pub trait Dim pub trait Dim
{ {
/// The dimension of the object.
fn dim() -> uint; fn dim() -> uint;
} }
// Some dimension token. Useful to restrict the dimension of n-dimensional // Some dimension token. Useful to restrict the dimension of n-dimensional
// object at the type-level. // object at the type-level.
/// Dimensional token for 0-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
pub struct d0; pub struct d0;
/// Dimensional token for 1-dimension. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
pub struct d1; pub struct d1;
/// Dimensional token for 2-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
pub struct d2; pub struct d2;
/// Dimensional token for 3-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
pub struct d3; pub struct d3;
/// Dimensional token for 4-dimensions. Dimensional tokens are the preferred
/// way to specify at the type level the dimension of n-dimensional objects.
pub struct d4; pub struct d4;
impl Dim for d0 impl Dim for d0

View File

@ -1,6 +1,14 @@
pub trait Dot<T> pub trait Dot<T>
{ {
/// Computes the dot (inner) product of two objects.
fn dot(&self, &Self) -> T; fn dot(&self, &Self) -> T;
/// Computes the norm a an object.
fn norm(&self) -> T; fn norm(&self) -> T;
/**
* Computes the squared norm of an object.
*
* Computes the squared norm of an object. Computation of the squared norm
* is usually faster than the norm itself.
*/
fn sqnorm(&self) -> T; // { self.dot(self); } fn sqnorm(&self) -> T; // { self.dot(self); }
} }

View File

@ -1,5 +1,7 @@
pub trait Inv pub trait Inv
{ {
/// Returns the inverse of an element.
fn inverse(&self) -> Self; fn inverse(&self) -> Self;
/// Inplace version of `inverse`.
fn invert(&mut self); fn invert(&mut self);
} }

View File

@ -1,6 +1,8 @@
// FIXME: valid only for square matrices… // FIXME: valid only for square matrices…
pub trait Transpose pub trait Transpose
{ {
/// Computes the transpose of a matrix.
fn transposed(&self) -> Self; fn transposed(&self) -> Self;
/// Inplace version of `transposed`.
fn transpose(&mut self); fn transpose(&mut self);
} }