Skip to main content

Array

Struct Array 

Source
pub struct Array {
    pub shape: Vec<usize>,
    pub data: Data,
    /* private fields */
}
Expand description

An array: a logical shape, a flat buffer, and the layout joining them.

data is the buffer as it lies. A reader that indexes it must either honour Array::layout or take Array::to_row_major first; the runtime’s rule is that a value reaching a verb has already been made row-major unless that verb asked for the other one.

Fields§

§shape: Vec<usize>§data: Data

Implementations§

Source§

impl Array

Source

pub fn new(shape: Vec<usize>, data: Data) -> Array

Source

pub fn col_major(shape: Vec<usize>, data: Data) -> Array

An array whose buffer holds its first axis fastest — the columns of a matrix, end to end. Rank 0 and 1 have only one layout and take it.

Source

pub fn with_layout(self, layout: Layout) -> Array

The same buffer read the other way round. The caller is asserting that the buffer really is in layout order for this shape.

Source

pub fn layout(&self) -> Layout

How this array’s buffer is ordered.

Source

pub fn is_row_major(&self) -> bool

Source

pub fn row_major_data(&self) -> &Data

The flat buffer, for a reader that indexes it row-major. Debug builds refuse a buffer that is not in that order, which is what keeps a column-major table from being read as if it were rows.

Source

pub fn to_row_major(&self) -> Array

This array with its elements in row-major order, materialising them once if they are not. Already row-major: a refcount bump.

Source

pub fn scalar_i64(v: i64) -> Array

Source

pub fn scalar_f64(v: f64) -> Array

Source

pub fn scalar_bool(v: bool) -> Array

Source

pub fn from_i64(values: Vec<i64>) -> Array

Source

pub fn from_f64(values: Vec<f64>) -> Array

Source

pub fn from_chars(values: Vec<char>) -> Array

Source

pub fn empty(dtype: DType) -> Array

Source

pub fn boxed(value: Array) -> Array

y as a scalar box (J <).

Source

pub fn box_fill() -> Array

The element that fills a boxed array: J’s a:, a box holding an empty numeric list.

Source

pub fn dtype(&self) -> DType

Source

pub fn rank(&self) -> usize

Source

pub fn count(&self) -> usize

Total number of elements.

Source

pub fn items(&self) -> usize

Number of items (major cells): leading axis length, 1 for a scalar.

Source

pub fn item_size(&self) -> usize

Elements per item.

Source

pub fn cast(&self, to: DType) -> Option<Array>

Widen the elements. A cast reads and writes the buffer as it lies, so the layout comes through untouched.

Source

pub fn cells(&self, frame_rank: usize) -> Vec<Array>

Split into cells: the trailing cell_rank axes form the cell shape, the leading axes form the frame.

Source

pub fn cell_at(&self, frame_rank: usize, index: usize) -> Array

One cell without materialising all of them.

Source

pub fn item(&self, i: usize) -> Array

Item i (major cell along the leading axis).

Source

pub fn as_i64_slice(&self) -> Option<&[i64]>

Source

pub fn as_boxes(&self) -> Option<&[Array]>

The boxed elements, if the array holds boxes.

Source

pub fn as_f64_slice(&self) -> Option<&[f64]>

Source

pub fn as_ext_slice(&self) -> Option<&[Ext]>

The extended integers, if the array holds them.

Source

pub fn as_rat_slice(&self) -> Option<&[Rat]>

The rationals, if the array holds them.

Source

pub fn as_complex_slice(&self) -> Option<&[Cx]>

Source

pub fn to_complex_vec(&self) -> Option<Vec<Cx>>

Numeric contents widened to complex. None for character or boxed data.

Source

pub fn to_f64_vec(&self) -> Option<Vec<f64>>

Numeric contents widened to f64. None for character data.

Source

pub fn to_i64_vec(&self) -> Option<Vec<i64>>

Numeric contents as i64 if exactly representable.

Trait Implementations§

Source§

impl Clone for Array

Source§

fn clone(&self) -> Array

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 PartialEq for Array

Two arrays are equal when they hold the same elements at the same indices, whatever buffer order each of them keeps.

Source§

fn eq(&self, other: &Array) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. 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> 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 = 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<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

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