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>
impl<T: Clone + Default> Array<T>
Sourcepub fn from_vec(data: Vec<T>, shape: Vec<usize>) -> Self
pub fn from_vec(data: Vec<T>, shape: Vec<usize>) -> Self
Create an array from a vector with given shape
Sourcepub fn ones(shape: Vec<usize>) -> Array<f64>
pub fn ones(shape: Vec<usize>) -> Array<f64>
Create an array filled with ones (for numeric types)
Sourcepub fn full(shape: Vec<usize>, fill_value: T) -> Self
pub fn full(shape: Vec<usize>, fill_value: T) -> Self
Create array with given shape and fill value
Sourcepub fn ravel_index(&self, indices: &[usize]) -> usize
pub fn ravel_index(&self, indices: &[usize]) -> usize
Convert multi-dimensional index to flat index
Sourcepub fn get_mut(&mut self, indices: &[usize]) -> Option<&mut T>
pub fn get_mut(&mut self, indices: &[usize]) -> Option<&mut T>
Get mutable element at mutli-dimensional index
Source§impl Array<f64>
impl Array<f64>
Sourcepub fn solve(&self, b: &Array<f64>) -> Option<Array<f64>>
pub fn solve(&self, b: &Array<f64>) -> Option<Array<f64>>
Solve linear system Ax = b using QR decomposition
Sourcepub fn eig(&self) -> Option<(Array<f64>, Array<f64>)>
pub fn eig(&self) -> Option<(Array<f64>, Array<f64>)>
Compute eigenvalues and eigenvectors (2x2 only)
Sourcepub fn svd(&self) -> (Array<f64>, Array<f64>, Array<f64>)
pub fn svd(&self) -> (Array<f64>, Array<f64>, Array<f64>)
Singular Value Decomposition (SVD) - simplified version for 2x2 matrices
Sourcepub fn rank(&self, tolerance: Option<f64>) -> usize
pub fn rank(&self, tolerance: Option<f64>) -> usize
Compute matrix rank (approximate, using SVD)
Sourcepub fn is_symmetric(&self, tolerance: Option<f64>) -> bool
pub fn is_symmetric(&self, tolerance: Option<f64>) -> bool
Check if matrix is symmetric
Sourcepub fn is_orthogonal(&self, tolerance: Option<f64>) -> bool
pub fn is_orthogonal(&self, tolerance: Option<f64>) -> bool
Check if matrix is orthogonal
Source§impl Array<f64>
impl Array<f64>
Sourcepub fn shapes_broadcastable(shape1: &[usize], shape2: &[usize]) -> bool
pub fn shapes_broadcastable(shape1: &[usize], shape2: &[usize]) -> bool
Check if two shapes are broadcastable
Sourcepub fn broadcast_shapes(
shape1: &[usize],
shape2: &[usize],
) -> Option<Vec<usize>>
pub fn broadcast_shapes( shape1: &[usize], shape2: &[usize], ) -> Option<Vec<usize>>
Compute the resulting shape after broadcasting
Sourcepub fn get_broadcasted(&self, indices: &[usize], target_shape: &[usize]) -> &f64
pub fn get_broadcasted(&self, indices: &[usize], target_shape: &[usize]) -> &f64
Get element with broadcasting
Sourcepub fn add_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
pub fn add_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
Element-wise addition with broadcasting
Sourcepub fn sub_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
pub fn sub_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
Element-wise subtraction with broadcasting
Sourcepub fn mul_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
pub fn mul_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
Element-wise multiplication with broadcasting
Sourcepub fn div_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
pub fn div_broadcast(&self, other: &Array<f64>) -> Option<Array<f64>>
Element-wise division with broadcasting
Sourcepub fn unravel_index(flat_index: usize, shape: &[usize]) -> Vec<usize>
pub fn unravel_index(flat_index: usize, shape: &[usize]) -> Vec<usize>
Convert flat index to multi-dimensional index
Sourcepub fn add_scalar(&self, scalar: f64) -> Array<f64>
pub fn add_scalar(&self, scalar: f64) -> Array<f64>
Scalar operations
pub fn sub_scalar(&self, scalar: f64) -> Array<f64>
pub fn mul_scalar(&self, scalar: f64) -> Array<f64>
pub fn div_scalar(&self, scalar: f64) -> Array<f64>
pub fn sum_axis(&self, axis: usize) -> Array<f64>
pub fn mean(&self) -> f64
pub fn mean_axis(&self, axis: usize) -> Array<f64>
pub fn max(&self) -> f64
pub fn min(&self) -> f64
pub fn ln(&self) -> Array<f64>
pub fn sin(&self) -> Array<f64>
pub fn cos(&self) -> Array<f64>
pub fn sqrt(&self) -> Array<f64>
pub fn pow(&self, exponent: f64) -> Array<f64>
Trait Implementations§
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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