Struct extendr_api::matrix::RArray [−][src]
Wrapper for creating and using matrices and arrays.
use extendr_api::prelude::*; test! { let matrix = RMatrix::new([ 1., 2., 3., 4., 5., 6.], 3, 2); let robj = r!(matrix); assert_eq!(robj.is_matrix(), true); assert_eq!(robj.nrows(), 3); assert_eq!(robj.ncols(), 2); let matrix2 : RMatrix<&[f64]> = robj.as_matrix().ok_or("error")?; assert_eq!(matrix2.data().len(), 6); assert_eq!(matrix2.nrows(), 3); assert_eq!(matrix2.ncols(), 2); }
Implementations
impl<T, D> RArray<T, D>
[src]
pub fn data(&self) -> &T
[src]
Get the underlying data fro this array.
pub fn dim(&self) -> &D
[src]
Get the dimensions for this array.
impl<T> RArray<T, [usize; 1]>
[src]
pub fn new(data: T, nrows: usize) -> Self
[src]
Make a new vector type.
pub fn nrows(&self) -> usize
[src]
Get the number of rows.
impl<T> RArray<T, [usize; 2]>
[src]
pub fn new(data: T, nrows: usize, ncols: usize) -> Self
[src]
Create a new matrix wrapper.
pub fn nrows(&self) -> usize
[src]
Get the number of rows.
pub fn ncols(&self) -> usize
[src]
Get the number of columns.
impl<T> RArray<T, [usize; 3]>
[src]
pub fn new(data: T, nrows: usize, ncols: usize, nsub: usize) -> Self
[src]
Create a new matrix wrapper.
pub fn nrows(&self) -> usize
[src]
Get the number of rows.
pub fn ncols(&self) -> usize
[src]
Get the number of columns.
pub fn nsub(&self) -> usize
[src]
Get the number of submatrices.
Trait Implementations
impl<T: Debug, D: Debug> Debug for RArray<T, D>
[src]
impl<T> From<RArray<T, [usize; 1]>> for Robj where
T: Into<Robj>,
[src]
T: Into<Robj>,
impl<T> From<RArray<T, [usize; 2]>> for Robj where
T: Into<Robj>,
[src]
T: Into<Robj>,
impl<T> From<RArray<T, [usize; 3]>> for Robj where
T: Into<Robj>,
[src]
T: Into<Robj>,
impl<'a, T> FromRobj<'a> for RArray<&'a [T], [usize; 2]> where
Robj: AsTypedSlice<'a, T>,
[src]
Robj: AsTypedSlice<'a, T>,
impl<T> Index<[usize; 2]> for RArray<T, [usize; 2]> where
T: Index<usize>,
[src]
T: Index<usize>,
type Output = <T as Index<usize>>::Output
The returned type after indexing.
fn index(&self, index: [usize; 2]) -> &Self::Output
[src]
Zero-based indexing in row, column order.
Panics if out of bounds.
use extendr_api::prelude::*; test! { let matrix = RMatrix::new(vec![ 1., 2., 3., 4., 5., 6.], 3, 2); assert_eq!(matrix[[0, 0]], 1.); assert_eq!(matrix[[1, 0]], 2.); assert_eq!(matrix[[2, 1]], 6.); }
impl<T> IndexMut<[usize; 2]> for RArray<T, [usize; 2]> where
T: IndexMut<usize>,
[src]
T: IndexMut<usize>,
fn index_mut(&mut self, index: [usize; 2]) -> &mut Self::Output
[src]
Zero-based mutable indexing in row, column order.
Panics if out of bounds.
use extendr_api::prelude::*; test! { let mut matrix = RMatrix::new(vec![0.; 6], 3, 2); matrix[[0, 0]] = 1.; matrix[[1, 0]] = 2.; matrix[[2, 0]] = 3.; assert_eq!(matrix, RMatrix::new(vec![1., 2., 3., 0., 0., 0.], 3, 2)); }
impl<T: PartialEq, D: PartialEq> PartialEq<RArray<T, D>> for RArray<T, D>
[src]
impl<T, D> StructuralPartialEq for RArray<T, D>
[src]
Auto Trait Implementations
impl<T, D> RefUnwindSafe for RArray<T, D> where
D: RefUnwindSafe,
T: RefUnwindSafe,
[src]
D: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, D> Send for RArray<T, D> where
D: Send,
T: Send,
[src]
D: Send,
T: Send,
impl<T, D> Sync for RArray<T, D> where
D: Sync,
T: Sync,
[src]
D: Sync,
T: Sync,
impl<T, D> Unpin for RArray<T, D> where
D: Unpin,
T: Unpin,
[src]
D: Unpin,
T: Unpin,
impl<T, D> UnwindSafe for RArray<T, D> where
D: UnwindSafe,
T: UnwindSafe,
[src]
D: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,