diff --git a/src/dmat.rs b/src/dmat.rs index 41142f17..16e700fb 100644 --- a/src/dmat.rs +++ b/src/dmat.rs @@ -63,6 +63,16 @@ impl DMat { 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)? diff --git a/src/dvec.rs b/src/dvec.rs index 5caee856..7931543d 100644 --- a/src/dvec.rs +++ b/src/dvec.rs @@ -59,19 +59,29 @@ impl DVec { } } +impl Container for DVec { + #[inline] + fn len(&self) -> uint { + self.at.len() + } +} + impl Iterable for DVec { + #[inline] fn iter<'l>(&'l self) -> VecIterator<'l, N> { self.at.iter() } } impl IterableMut for DVec { + #[inline] fn mut_iter<'l>(&'l mut self) -> VecMutIterator<'l, N> { self.at.mut_iter() } } impl FromIterator for DVec { + #[inline] fn from_iterator>(mut param: &mut I) -> DVec { let mut res = DVec { at: ~[] };