Struct ndarray::Array

source ·
pub struct Array<A, D> { /* private fields */ }
Expand description

The Array type is an N-dimensional array.

A reference counted array with copy-on-write mutability.

The array can be a container of numerical use, supporting all mathematical operators by applying them elementwise – but it can store any kind of value. It cannot grow or shrink, but can be sliced into views of parts of its data.

The array is both a view and a shared owner of its data. Some methods, for example slice(), merely change the view of the data, while methods like iadd() allow mutating the element values.

Calling a method for mutating elements, for example at_mut(), iadd() or iter_mut() will break sharing and require a clone of the data (if it is not uniquely held).

§Method Conventions

Methods mutating the view or array elements in place use an i prefix, for example slice vs. islice and add vs iadd.

§Indexing

Arrays use u32 for indexing, represented by the types Ix and Ixs (signed).

§Broadcasting

Arrays support limited broadcasting, where arithmetic operations with array operands of different sizes can be carried out by repeating the elements of the smaller dimension array. See .broadcast_iter() for a more detailed description.

use ndarray::arr2;

let a = arr2(&[[1., 1.],
               [1., 2.]]);
let b = arr2(&[[0., 1.]]);

let c = arr2(&[[1., 2.],
               [1., 3.]]);
// We can add because the shapes are compatible even if not equal.
assert!(
    c == a + b
);

Implementations§

source§

impl<A> Array<A, Ix>

source

pub fn from_vec(v: Vec<A>) -> Array<A, Ix>

Create a one-dimensional array from a vector (no allocation needed).

source

pub fn from_iter<I: IntoIterator<Item = A>>(iterable: I) -> Array<A, Ix>

Create a one-dimensional array from an iterable.

source§

impl Array<f32, Ix>

source

pub fn range(begin: f32, end: f32) -> Array<f32, Ix>

Create a one-dimensional Array from interval [begin, end)

Examples found in repository?
examples/matmul.rs (line 9)
7
8
9
10
11
12
13
14
15
fn main()
{
    let mat = Array::range(0.0f32, 16.0).reshape((2, 4, 2));
    println!("{a:?}\n times \n{b:?}\nis equal to:\n{c:?}",
             a=mat.subview(2,1),
             b=mat.subview(0,1),
             c=mat.subview(2,1).mat_mul(&mat.subview(0,1)));

}
source§

impl<A, D> Array<A, D>
where D: Dimension,

source

pub fn zeros(dim: D) -> Array<A, D>
where A: Clone + Zero,

Construct an Array with zeros.

source

pub fn default(dim: D) -> Array<A, D>
where A: Default,

Construct an Array with default values, dimension dim.

source

pub fn from_elem(dim: D, elem: A) -> Array<A, D>
where A: Clone,

Construct an Array with copies of elem.

use ndarray::Array;
use ndarray::arr3;

let a = Array::from_elem((2, 2, 2), 1.);

assert!(
    a == arr3(&[[[1., 1.],
                 [1., 1.]],
                [[1., 1.],
                 [1., 1.]]])
);
source

pub unsafe fn from_vec_dim(dim: D, v: Vec<A>) -> Array<A, D>

Create an array from a vector (with no allocation needed).

Unsafe because dimension is unchecked, and must be correct.

source

pub fn len(&self) -> usize

Return the total number of elements in the Array.

source

pub fn dim(&self) -> D

Return the shape of the array.

source

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

Return the shape of the array as a slice.

source

pub fn is_standard_layout(&self) -> bool

Return true if the array data is laid out in contiguous “C order” where the last index is the most rapidly varying.

Return false otherwise, i.e the array is possibly not contiguous in memory, it has custom strides, etc.

source

pub fn raw_data<'a>(&'a self) -> &'a [A]

Return a slice of the array’s backing data in memory order.

Note: Data memory order may not correspond to the index order of the array. Neither is the raw data slice is restricted to just the Array’s view.

source

pub fn slice(&self, indexes: &[Si]) -> Array<A, D>

Return a sliced array.

