Type Definition extendr_api::wrapper::matrix::RMatrix

source ·
pub type RMatrix<T> = RArray<T, [usize; 2]>;



impl<'a, T: ToVectorValue + 'a> RMatrix<T>where Robj: AsTypedSlice<'a, T>,


pub fn new_matrix<F: Clone + FnMut(usize, usize) -> T>( nrows: usize, ncols: usize, f: F ) -> Self

Create a new matrix wrapper.

  • nrows - the number of rows the returned matrix will have
  • ncols - the number of columns the returned matrix will have
  • f - a function that will be called for each entry of the matrix in order to populate it with values. It must return a scalar value that can be converted to an R scalar, such as u32, f64, i.e. see ToVectorValue. It accepts two arguments:
    • r - the current row of the entry we are creating
    • c - the current column of the entry we are creating

pub fn nrows(&self) -> usize

Get the number of rows.


pub fn ncols(&self) -> usize

Get the number of columns.

Trait Implementations§


impl<'a, T: 'a> TryFrom<Robj> for RMatrix<T>where Robj: AsTypedSlice<'a, T>,


type Error = Error

The type returned in the event of a conversion error.

fn try_from(robj: Robj) -> Result<Self>

Performs the conversion.