Skip to main content

RMatrix

Type Alias RMatrix 

Source
pub type RMatrix<T> = RArray<T, 2>;
Expand description

A 2-dimensional R matrix.

Aliased Type§

#[repr(transparent)]
pub struct RMatrix<T> { sexp: SEXP, _marker: PhantomData<*const T>, }

Fields§

§sexp: SEXP§_marker: PhantomData<*const T>

Implementations§

Source§

impl<T: RNativeType> RMatrix<T>

Source

pub unsafe fn nrow(&self) -> usize

Get the number of rows.

§Safety

The SEXP must be valid.

Source

pub unsafe fn ncol(&self) -> usize

Get the number of columns.

§Safety

The SEXP must be valid.

Source

pub unsafe fn get_rc(&self, row: usize, col: usize) -> T
where T: Copy,

Get an element by row and column.

§Safety

The SEXP must be protected and valid.

Source

pub unsafe fn set_rc(&mut self, row: usize, col: usize, value: T)
where T: Copy,

Set an element by row and column.

§Safety
  • The SEXP must be protected and valid
  • No other references to the data may exist
Source

pub unsafe fn column(&self, col: usize) -> &[T]

Get a column as a slice.

§Safety

The SEXP must be protected and valid.

Source

pub unsafe fn column_mut(&mut self, col: usize) -> &mut [T]

Get a mutable column as a slice.

Columns are contiguous in R’s column-major layout, so this returns a proper &mut [T] without any striding.

§Safety

The SEXP must be protected and valid.

§Panics

Panics if col >= ncol.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 8 bytes