Panics if indexes does not match the number of array axes.

source

pub fn islice(&mut self, indexes: &[Si])

Slice the array’s view in place.

Panics if indexes does not match the number of array axes.

source

pub fn slice_iter<'a>(&'a self, indexes: &[Si]) -> Elements<'a, A, D>

Return an iterator over a sliced view.

Panics if indexes does not match the number of array axes.

source

pub fn at<'a>(&'a self, index: D) -> Option<&'a A>

Return a reference to the element at index, or return None if the index is out of bounds.

source

pub unsafe fn uchk_at<'a>(&'a self, index: D) -> &'a A

Perform unchecked array indexing.

Return a reference to the element at index.

Note: only unchecked for non-debug builds of ndarray.

source

pub unsafe fn uchk_at_mut(&mut self, index: D) -> &mut A

Perform unchecked array indexing.

Return a mutable reference to the element at index.

Note: Only unchecked for non-debug builds of ndarray.
Note: The array must be uniquely held when mutating it.

source

pub fn iter<'a>(&'a self) -> Elements<'a, A, D>

Return an iterator of references to the elements of the array.

Iterator element type is &’a A.

source

pub fn indexed_iter<'a>(&'a self) -> Indexed<Elements<'a, A, D>>

Return an iterator of references to the elements of the array.

Iterator element type is (D, &’a A).

source

pub fn isubview(&mut self, axis: usize, index: Ix)

Collapse dimension axis into length one, and select the subview of index along that axis.

Panics if index is past the length of the axis.

source

pub fn broadcast_iter<'a, E: Dimension>( &'a self, dim: E, ) -> Option<Elements<'a, A, E>>

Act like a larger size and/or shape array by broadcasting into a larger shape, if possible.

Return None if shapes can not be broadcast together.

§Background
  • Two axes are compatible if they are equal, or one of them is 1.
  • In this instance, only the axes of the smaller side (self) can be 1.

Compare axes beginning with the last axis of each shape.

For example (1, 2, 4) can be broadcast into (7, 6, 2, 4) because its axes are either equal or 1 (or missing); while (2, 2) can not be broadcast into (2, 4).

The implementation creates an iterator with strides set to 0 for the axes that are to be repeated.

See broadcasting documentation for Numpy for more information.

use ndarray::arr1;

assert!(
    arr1(&[1., 0.]).broadcast_iter((10, 2)).unwrap().count()
    == 20
);
source

pub fn swap_axes(&mut self, ax: usize, bx: usize)

Swap axes ax and bx.

Panics if the axes are out of bounds.

use ndarray::arr2;

let mut a = arr2(&[[1., 2., 3.]]);
a.swap_axes(0, 1);
assert!(
    a == arr2(&[[1.], [2.], [3.]])
);
source

pub fn diag_iter<'a>(&'a self) -> Elements<'a, A, Ix>

Return an iterator over the diagonal elements of the array.

The diagonal is simply the sequence indexed by (0, 0, .., 0), (1, 1, …, 1) etc as long as all axes have elements.

source

pub fn diag(&self) -> Array<A, Ix>

Return the diagonal as a one-dimensional array.

source

pub fn map<'a, B, F>(&'a self, f: F) -> Array<B, D>
where F: FnMut(&'a A) -> B,

Apply f elementwise and return a new array with the results.

Return an array with the same shape as self.

use ndarray::arr2;

let a = arr2(&[[1., 2.],
               [3., 4.]]);
assert!(
    a.map(|&x| (x / 2.) as i32)
    == arr2(&[[0, 1], [1, 2]])
);
source

pub fn subview( &self, axis: usize, index: Ix, ) -> Array<A, <D as RemoveAxis>::Smaller>
where D: RemoveAxis,

Select the subview index along axis and return an array with that axis removed.

Panics if index is past the length of the axis.

use ndarray::{arr1, arr2};

let a = arr2(&[[1., 2.],
               [3., 4.]]);

assert!(
    a.subview(0, 0) == arr1(&[1., 2.]) &&
    a.subview(1, 1) == arr1(&[2., 4.])
);
Examples found in repository?
examples/matmul.rs (line 11)
7
8
9
10
11
12
13
14
15
fn main()
{
    let mat = Array::range(0.0f32, 16.0).reshape((2, 4, 2));
    println!("{a:?}\n times \n{b:?}\nis equal to:\n{c:?}",
             a=mat.subview(2,1),
             b=mat.subview(0,1),
             c=mat.subview(2,1).mat_mul(&mat.subview(0,1)));

}
source

pub fn ensure_unique(&mut self)
where A: Clone,

Make the array unshared.

This method is mostly only useful with unsafe code.

source

pub fn at_mut<'a>(&'a mut self, index: D) -> Option<&'a mut A>
where A: Clone,

