Skip to main content

Array

Struct Array 

Source
pub struct Array { /* private fields */ }
Expand description

A lazily evaluated n-dimensional array.

Cloning is cheap: clones share the computation and its result. Operations record a graph node and return immediately; values are computed on Array::eval, crate::eval, or when read back.

Implementations§

Source§

impl Array

Source

pub fn from_slice<T: Element>(data: &[T], shape: &[usize]) -> Result<Self>

An array holding data with the given shape.

Fails with Error::SizeMismatch if data.len() is not the shape’s element count.

Source

pub fn full<T: Element>(shape: &[usize], value: T) -> Result<Self>

An array of the given shape with every element set to value.

Source

pub fn scalar<T: Element>(value: T) -> Self

A zero-dimensional array holding value.

Source

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

Dimension sizes.

Source

pub fn ndim(&self) -> usize

Number of dimensions.

Source

pub fn size(&self) -> usize

Number of elements.

Source

pub fn dtype(&self) -> DType

Element type.

Source

pub fn itemsize(&self) -> usize

Size of one element in bytes.

Source

pub fn nbytes(&self) -> usize

Size of all elements in bytes.

Source

pub fn strides(&self) -> &[isize]

Per-dimension steps, in elements.

Source

pub fn flags(&self) -> Flags

Memory-layout flags.

Source

pub fn stream(&self) -> Stream

The stream the producing operation was recorded on.

Source

pub fn device(&self) -> Device

The device the producing operation runs on.

Source

pub fn is_evaluated(&self) -> bool

Whether the array has been evaluated (successfully or not).

Source

pub fn primitive(&self) -> Option<Primitive>

The operation that produces this array, until it has been evaluated. None for host data and evaluated arrays.

Source

pub fn eval(&self) -> Result<()>

Evaluates this array, if it has not been evaluated yet.

Source

pub fn to_vec<T: Element>(&self) -> Result<Vec<T>>

The elements in row-major order, evaluating first if needed.

Source

pub fn item<T: Element>(&self) -> Result<T>

The single element of a one-element array, evaluating first if needed.

Source§

impl Array

Source

pub fn astype(&self, dtype: DType) -> Result<Array>

Converts the elements to dtype; see astype.

Source

pub fn reshape(&self, shape: &[isize]) -> Result<Array>

The same elements in another shape; see reshape.

Source

pub fn t(&self) -> Result<Array>

The array with all axes reversed (the matrix transpose for 2-D arrays).

Trait Implementations§

Source§

impl Add for Array

Source§

type Output = Array

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Array) -> Array

Performs the + operation. Read more
Source§

impl Add<&Array> for &Array

Source§

type Output = Array

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Array) -> Array

Performs the + operation. Read more
Source§

impl Add<&Array> for Array

Source§

type Output = Array

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Array) -> Array

Performs the + operation. Read more
Source§

impl Add<Array> for &Array

Source§

type Output = Array

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Array) -> Array

Performs the + operation. Read more
Source§

impl Clone for Array

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Array

Source§

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

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

impl Div for Array

Source§

type Output = Array

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Array) -> Array

Performs the / operation. Read more
Source§

impl Div<&Array> for &Array

Source§

type Output = Array

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Array) -> Array

Performs the / operation. Read more
Source§

impl Div<&Array> for Array

Source§

type Output = Array

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Array) -> Array

Performs the / operation. Read more
Source§

impl Div<Array> for &Array

Source§

type Output = Array

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Array) -> Array

Performs the / operation. Read more
Source§

impl Mul for Array

Source§

type Output = Array

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Array) -> Array

Performs the * operation. Read more
Source§

impl Mul<&Array> for &Array

Source§

type Output = Array

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Array) -> Array

Performs the * operation. Read more
Source§

impl Mul<&Array> for Array

Source§

type Output = Array

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Array) -> Array

Performs the * operation. Read more
Source§

impl Mul<Array> for &Array

Source§

type Output = Array

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Array) -> Array

Performs the * operation. Read more
Source§

impl Neg for &Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn neg(self) -> Array

Performs the unary - operation. Read more
Source§

impl Neg for Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn neg(self) -> Array

Performs the unary - operation. Read more
Source§

impl Sub for Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Array) -> Array

Performs the - operation. Read more
Source§

impl Sub<&Array> for &Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Array) -> Array

Performs the - operation. Read more
Source§

impl Sub<&Array> for Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Array) -> Array

Performs the - operation. Read more
Source§

impl Sub<Array> for &Array

Source§

type Output = Array

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Array) -> Array

Performs the - operation. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Array

§

impl !UnwindSafe for Array

§

impl Freeze for Array

§

impl Send for Array

§

impl Sync for Array

§

impl Unpin for Array

§

impl UnsafeUnpin for Array

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> AutoreleaseSafe for T
where T: ?Sized,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.