extendr_api::wrapper::matrix

Type Alias RMatrix

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

Aliased Type§

struct RMatrix<T> {
    robj: Robj,
    dim: [usize; 2],
    _data: PhantomData<T>,
}

Fields§

§robj: Robj

Owning Robj (probably should be a Pin).

§dim: [usize; 2]

Dimensions of the array.

§_data: PhantomData<T>

Implementations§

Source§

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

Source

pub fn new(nrow: usize, ncol: usize) -> Self

Returns an RMatrix with dimensions according to nrow and ncol, with arbitrary entries. To initialize a matrix containing only NA values, use RMatrix::new_with_na.

Source§

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

Source

pub fn new_with_na(nrow: usize, ncol: usize) -> Self

Returns an RMatrix with dimensions according to nrow and ncol, with all entries set to NA.

Note that since Raw does not have an NA representation in R, this method is not implemented for [Rbyte].

Source§

impl<T> RMatrix<T>

Source§

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

Source

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

Create a new matrix wrapper.

§Arguments
  • 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 i32, u32, or 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
Source

pub fn nrows(&self) -> usize

Get the number of rows.

Source

pub fn ncols(&self) -> usize

Get the number of columns.

Trait Implementations§

Source§

impl From<Mat<f64>> for RMatrix<Rfloat>

Source§

fn from(value: Mat<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<Mat<f64>> for RMatrix<f64>

Convert a faer::Mat<f64> into an RMatrix<f64> which is not NA aware.

Source§

fn from(value: Mat<f64>) -> Self

Converts to this type from the input type.
Source§

impl From<MatRef<'_, f64>> for RMatrix<Rfloat>

Source§

fn from(value: MatRef<'_, f64>) -> Self

Converts to this type from the input type.
Source§

impl From<MatRef<'_, f64>> for RMatrix<f64>

Convert a faer::Mat<f64> into an RMatrix<f64> which is not NA aware.

Source§

fn from(value: MatRef<'_, f64>) -> Self

Convert a faer MatRef into Robj.

Source§

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

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

type Error = Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.