Add nrow()
, ncols()
methods for DMat
, and Container impl. for DVec
.
This commit is contained in:
parent
3ab06faef6
commit
57b89b38df
10
src/dmat.rs
10
src/dmat.rs
@ -63,6 +63,16 @@ impl<N> DMat<N> {
|
||||
mij: vec::from_fn(nrows * ncols, |i| { let m = i % ncols; f(m, m - i * ncols) })
|
||||
}
|
||||
}
|
||||
|
||||
/// The number of row on the matrix.
|
||||
pub fn nrows(&self) -> uint {
|
||||
self.nrows
|
||||
}
|
||||
|
||||
/// The number of columns on the matrix.
|
||||
pub fn ncols(&self) -> uint {
|
||||
self.ncols
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: add a function to modify the dimension (to avoid useless allocations)?
|
||||
|
10
src/dvec.rs
10
src/dvec.rs
@ -59,19 +59,29 @@ impl<N: Clone> DVec<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> Container for DVec<N> {
|
||||
#[inline]
|
||||
fn len(&self) -> uint {
|
||||
self.at.len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> Iterable<N> for DVec<N> {
|
||||
#[inline]
|
||||
fn iter<'l>(&'l self) -> VecIterator<'l, N> {
|
||||
self.at.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> IterableMut<N> for DVec<N> {
|
||||
#[inline]
|
||||
fn mut_iter<'l>(&'l mut self) -> VecMutIterator<'l, N> {
|
||||
self.at.mut_iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<N> FromIterator<N> for DVec<N> {
|
||||
#[inline]
|
||||
fn from_iterator<I: Iterator<N>>(mut param: &mut I) -> DVec<N> {
|
||||
let mut res = DVec { at: ~[] };
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user