Return a mutable reference to the element at index, or return None if the index is out of bounds.

source

pub fn iter_mut<'a>(&'a mut self) -> ElementsMut<'a, A, D>
where A: Clone,

Return an iterator of mutable references to the elements of the array.

Iterator element type is &’a mut A.

source

pub fn indexed_iter_mut<'a>(&'a mut self) -> Indexed<ElementsMut<'a, A, D>>
where A: Clone,

Return an iterator of indexes and mutable references to the elements of the array.

Iterator element type is (D, &’a mut A).

source

pub fn slice_iter_mut<'a>(&'a mut self, indexes: &[Si]) -> ElementsMut<'a, A, D>
where A: Clone,

Return an iterator of mutable references into the sliced view of the array.

Iterator element type is &’a mut A.

Panics if indexes does not match the number of array axes.

source

pub fn sub_iter_mut<'a>( &'a mut self, axis: usize, index: Ix, ) -> ElementsMut<'a, A, D>
where A: Clone,

Select the subview index along axis and return an iterator of the subview.

Iterator element type is &’a mut A.

Panics if axis or index is out of bounds.

source

pub fn diag_iter_mut<'a>(&'a mut self) -> ElementsMut<'a, A, Ix>
where A: Clone,

Return an iterator over the diagonal elements of the array.

source

pub fn raw_data_mut<'a>(&'a mut self) -> &'a mut [A]
where A: Clone,

Return a mutable slice of the array’s backing data in memory order.

Note: Data memory order may not correspond to the index order of the array. Neither is the raw data slice is restricted to just the array’s view.

Note: The data is uniquely held and nonaliased while it is mutably borrowed.

source

pub fn reshape<E: Dimension>(&self, shape: E) -> Array<A, E>
where A: Clone,

Transform the array into shape; any other shape with the same number of elements is accepted.

Panics if sizes are incompatible.

use ndarray::{arr1, arr2};

assert!(
    arr1(&[1., 2., 3., 4.]).reshape((2, 2))
    == arr2(&[[1., 2.],
              [3., 4.]])
);
Examples found in repository?
examples/matmul.rs (line 9)
7
8
9
10
11
12
13
14
15
fn main()
{
    let mat = Array::range(0.0f32, 16.0).reshape((2, 4, 2));
    println!("{a:?}\n times \n{b:?}\nis equal to:\n{c:?}",
             a=mat.subview(2,1),
             b=mat.subview(0,1),
             c=mat.subview(2,1).mat_mul(&mat.subview(0,1)));

}
source

pub fn assign<E: Dimension>(&mut self, other: &Array<A, E>)
where A: Clone,

Perform an elementwise assigment to self from other.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn assign_scalar(&mut self, x: &A)
where A: Clone,

Perform an elementwise assigment to self from scalar x.

source§

impl<A, D> Array<A, D>
where A: Clone + Add<Output = A>, D: RemoveAxis,

source

pub fn sum(&self, axis: usize) -> Array<A, <D as RemoveAxis>::Smaller>

Return sum along axis.

use ndarray::{arr0, arr1, arr2};

let a = arr2(&[[1., 2.],
               [3., 4.]]);
assert!(
    a.sum(0) == arr1(&[4., 6.]) &&
    a.sum(1) == arr1(&[3., 7.]) &&

    a.sum(0).sum(0) == arr0(10.)
);

