Array

Struct Array 

Source
pub struct Array<T> {
    pub data: Vec<T>,
    pub shape: Vec<usize>,
    pub strides: Vec<usize>,
}

Fields§

§data: Vec<T>§shape: Vec<usize>§strides: Vec<usize>

Implementations§

Source§

impl<T: Clone + Default> Array<T>

Source

pub fn from_vec(data: Vec<T>, shape: Vec<usize>) -> Self

Create an array from a vector with given shape

Source

pub fn zeros(shape: Vec<usize>) -> Self

Create an array filled with zeros

Source

pub fn ones(shape: Vec<usize>) -> Array<f64>
where T: Into<f64>,

Create an array filled with ones (for numeric types)

Source

pub fn full(shape: Vec<usize>, fill_value: T) -> Self

Create array with given shape and fill value

Source

pub fn arange(start: T, stop: T, step: T) -> Array<T>
where T: Num + PartialOrd + Copy,

Create array from range

Source

pub fn ravel_index(&self, indices: &[usize]) -> usize

Convert multi-dimensional index to flat index

Source

pub fn get(&self, indices: &[usize]) -> Option<&T>

Get element at multi-dimensional index

Source

pub fn get_mut(&mut self, indices: &[usize]) -> Option<&mut T>

Get mutable element at mutli-dimensional index

Source

pub fn reshape(&self, new_shape: Vec<usize>) -> Array<T>

Reshape array to new shape (must have same total size)

Source

pub fn ndim(&self) -> usize

Get the number of dimensions

Source

pub fn len(&self) -> usize

Get total number of elements

Source

pub fn is_empty(&self) -> bool

Check if array is empty

Source

pub fn size(&self) -> usize

Get array size (total elements)

Source

pub fn transpose(&self) -> Array<T>

Transpose 2D array

Source§

impl Array<f64>

Source

pub fn dot(&self, other: &Array<f64>) -> Array<f64>

Matrix multiplication (dot product)

Source

pub fn det(&self) -> f64

Matrix determinant (2x2 and 3x3 only)

Source

pub fn trace(&self) -> f64

Matrix trace (sum of diagonal elements)

Source

pub fn inv(&self) -> Option<Array<f64>>

Matrix inverse (2x2 only for now)

Source

pub fn qr(&self) -> (Array<f64>, Array<f64>)

QR decomposition (Gram-Schmidt process)

Source

pub fn solve(&self, b: &Array<f64>) -> Option<Array<f64>>

Solve linear system Ax = b using QR decomposition

Source

pub fn eig(&self) -> Option<(Array<f64>, Array<f64>)>

Compute eigenvalues and eigenvectors (2x2 only)

Source

pub fn svd(&self) -> (Array<f64>, Array<f64>, Array<f64>)

Singular Value Decomposition (SVD) - simplified version for 2x2 matrices

Source

pub fn norm(&self) -> f64

Compute matrix norm (Frobenius norm)

Source

pub fn rank(&self, tolerance: Option<f64>) -> usize

Compute matrix rank (approximate, using SVD)

Source

pub fn is_symmetric(&self, tolerance: Option<f64>) -> bool

Check if matrix is symmetric

Source

pub fn is_orthogonal(&self, tolerance: Option<f64>) -> bool

Check if matrix is orthogonal

Source§

impl Array<f64>

Source

pub fn shapes_broadcastable(shape1: &[usize], shape2: &[usize]) -> bool

Check if two shapes are broadcastable

Source

pub fn broadcast_shapes( shape1: &[usize], shape2: &[usize], ) -> Option<Vec<usize>>

Compute the resulting shape after broadcasting

Source

pub fn get_broadcasted(&self, indices: &[usize], target_shape: &[usize]) -> &f64

Get element with broadcasting

Source

pub fn add_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>

Element-wise addition with broadcasting

Source

pub fn sub_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>

Element-wise subtraction with broadcasting

Source

pub fn mul_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>

Element-wise multiplication with broadcasting

Source

pub fn div_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>

Element-wise division with broadcasting

Source

pub fn unravel_index(flat_index: usize, shape: &[usize]) -> Vec<usize>

Convert flat index to multi-dimensional index

Source

pub fn add_scalar(&self, scalar: f64) -> Array<f64>

Scalar operations

Source

pub fn sub_scalar(&self, scalar: f64) -> Array<f64>

Source

pub fn mul_scalar(&self, scalar: f64) -> Array<f64>

Source

pub fn div_scalar(&self, scalar: f64) -> Array<f64>

Source

pub fn sum(&self) -> f64

Reduction operations

Source

pub fn sum_axis(&self, axis: usize) -> Array<f64>

Source

pub fn mean(&self) -> f64

Source

pub fn mean_axis(&self, axis: usize) -> Array<f64>

Source

pub fn max(&self) -> f64

Source

pub fn min(&self) -> f64

Source

pub fn exp(&self) -> Array<f64>

Element-wise mathematical functions

Source

pub fn ln(&self) -> Array<f64>

Source

pub fn sin(&self) -> Array<f64>

Source

pub fn cos(&self) -> Array<f64>

Source

pub fn sqrt(&self) -> Array<f64>

Source

pub fn pow(&self, exponent: f64) -> Array<f64>

Trait Implementations§

Source§

impl Add<f64> for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the + operator.
Source§

fn add(self, scalar: f64) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<T: Clone> Clone for Array<T>

Source§

fn clone(&self) -> Array<T>

Returns a duplicate 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> Debug for Array<T>

Source§

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

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

impl Div<f64> for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the / operator.
Source§

fn div(self, scalar: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Self) -> Self::Output

Performs the / operation. Read more
Source§

impl<T: Clone + Default> Index<&[usize]> for Array<T>

Source§

type Output = T

The returned type after indexing.
Source§

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

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Clone + Default> Index<(usize, usize)> for Array<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: (usize, usize)) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T: Clone + Default> IndexMut<&[usize]> for Array<T>

Source§

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

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<T: Clone + Default> IndexMut<(usize, usize)> for Array<T>

Source§

fn index_mut(&mut self, index: (usize, usize)) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl Mul<f64> for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, scalar: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Self) -> Self::Output

Performs the * operation. Read more
Source§

impl<T: PartialEq> PartialEq for Array<T>

Source§

fn eq(&self, other: &Array<T>) -> 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 Sub<f64> for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, scalar: f64) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for &Array<f64>

Source§

type Output = Array<f64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> StructuralPartialEq for Array<T>

Auto Trait Implementations§

§

impl<T> Freeze for Array<T>

§

impl<T> RefUnwindSafe for Array<T>
where T: RefUnwindSafe,

§

impl<T> Send for Array<T>
where T: Send,

§

impl<T> Sync for Array<T>
where T: Sync,

§

impl<T> Unpin for Array<T>
where T: Unpin,

§

impl<T> UnwindSafe for Array<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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>,

Source§

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>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V

Source§

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