Type Alias extendr_api::wrapper::matrix::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>,

§

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>,

§

type Error = Error

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

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

Performs the conversion.