Type Alias RMatrix3D

Source
pub type RMatrix3D<T> = RArray<T, [usize; 3]>;

Aliased Type§

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

Fields§

§robj: Robj

Owning Robj (probably should be a Pin).

§dim: [usize; 3]

Dimensions of the array.

§_data: PhantomData<T>

Implementations§

Source§

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

Source

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

Source

pub fn nrows(&self) -> usize

Get the number of rows.

Source

pub fn ncols(&self) -> usize

Get the number of columns.

Source

pub fn nsub(&self) -> usize

Get the number of submatrices.

Source§

impl<T, D> RArray<T, D>
where Robj: for<'a> AsTypedSlice<'a, T>,

Source

pub fn from_parts(robj: Robj, dim: D) -> Self

Source

pub fn data(&self) -> &[T]

Returns a flat representation of the array in col-major.

Source

pub fn data_mut(&mut self) -> &mut [T]

Returns a flat, mutable representation of the array in col-major.

Source

pub fn dim(&self) -> &D

Get the dimensions for this array.

Source§

impl<T, D> RArray<T, D>

Source

pub fn get_dimnames(&self) -> List

Source

pub fn set_names(&mut self, names: Strings)

Set the names of the elements of an array.

Equivalent to names<- in R

Source

pub fn set_dimnames(&mut self, dimnames: List)

Set the dimension names of an array.

For RMatrix a list of length 2 is required, as that would entail column-names and row-names. If you only wish to set one, but not the other, then the unset element must be R NULL

Equivalent to dimnames<- in R

Source

pub fn set_dim(&mut self, dim: Robj)

Set the dimensions of an array.

Equivalent to dim<-

Trait Implementations§

Source§

impl<T> TryFrom<&Robj> for RMatrix3D<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 RMatrix3D<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: Debug, D: Debug> Debug for RArray<T, D>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T, D> Deref for RArray<T, D>

Source§

type Target = Robj

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<T, D> DerefMut for RArray<T, D>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<T> Index<[usize; 3]> for RArray<T, [usize; 3]>
where Robj: for<'a> AsTypedSlice<'a, T>,

Source§

fn index(&self, index: [usize; 3]) -> &Self::Output

Zero-based indexing in row, column order.

Panics if out of bounds.

use extendr_api::prelude::*;
test! {
   let matrix = RArray::new_matrix3d(3, 2, 2, |r, c, d| (r + c + d) as f64);
    assert_eq!(matrix[[0, 0, 0]], 0.);
    assert_eq!(matrix[[1, 0, 1]], 2.);
    assert_eq!(matrix[[2, 1, 1]], 4.);
}
Source§

type Output = T

The returned type after indexing.
Source§

impl<T> IndexMut<[usize; 3]> for RArray<T, [usize; 3]>
where Robj: for<'a> AsTypedSlice<'a, T>,

Source§

fn index_mut(&mut self, index: [usize; 3]) -> &mut Self::Output

Zero-based mutable indexing in row, column order.

Panics if out of bounds.

use extendr_api::prelude::*;
test! {
   let mut matrix = RMatrix3D::new_matrix3d(3, 2, 2, |_, _, _| 0.);
   matrix[[0, 0, 0]] = 1.;
   matrix[[1, 0, 0]] = 2.;
   matrix[[2, 0, 0]] = 3.;
   matrix[[0, 1, 0]] = 4.;
   assert_eq!(matrix.as_real_slice().unwrap(),
       &[1., 2., 3., 4., 0., 0., 0., 0., 0., 0., 0., 0.]);
}
Source§

impl<T> Offset<[usize; 3]> for RArray<T, [usize; 3]>

Source§

fn offset(&self, index: [usize; 3]) -> usize

Get the offset into the array for a given index.

Source§

impl<T: PartialEq, D: PartialEq> PartialEq for RArray<T, D>

Source§

fn eq(&self, other: &RArray<T, D>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T, D> StructuralPartialEq for RArray<T, D>