pub struct MatrixView<T: ArrowFloatType> {
    pub transpose: bool,
    /* private fields */
}
Expand description

A 2-D dense matrix on top of Arrow Arrays.

Fields§

§transpose: bool

Is this matrix transposed or not.

Implementations§

source§

impl<T: ArrowFloatType> MatrixView<T>

source

pub fn new( data: Arc<T::ArrayType>, num_columns: impl AsPrimitive<usize> ) -> Self

Create a MatrixView from a f32 data.

source

pub fn random(num_rows: usize, num_columns: usize) -> Self

Randomly initialize a matrix of shape (num_rows, num_columns).

source

pub fn identity(n: usize) -> Self

Create a identity matrix, with number of rows n.

source

pub fn num_rows(&self) -> usize

Number of rows in the matrix

source

pub fn num_columns(&self) -> usize

Number of the columns (dimension) in the matrix.

source

pub fn ndim(&self) -> usize

Number of dimensions.

source

pub fn data(&self) -> Arc<T::ArrayType>

source

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.
source

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.
source

pub fn transpose(&self) -> Self

(Lazy) transpose of the matrix.

source

pub fn normalize(&self) -> Self

source

pub fn sample(&self, n: usize) -> Self

Sample n rows from the matrix.

source

pub fn sample_with(&self, n: usize, rng: impl Rng) -> Self

Sample n rows with a random generator.

source

pub fn iter(&self) -> MatrixRowIter<'_, T>

Trait Implementations§

source§

impl<T: ArrowFloatType> Clone for MatrixView<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T: Debug + ArrowFloatType> Debug for MatrixView<T>
where T::ArrayType: Debug,

source§

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

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

impl<T: ArrowFloatType + ArrowPrimitiveType> TryFrom<&FixedSizeListArray> for MatrixView<T>

§

type Error = ArrowError

The type returned in the event of a conversion error.
source§

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,