Panics if axis is out of bounds.

source§

impl<A, D> Array<A, D>
where A: Copy + Field, D: RemoveAxis,

source

pub fn mean(&self, axis: usize) -> Array<A, <D as RemoveAxis>::Smaller>

Return mean along axis.

use ndarray::{arr1, arr2};

let a = arr2(&[[1., 2.],
               [3., 4.]]);
assert!(
    a.mean(0) == arr1(&[2.0, 3.0]) &&
    a.mean(1) == arr1(&[1.5, 3.5])
);

Panics if axis is out of bounds.

source§

impl<A> Array<A, (Ix, Ix)>

source

pub fn row_iter<'a>(&'a self, index: Ix) -> Elements<'a, A, Ix>

Return an iterator over the elements of row index.

Panics if index is out of bounds.

source

pub fn col_iter<'a>(&'a self, index: Ix) -> Elements<'a, A, Ix>

Return an iterator over the elements of column index.

Panics if index is out of bounds.

source§

impl<'a, A: Copy + Ring> Array<A, (Ix, Ix)>

source

pub fn mat_mul(&self, other: &Array<A, (Ix, Ix)>) -> Array<A, (Ix, Ix)>

Perform matrix multiplication of rectangular arrays self and other.

The array sizes must agree in the way that if self is M × N, then other is N × K.

Return a result array with shape M × K.

Panics if sizes are incompatible.

use ndarray::arr2;

let a = arr2(&[[1., 2.],
               [0., 1.]]);
let b = arr2(&[[1., 2.],
               [2., 3.]]);

assert!(
    a.mat_mul(&b) == arr2(&[[5., 8.],
                            [2., 3.]])
);
Examples found in repository?
examples/matmul.rs (line 13)
7
8
9
10
11
12
13
14
15
fn main()
{
    let mat = Array::range(0.0f32, 16.0).reshape((2, 4, 2));
    println!("{a:?}\n times \n{b:?}\nis equal to:\n{c:?}",
             a=mat.subview(2,1),
             b=mat.subview(0,1),
             c=mat.subview(2,1).mat_mul(&mat.subview(0,1)));

}
source

pub fn mat_mul_col(&self, other: &Array<A, Ix>) -> Array<A, Ix>

Perform the matrix multiplication of the rectangular array self and column vector other.

The array sizes must agree in the way that if self is M × N, then other is N.

Return a result array with shape M.

Panics if sizes are incompatible.

source§

impl<A: Float + PartialOrd, D: Dimension> Array<A, D>

source

pub fn allclose(&self, other: &Array<A, D>, tol: A) -> bool

Return true if the arrays’ elementwise differences are all within the given absolute tolerance.
Return false otherwise, or if the shapes disagree.

source§

impl<A, D> Array<A, D>
where A: Clone + Add<A, Output = A>, D: Dimension,

source

pub fn iadd<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn iadd_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + Sub<A, Output = A>, D: Dimension,

source

pub fn isub<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn isub_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + Mul<A, Output = A>, D: Dimension,

source

pub fn imul<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn imul_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + Div<A, Output = A>, D: Dimension,

source

pub fn idiv<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn idiv_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + Rem<A, Output = A>, D: Dimension,

source

pub fn irem<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn irem_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + BitAnd<A, Output = A>, D: Dimension,

source

pub fn ibitand<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn ibitand_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + BitOr<A, Output = A>, D: Dimension,

source

pub fn ibitor<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn ibitor_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + BitXor<A, Output = A>, D: Dimension,

source

pub fn ibitxor<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn ibitxor_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + Shl<A, Output = A>, D: Dimension,

source

pub fn ishl<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn ishl_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A, D> Array<A, D>
where A: Clone + Shr<A, Output = A>, D: Dimension,

source

pub fn ishr<E: Dimension>(&mut self, other: &Array<A, E>)

Perform an elementwise arithmetic operation between self and other, in place.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

source

pub fn ishr_scalar(&mut self, x: &A)

