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: DataImplementations§
Source§impl Array
impl Array
pub fn new(shape: Vec<usize>, data: Data) -> Array
Sourcepub fn col_major(shape: Vec<usize>, data: Data) -> Array
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.
Sourcepub fn with_layout(self, layout: Layout) -> Array
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.
pub fn is_row_major(&self) -> bool
Sourcepub fn row_major_data(&self) -> &Data
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.
Sourcepub fn to_row_major(&self) -> Array
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.
pub fn scalar_i64(v: i64) -> Array
pub fn scalar_f64(v: f64) -> Array
pub fn scalar_bool(v: bool) -> Array
pub fn from_i64(values: Vec<i64>) -> Array
pub fn from_f64(values: Vec<f64>) -> Array
pub fn from_chars(values: Vec<char>) -> Array
pub fn empty(dtype: DType) -> Array
Sourcepub fn box_fill() -> Array
pub fn box_fill() -> Array
The element that fills a boxed array: J’s a:, a box holding an
empty numeric list.
pub fn dtype(&self) -> DType
pub fn rank(&self) -> usize
Sourcepub fn items(&self) -> usize
pub fn items(&self) -> usize
Number of items (major cells): leading axis length, 1 for a scalar.
Sourcepub fn cast(&self, to: DType) -> Option<Array>
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.
Sourcepub fn cells(&self, frame_rank: usize) -> Vec<Array>
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.
Sourcepub fn cell_at(&self, frame_rank: usize, index: usize) -> Array
pub fn cell_at(&self, frame_rank: usize, index: usize) -> Array
One cell without materialising all of them.
pub fn as_i64_slice(&self) -> Option<&[i64]>
pub fn as_f64_slice(&self) -> Option<&[f64]>
Sourcepub fn as_ext_slice(&self) -> Option<&[Ext]>
pub fn as_ext_slice(&self) -> Option<&[Ext]>
The extended integers, if the array holds them.
Sourcepub fn as_rat_slice(&self) -> Option<&[Rat]>
pub fn as_rat_slice(&self) -> Option<&[Rat]>
The rationals, if the array holds them.
pub fn as_complex_slice(&self) -> Option<&[Cx]>
Sourcepub fn to_complex_vec(&self) -> Option<Vec<Cx>>
pub fn to_complex_vec(&self) -> Option<Vec<Cx>>
Numeric contents widened to complex. None for character or boxed data.
Sourcepub fn to_f64_vec(&self) -> Option<Vec<f64>>
pub fn to_f64_vec(&self) -> Option<Vec<f64>>
Numeric contents widened to f64. None for character data.
Sourcepub fn to_i64_vec(&self) -> Option<Vec<i64>>
pub fn to_i64_vec(&self) -> Option<Vec<i64>>
Numeric contents as i64 if exactly representable.
Trait Implementations§
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> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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