Struct lance_linalg::matrix::MatrixView
source · pub struct MatrixView<T: ArrowFloatType> {
pub transpose: bool,
/* private fields */
}Expand description
A 2-D dense matrix on top of Arrow Arrays.
Fields§
§transpose: boolIs this matrix transposed or not.
Implementations§
source§impl<T: ArrowFloatType> MatrixView<T>
impl<T: ArrowFloatType> MatrixView<T>
sourcepub fn new(
data: Arc<T::ArrayType>,
num_columns: impl AsPrimitive<usize>
) -> Self
pub fn new( data: Arc<T::ArrayType>, num_columns: impl AsPrimitive<usize> ) -> Self
Create a MatrixView from a f32 data.
sourcepub fn random(num_rows: usize, num_columns: usize) -> Self
pub fn random(num_rows: usize, num_columns: usize) -> Self
Randomly initialize a matrix of shape (num_rows, num_columns).
sourcepub fn num_columns(&self) -> usize
pub fn num_columns(&self) -> usize
Number of the columns (dimension) in the matrix.
pub fn data(&self) -> Arc<T::ArrayType>
sourcepub fn row(&self, i: usize) -> Option<&[T::Native]>
pub fn row(&self, i: usize) -> Option<&[T::Native]>
Returns a row at index i. Returns None if the index is out of bound.
Panics if the matrix is transposed.
sourcepub fn centroid(&self) -> Option<T::ArrayType>
pub fn centroid(&self) -> Option<T::ArrayType>
Compute the centroid from all the rows. Returns None if this matrix is empty.
Panics if the matrix is transposed.
sourcepub fn sample_with(&self, n: usize, rng: impl Rng) -> Self
pub fn sample_with(&self, n: usize, rng: impl Rng) -> Self
Sample n rows with a random generator.
pub fn iter(&self) -> MatrixRowIter<'_, T> ⓘ
Trait Implementations§
source§impl<T: ArrowFloatType> Clone for MatrixView<T>
impl<T: ArrowFloatType> Clone for MatrixView<T>
source§impl<T: Debug + ArrowFloatType> Debug for MatrixView<T>
impl<T: Debug + ArrowFloatType> Debug for MatrixView<T>
source§impl<T: ArrowFloatType + ArrowPrimitiveType> TryFrom<&FixedSizeListArray> for MatrixView<T>
impl<T: ArrowFloatType + ArrowPrimitiveType> TryFrom<&FixedSizeListArray> for MatrixView<T>
§type Error = ArrowError
type Error = ArrowError
The type returned in the event of a conversion error.
source§fn try_from(value: &FixedSizeListArray) -> Result<Self>
fn try_from(value: &FixedSizeListArray) -> Result<Self>
Performs the conversion.
Auto Trait Implementations§
impl<T> RefUnwindSafe for MatrixView<T>
impl<T> Send for MatrixView<T>
impl<T> Sync for MatrixView<T>
impl<T> Unpin for MatrixView<T>
impl<T> UnwindSafe for MatrixView<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more