Perform an elementwise arithmetic operation between self and the scalar x, in place.

source§

impl<A: Clone + Neg<Output = A>, D: Dimension> Array<A, D>

source

pub fn ineg(&mut self)

Perform an elementwise negation of self, in place.

source§

impl<A: Clone + Not<Output = A>, D: Dimension> Array<A, D>

source

pub fn inot(&mut self)

Perform an elementwise unary not of self, in place.

Trait Implementations§

source§

impl<'a, A, D, E> Add<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Add<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the + operator.
source§

fn add(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the + operation. Read more
source§

impl<'a, A, D, E> Add<Array<A, E>> for Array<A, D>
where A: Clone + Add<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the + operator.
source§

fn add(self, other: Array<A, E>) -> Array<A, D>

Performs the + operation. Read more
source§

impl<'a, A, D, E> BitAnd<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + BitAnd<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the & operator.
source§

fn bitand(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the & operation. Read more
source§

impl<'a, A, D, E> BitAnd<Array<A, E>> for Array<A, D>
where A: Clone + BitAnd<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the & operator.
source§

fn bitand(self, other: Array<A, E>) -> Array<A, D>

Performs the & operation. Read more
source§

impl<'a, A, D, E> BitOr<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + BitOr<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the | operator.
source§

fn bitor(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the | operation. Read more
source§

impl<'a, A, D, E> BitOr<Array<A, E>> for Array<A, D>
where A: Clone + BitOr<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the | operator.
source§

fn bitor(self, other: Array<A, E>) -> Array<A, D>

Performs the | operation. Read more
source§

impl<'a, A, D, E> BitXor<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + BitXor<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the ^ operation. Read more
source§

impl<'a, A, D, E> BitXor<Array<A, E>> for Array<A, D>
where A: Clone + BitXor<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the ^ operator.
source§

fn bitxor(self, other: Array<A, E>) -> Array<A, D>

Performs the ^ operation. Read more
source§

impl<A, D: Clone> Clone for Array<A, D>

source§

fn clone(&self) -> Array<A, D>

Returns a copy 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<'a, A: Debug, D: Dimension> Debug for Array<A, D>

source§

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

Format the array using Debug and apply the formatting parameters used to each element.

The array is shown in multiline style, unless the alternate form is used – i.e. {:#}.

source§

impl<'a, A: Display, D: Dimension> Display for Array<A, D>

source§

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

Format the array using Display and apply the formatting parameters used to each element.

The array is shown in multiline style, unless the alternate form is used – i.e. {:#}.

source§

impl<'a, A, D, E> Div<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Div<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the / operator.
source§

fn div(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the / operation. Read more
source§

impl<'a, A, D, E> Div<Array<A, E>> for Array<A, D>
where A: Clone + Div<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the / operator.
source§

fn div(self, other: Array<A, E>) -> Array<A, D>

Performs the / operation. Read more
source§

impl<A> FromIterator<A> for Array<A, Ix>

source§

fn from_iter<I: IntoIterator<Item = A>>(iterable: I) -> Array<A, Ix>

Creates a value from an iterator. Read more
source§

impl<A: Hash, D: Dimension> Hash for Array<A, D>

source§

fn hash<S: Hasher>(&self, state: &mut S)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<'a, A, D: Dimension> Index<D> for Array<A, D>

source§

fn index(&self, index: D) -> &A

Access the element at index.

Panics if index is out of bounds.

§

type Output = A

The returned type after indexing.
source§

impl<'a, A: Clone, D: Dimension> IndexMut<D> for Array<A, D>

source§

fn index_mut(&mut self, index: D) -> &mut A

Access the element at index mutably.

Panics if index is out of bounds.

source§

impl<'a, A, D> IntoIterator for &'a Array<A, D>
where D: Dimension,

§

type Item = &'a A

The type of the elements being iterated over.
§

type IntoIter = Elements<'a, A, D>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, A, D> IntoIterator for &'a mut Array<A, D>
where A: Clone, D: Dimension,

§

type Item = &'a mut A

The type of the elements being iterated over.
§

type IntoIter = ElementsMut<'a, A, D>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, A: LowerExp, D: Dimension> LowerExp for Array<A, D>

source§

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

Format the array using LowerExp and apply the formatting parameters used to each element.

The array is shown in multiline style, unless the alternate form is used – i.e. {:#e}.

source§

impl<'a, A, D, E> Mul<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Mul<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the * operation. Read more
source§

impl<'a, A, D, E> Mul<Array<A, E>> for Array<A, D>
where A: Clone + Mul<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the * operator.
source§

fn mul(self, other: Array<A, E>) -> Array<A, D>

Performs the * operation. Read more
source§

impl<A: Clone + Neg<Output = A>, D: Dimension> Neg for Array<A, D>

source§

fn neg(self) -> Array<A, D>

Perform an elementwise negation of self and return the result.

§

type Output = Array<A, D>

The resulting type after applying the - operator.
source§

impl<A: Clone + Not<Output = A>, D: Dimension> Not for Array<A, D>

source§

fn not(self) -> Array<A, D>

Perform an elementwise unary not of self and return the result.

§

type Output = Array<A, D>

The resulting type after applying the ! operator.
source§

impl<A: PartialEq, D: Dimension> PartialEq for Array<A, D>

source§

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

Return true if the array shapes and all elements of self and other are equal. Return false otherwise.

1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, A, D, E> Rem<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Rem<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the % operator.
source§

fn rem(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the % operation. Read more
source§

impl<'a, A, D, E> Rem<Array<A, E>> for Array<A, D>
where A: Clone + Rem<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the % operator.
source§

fn rem(self, other: Array<A, E>) -> Array<A, D>

Performs the % operation. Read more
source§

impl<'a, A, D, E> Shl<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Shl<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the << operator.
source§

fn shl(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the << operation. Read more
source§

impl<'a, A, D, E> Shl<Array<A, E>> for Array<A, D>
where A: Clone + Shl<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the << operator.
source§

fn shl(self, other: Array<A, E>) -> Array<A, D>

Performs the << operation. Read more
source§

impl<'a, A, D, E> Shr<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Shr<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the >> operator.
source§

fn shr(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the >> operation. Read more
source§

impl<'a, A, D, E> Shr<Array<A, E>> for Array<A, D>
where A: Clone + Shr<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the >> operator.
source§

fn shr(self, other: Array<A, E>) -> Array<A, D>

Performs the >> operation. Read more
source§

impl<'a, A, D, E> Sub<&'a Array<A, E>> for &'a Array<A, D>
where A: Clone + Sub<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'a Array<A, E>) -> Array<A, D>

Performs the - operation. Read more
source§

impl<'a, A, D, E> Sub<Array<A, E>> for Array<A, D>
where A: Clone + Sub<A, Output = A>, D: Dimension, E: Dimension,

Perform an elementwise arithmetic operation between self and other, and return the result.

If their shapes disagree, other is broadcast to the shape of self.

Panics if broadcasting isn’t possible.

§

type Output = Array<A, D>

The resulting type after applying the - operator.
source§

fn sub(self, other: Array<A, E>) -> Array<A, D>

Performs the - operation. Read more
source§

impl<'a, A: UpperExp, D: Dimension> UpperExp for Array<A, D>

source§

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

Format the array using UpperExp and apply the formatting parameters used to each element.

The array is shown in multiline style, unless the alternate form is used – i.e. {:#E}.

source§

impl<A: Eq, D: Dimension> Eq for Array<A, D>

Auto Trait Implementations§

§

impl<A, D> Freeze for Array<A, D>
where D: Freeze,

§

impl<A, D> RefUnwindSafe for Array<A, D>

§

impl<A, D> !Send for Array<A, D>

§

impl<A, D> !Sync for Array<A, D>

§

impl<A, D> Unpin for Array<A, D>
where D: Unpin,

§

impl<A, D> UnwindSafe for Array<A, D>

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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§

default 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>,

§

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>,

§

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, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,