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>
impl<T> RMatrix3D<T>
Source§impl<T, D> RArray<T, D>where
Robj: for<'a> AsTypedSlice<'a, T>,
impl<T, D> RArray<T, D>where
Robj: for<'a> AsTypedSlice<'a, T>,
Source§impl<T, D> RArray<T, D>
impl<T, D> RArray<T, D>
pub fn get_dimnames(&self) -> List
Sourcepub fn set_names(&mut self, names: Strings)
pub fn set_names(&mut self, names: Strings)
Set the names of the elements of an array.
Equivalent to names<-
in R
Sourcepub fn set_dimnames(&mut self, dimnames: List)
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
Trait Implementations§
Source§impl<T> Index<[usize; 3]> for RArray<T, [usize; 3]>where
Robj: for<'a> AsTypedSlice<'a, T>,
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
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§impl<T> IndexMut<[usize; 3]> for RArray<T, [usize; 3]>where
Robj: for<'a> AsTypedSlice<'a, T>,
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
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.]);
}