2013-07-24 22:50:40 +08:00
|
|
|
/// Traits of objecs which can form a basis.
|
2013-05-19 01:04:03 +08:00
|
|
|
pub trait Basis
|
|
|
|
{
|
2013-08-05 15:44:56 +08:00
|
|
|
/// Iterate through the canonical basis of the space in which this object lives.
|
|
|
|
fn canonical_basis(&fn(Self));
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
/// Iterate through a basis of the subspace orthogonal to `self`.
|
|
|
|
fn orthonormal_subspace_basis(&self, &fn(Self));
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
/// Creates the canonical basis of the space in which this object lives.
|
|
|
|
fn canonical_basis_list() -> ~[Self]
|
|
|
|
{
|
|
|
|
let mut res = ~[];
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
do Basis::canonical_basis::<Self> |elem|
|
|
|
|
{ res.push(elem) }
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
res
|
|
|
|
}
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
/// Creates a basis of the subspace orthogonal to `self`.
|
|
|
|
fn orthonormal_subspace_basis_list(&self) -> ~[Self]
|
|
|
|
{
|
|
|
|
let mut res = ~[];
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
do self.orthonormal_subspace_basis |elem|
|
|
|
|
{ res.push(elem) }
|
2013-07-24 22:50:40 +08:00
|
|
|
|
2013-08-05 15:44:56 +08:00
|
|
|
res
|
|
|
|
}
|
2013-05-19 01:04:03 +08:00
|
|
|
}
|