Skip to main content

DynArray

Enum DynArray 

Source
#[non_exhaustive]
pub enum DynArray {
Show 15 variants Bool(Array<bool, IxDyn>), U8(Array<u8, IxDyn>), U16(Array<u16, IxDyn>), U32(Array<u32, IxDyn>), U64(Array<u64, IxDyn>), U128(Array<u128, IxDyn>), I8(Array<i8, IxDyn>), I16(Array<i16, IxDyn>), I32(Array<i32, IxDyn>), I64(Array<i64, IxDyn>), I128(Array<i128, IxDyn>), F32(Array<f32, IxDyn>), F64(Array<f64, IxDyn>), Complex32(Array<Complex<f32>, IxDyn>), Complex64(Array<Complex<f64>, IxDyn>),
}
Expand description

A runtime-typed array whose element type is determined at runtime.

This is analogous to a Python numpy.ndarray where the dtype is a runtime property. Each variant wraps an Array<T, IxDyn> for the corresponding element type.

Use this when the element type is not known at compile time (e.g., loading from a file, receiving from Python/FFI).

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Bool(Array<bool, IxDyn>)

bool elements

§

U8(Array<u8, IxDyn>)

u8 elements

§

U16(Array<u16, IxDyn>)

u16 elements

§

U32(Array<u32, IxDyn>)

u32 elements

§

U64(Array<u64, IxDyn>)

u64 elements

§

U128(Array<u128, IxDyn>)

u128 elements

§

I8(Array<i8, IxDyn>)

i8 elements

§

I16(Array<i16, IxDyn>)

i16 elements

§

I32(Array<i32, IxDyn>)

i32 elements

§

I64(Array<i64, IxDyn>)

i64 elements

§

I128(Array<i128, IxDyn>)

i128 elements

§

F32(Array<f32, IxDyn>)

f32 elements

§

F64(Array<f64, IxDyn>)

f64 elements

§

Complex32(Array<Complex<f32>, IxDyn>)

Complex<f32> elements

§

Complex64(Array<Complex<f64>, IxDyn>)

Complex<f64> elements

Implementations§

Source§

impl DynArray

Source

pub fn dtype(&self) -> DType

The runtime dtype of the elements in this array.

Source

pub fn shape(&self) -> &[usize]

Shape as a slice.

Source

pub fn ndim(&self) -> usize

Number of dimensions.

Source

pub fn size(&self) -> usize

Total number of elements.

Source

pub fn is_empty(&self) -> bool

Whether the array has zero elements.

Source

pub fn itemsize(&self) -> usize

Size in bytes of one element.

Source

pub fn nbytes(&self) -> usize

Total size in bytes.

Source

pub fn try_into_f64(self) -> FerrayResult<Array<f64, IxDyn>>

Try to extract the inner Array<f64, IxDyn>.

§Errors

Returns FerrayError::InvalidDtype if the dtype is not f64.

Source

pub fn try_into_f32(self) -> FerrayResult<Array<f32, IxDyn>>

Try to extract the inner Array<f32, IxDyn>.

Source

pub fn try_into_i64(self) -> FerrayResult<Array<i64, IxDyn>>

Try to extract the inner Array<i64, IxDyn>.

Source

pub fn try_into_i32(self) -> FerrayResult<Array<i32, IxDyn>>

Try to extract the inner Array<i32, IxDyn>.

Source

pub fn try_into_bool(self) -> FerrayResult<Array<bool, IxDyn>>

Try to extract the inner Array<bool, IxDyn>.

Source

pub fn zeros(dtype: DType, shape: &[usize]) -> FerrayResult<Self>

Create a DynArray of zeros with the given dtype and shape.

Trait Implementations§

Source§

impl Clone for DynArray

Source§

fn clone(&self) -> DynArray

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 Debug for DynArray

Source§

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

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

impl Display for DynArray

Source§

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

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

impl From<Array<Complex<f32>, IxDyn>> for DynArray

Source§

fn from(a: Array<Complex<f32>, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<Complex<f64>, IxDyn>> for DynArray

Source§

fn from(a: Array<Complex<f64>, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<bool, IxDyn>> for DynArray

Source§

fn from(a: Array<bool, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<f32, IxDyn>> for DynArray

Source§

fn from(a: Array<f32, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<f64, IxDyn>> for DynArray

Source§

fn from(a: Array<f64, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<i128, IxDyn>> for DynArray

Source§

fn from(a: Array<i128, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<i16, IxDyn>> for DynArray

Source§

fn from(a: Array<i16, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<i32, IxDyn>> for DynArray

Source§

fn from(a: Array<i32, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<i64, IxDyn>> for DynArray

Source§

fn from(a: Array<i64, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<i8, IxDyn>> for DynArray

Source§

fn from(a: Array<i8, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<u128, IxDyn>> for DynArray

Source§

fn from(a: Array<u128, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<u16, IxDyn>> for DynArray

Source§

fn from(a: Array<u16, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<u32, IxDyn>> for DynArray

Source§

fn from(a: Array<u32, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<u64, IxDyn>> for DynArray

Source§

fn from(a: Array<u64, IxDyn>) -> Self

Converts to this type from the input type.
Source§

impl From<Array<u8, IxDyn>> for DynArray

Source§

fn from(a: Array<u8, IxDyn>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.