#[non_exhaustive]pub enum DynArray {
Show 16 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>),
I256(Array<I256, 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
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
I256(Array<I256, IxDyn>)
I256 elements — 256-bit two’s-complement signed integer,
used as the promoted type for mixed u128 + signed-int
arithmetic (#375, #562).
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
impl DynArray
Sourcepub fn try_into_f64(self) -> FerrayResult<Array<f64, IxDyn>>
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.
Sourcepub fn try_into_f32(self) -> FerrayResult<Array<f32, IxDyn>>
pub fn try_into_f32(self) -> FerrayResult<Array<f32, IxDyn>>
Try to extract the inner Array<f32, IxDyn>.
Sourcepub fn try_into_i64(self) -> FerrayResult<Array<i64, IxDyn>>
pub fn try_into_i64(self) -> FerrayResult<Array<i64, IxDyn>>
Try to extract the inner Array<i64, IxDyn>.
Sourcepub fn try_into_i32(self) -> FerrayResult<Array<i32, IxDyn>>
pub fn try_into_i32(self) -> FerrayResult<Array<i32, IxDyn>>
Try to extract the inner Array<i32, IxDyn>.
Sourcepub fn try_into_bool(self) -> FerrayResult<Array<bool, IxDyn>>
pub fn try_into_bool(self) -> FerrayResult<Array<bool, IxDyn>>
Try to extract the inner Array<bool, IxDyn>.
Sourcepub fn astype(&self, target: DType, casting: CastKind) -> FerrayResult<Self>
pub fn astype(&self, target: DType, casting: CastKind) -> FerrayResult<Self>
Cast this array to a different element dtype at the requested safety level.
Mirrors NumPy’s arr.astype(dtype, casting=...). The conversion routes
through crate::dtype::unsafe_cast::CastTo for the underlying typed
arrays, so it supports the same set of element pairs (every primitive
numeric, bool, and Complex
f16 / bf16 are not yet supported in this dispatch and will return
FerrayError::InvalidDtype — track via the umbrella casting issue.
§Errors
Returns FerrayError::InvalidDtype if:
- The cast is not permitted at the chosen
castinglevel, or - either source or target dtype is
f16/bf16(not yet wired).
Sourcepub fn zeros(dtype: DType, shape: &[usize]) -> FerrayResult<Self>
pub fn zeros(dtype: DType, shape: &[usize]) -> FerrayResult<Self>
Create a DynArray of zeros with the given dtype and shape.