Struct ndarray::ArrayBase
[−]
[src]
pub struct ArrayBase<S, D> where S: Data {
// some fields omitted
}
An N-dimensional array.
The array is a general container of elements. It can be of numerical use too, supporting all mathematical operators by applying them elementwise. It cannot grow or shrink, but can be sliced into views of parts of its data.
The ArrayBase<S, D>
is parameterized by:
S
for the data storageD
for the number of dimensions
Type aliases Array
, OwnedArray
, ArrayView
, and ArrayViewMut
refer
to ArrayBase
with different types for the data storage.
Array
Array<A, D>
is a an array with reference counted data and copy-on-write
mutability.
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
get_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
.
Note that all ArrayBase
variants can change their view (slicing) of the
data freely, even when the data can’t be mutated.
Indexing
Array indexes are represented by the types Ix
and Ixs
(signed). Note: A future version will switch from u32
to usize
.
Slicing
You can use slicing to create a view of a subset of the data in
the array. Slicing methods include .slice()
, .islice()
,
.slice_mut()
.
The dimensionality of the array determines the number of axes, for example
a 2D array has two axes. These are listed in “big endian” order, so that
the greatest dimension is listed first, the lowest dimension with the most
rapidly varying index is the last.
For the 2D array this means that indices are (row, column)
, and the order of
the elements is (0, 0), (0, 1), (0, 2), ... (1, 0), (1, 1), (1, 2) ... etc.
The slicing specification is passed as a function argument as a fixed size
array with elements of type Si
with fields Si(begin, end, stride)
,
where the values are signed integers, and end
is an Option<Ixs>
.
The constant S
is a shorthand for the full range of an axis.
For example, if the array has two axes, the slice argument is passed as
type &[Si; 2]
.
The macro s![]
is however a much more convenient way to
specify the slicing argument, so it will be used in all examples.
// import the s![] macro #[macro_use(s)] extern crate ndarray; use ndarray::arr3; fn main() { // 2 submatrices of 2 rows with 3 elements per row, means a shape of `[2, 2, 3]`. let a = arr3(&[[[ 1, 2, 3], // -- 2 rows \_ [ 4, 5, 6]], // -- / [[ 7, 8, 9], // \_ 2 submatrices [10, 11, 12]]]); // / // 3 columns ..../.../.../ assert_eq!(a.shape(), &[2, 2, 3]); // Let’s create a slice with // // - Both of the submatrices of the greatest dimension: `..` // - Only the first row in each submatrix: `0..1` // - Every element in each row: `..` let b = a.slice(s![.., 0..1, ..]); // without the macro, the explicit argument is `&[S, Si(0, Some(1), 1), S]` let c = arr3(&[[[ 1, 2, 3]], [[ 7, 8, 9]]]); assert_eq!(b, c); assert_eq!(b.shape(), &[2, 1, 3]); // Let’s create a slice with // // - Both submatrices of the greatest dimension: `..` // - The last row in each submatrix: `-1..` // - Row elements in reverse order: `..;-1` let d = a.slice(s![.., -1.., ..;-1]); let e = arr3(&[[[ 6, 5, 4]], [[12, 11, 10]]]); assert_eq!(d, e); }
Subviews
Subview methods allow you to restrict the array view while removing
one axis from the array. Subview methods include .subview()
,
.isubview()
, .subview_mut()
.
Subview takes two arguments: axis
and index
.
use ndarray::{arr3, aview2}; // 3 elements per row, times 2 rows, times 2 means a shape of `[2, 2, 3]`. let a = arr3(&[[[ 1, 2, 3], // \ axis 0, submatrix 0 [ 4, 5, 6]], // / [[ 7, 8, 9], // \ axis 0, submatrix 1 [10, 11, 12]]]); // / // \ // axis 2, column 0 assert_eq!(a.shape(), &[2, 2, 3]); // Let’s take a subview along the greatest dimension (axis 0), // taking submatrix 0, then submatrix 1 let sub_0 = a.subview(0, 0); let sub_1 = a.subview(0, 1); assert_eq!(sub_0, aview2(&[[ 1, 2, 3], [ 4, 5, 6]])); assert_eq!(sub_1, aview2(&[[ 7, 8, 9], [10, 11, 12]])); assert_eq!(sub_0.shape(), &[2, 3]); // This is the subview picking only axis 2, column 0 let sub_col = a.subview(2, 0); assert_eq!(sub_col, aview2(&[[ 1, 4], [ 7, 10]]));
.isubview()
modifies the view in the same way as subview()
, but
since it is in place, it cannot remove the collapsed axis. It becomes
an axis of length 1.
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()
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 );
Methods
impl<S> ArrayBase<S, Ix> where S: DataOwned
[src]
Constructor methods for single dimensional ArrayBase
.
fn from_vec(v: Vec<S::Elem>) -> Self
Create a one-dimensional array from a vector (no allocation needed).
fn from_iter<I: IntoIterator<Item=S::Elem>>(iterable: I) -> ArrayBase<S, Ix>
Create a one-dimensional array from an iterable.
fn linspace<F>(start: F, end: F, n: usize) -> ArrayBase<S, Ix> where S: Data<Elem=F>, F: Float, usize: ToFloat<F>
Create a one-dimensional array from inclusive interval [start, end]
with
n
elements.
fn range(start: f32, end: f32) -> ArrayBase<S, Ix> where S: Data<Elem=f32>
: use ArrayBase::linspace() instead
Create a one-dimensional array from interval [start, end)
impl<S, D> ArrayBase<S, D> where S: DataOwned, D: Dimension
[src]
Constructor methods for ArrayBase
.
unsafe fn from_vec_dim(dim: D, v: Vec<S::Elem>) -> ArrayBase<S, D>
Create an array from a vector (with no allocation needed).
Unsafe because dimension is unchecked, and must be correct.
fn zeros(dim: D) -> ArrayBase<S, D> where S::Elem: Clone + Zero
Construct an Array with zeros.
fn from_elem(dim: D, elem: S::Elem) -> ArrayBase<S, D> where S::Elem: 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.]]]) );
fn default(dim: D) -> ArrayBase<S, D> where S::Elem: Default
Construct an Array with default values, dimension dim
.
impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
[src]
fn len(&self) -> usize
Return the total number of elements in the Array.
fn dim(&self) -> D
Return the shape of the array.
fn shape(&self) -> &[Ix]
Return the shape of the array as a slice.
fn strides(&self) -> &[Ixs]
Return the strides of the array
fn view(&self) -> ArrayView<A, D>
Return a read-only view of the array
fn view_mut(&mut self) -> ArrayViewMut<A, D> where S: DataMut
Return a read-write view of the array
fn to_owned(&self) -> OwnedArray<A, D> where A: Clone
Return an uniquely owned copy of the array
fn to_shared(&self) -> Array<A, D> where A: Clone
Return a shared ownership (copy on write) array.
fn into_shared(self) -> Array<A, D> where S: DataOwned
Turn the array into a shared ownership (copy on write) array, without any copying.
fn iter(&self) -> Elements<A, D>
Return an iterator of references to the elements of the array.
Iterator element type is &A
.
fn indexed_iter(&self) -> Indexed<A, D>
Return an iterator of references to the elements of the array.
Iterator element type is (D, &A)
.
fn iter_mut(&mut self) -> ElementsMut<A, D> where S: DataMut
Return an iterator of mutable references to the elements of the array.
Iterator element type is &mut A
.
fn indexed_iter_mut(&mut self) -> IndexedMut<A, D> where S: DataMut
Return an iterator of indexes and mutable references to the elements of the array.
Iterator element type is (D, &mut A)
.
fn slice(&self, indexes: &D::SliceArg) -> Self where S: DataShared
Return a sliced array.
See Slicing for full documentation.
D::SliceArg
is typically a fixed size array of Si
, with one
element per axis.
Panics if an index is out of bounds or stride is zero.
(Panics if D
is Vec
and indexes
does not match the number of array axes.)
fn islice(&mut self, indexes: &D::SliceArg)
Slice the array’s view in place.
D::SliceArg
is typically a fixed size array of Si
, with one
element per axis.
Panics if an index is out of bounds or stride is zero.
(Panics if D
is Vec
and indexes
does not match the number of array axes.)
fn slice_iter(&self, indexes: &D::SliceArg) -> Elements<A, D>
Return an iterator over a sliced view.
D::SliceArg
is typically a fixed size array of Si
, with one
element per axis.
Panics if an index is out of bounds or stride is zero.
(Panics if D
is Vec
and indexes
does not match the number of array axes.)
fn slice_mut(&mut self, indexes: &D::SliceArg) -> ArrayViewMut<A, D> where S: DataMut
Return a sliced read-write view of the array.
D::SliceArg
is typically a fixed size array of Si
, with one
element per axis.
Panics if an index is out of bounds or stride is zero.
(Panics if D
is Vec
and indexes
does not match the number of array axes.)
fn slice_iter_mut(&mut self, indexes: &D::SliceArg) -> ElementsMut<A, D> where S: DataMut
: use .slice_mut() instead
Deprecated: use .slice_mut()
fn get(&self, index: D) -> Option<&A>
Return a reference to the element at index
, or return None
if the index is out of bounds.
fn at(&self, index: D) -> Option<&A>
: use .get() instead
Deprecated: use .get(i)
fn get_mut(&mut self, index: D) -> Option<&mut A> where S: DataMut
Return a mutable reference to the element at index
, or return None
if the index is out of bounds.
fn at_mut(&mut self, index: D) -> Option<&mut A> where S: DataMut
: use .get_mut() instead
Deprecated: use .get_mut(i)
unsafe fn uget(&self, index: D) -> &A
Perform unchecked array indexing.
Return a reference to the element at index
.
Note: only unchecked for non-debug builds of ndarray.
unsafe fn uchk_at(&self, index: D) -> &A
: use .uget() instead
Deprecated: use .uget()
unsafe fn uget_mut(&mut self, index: D) -> &mut A where S: DataMut
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.
unsafe fn uchk_at_mut(&mut self, index: D) -> &mut A where S: DataMut
: use .uget_mut() instead
Deprecated: use .uget_mut()
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.]]) );
fn subview(&self, axis: usize, index: Ix) -> ArrayBase<S, D::Smaller> where D: RemoveAxis, S: DataShared
Along axis
, select the subview index
and return an
array with that axis removed.
See Subviews for full documentation.
Panics if axis
or index
is out of bounds.
use ndarray::{arr1, arr2}; let a = arr2(&[[1., 2.], // -- axis 0, row 0 [3., 4.], // -- axis 0, row 1 [5., 6.]]); // -- axis 0, row 2 // \ \ // \ axis 1, column 1 // axis 1, column 0 assert!( a.subview(0, 1) == arr1(&[3., 4.]) && a.subview(1, 1) == arr1(&[2., 4., 6.]) );
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.
fn subview_mut(&mut self, axis: usize, index: Ix) -> ArrayViewMut<A, D::Smaller> where S: DataMut, D: RemoveAxis
Along axis
, select the subview index
and return a read-write view
with the axis removed.
Panics if axis
or index
is out of bounds.
use ndarray::{arr2, aview2}; let mut a = arr2(&[[1., 2.], [3., 4.]]); a.subview_mut(1, 1).iadd_scalar(&10.); assert!( a == aview2(&[[1., 12.], [3., 14.]]) );
fn sub_iter_mut(&mut self, axis: usize, index: Ix) -> ElementsMut<A, D> where S: DataMut
: use .subview_mut() instead
Deprecated: use .subview_mut()
fn inner_iter(&self) -> InnerIter<A, D>
Return an iterator that traverses over all dimensions but the innermost, and yields each inner row.
Iterator element is ArrayView<A, Ix>
(1D array view).
use ndarray::arr3; let a = arr3(&[[[ 0, 1, 2], // -- row 0, 0 [ 3, 4, 5]], // -- row 0, 1 [[ 6, 7, 8], // -- row 1, 0 [ 9, 10, 11]]]); // -- row 1, 1 // `inner_iter` yields the four inner rows of the 3D array. let mut row_sums = a.inner_iter().map(|v| v.scalar_sum()); assert_eq!(row_sums.collect::<Vec<_>>(), vec![3, 12, 21, 30]);
fn inner_iter_mut(&mut self) -> InnerIterMut<A, D> where S: DataMut
Return an iterator that traverses over all dimensions but the innermost, and yields each inner row.
Iterator element is ArrayViewView<A, Ix>
(1D read-write array view).
fn diag_iter(&self) -> Elements<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.
fn diag(&self) -> ArrayBase<S, Ix> where S: DataShared
Return the diagonal as a one-dimensional array.
fn diag_mut(&mut self) -> ArrayViewMut<A, Ix> where S: DataMut
Return a read-write view over the diagonal elements of the array.
fn diag_iter_mut(&mut self) -> ElementsMut<A, Ix> where S: DataMut
: use .diag_mut() instead
Deprecated: use .diag_mut()
fn is_standard_layout(&self) -> bool
Return true
if the array data is laid out in contiguous “C order” in
memory (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.
fn as_slice(&self) -> Option<&[A]>
Return the array’s data as a slice, if it is contiguous and
the element order corresponds to the memory order. Return None
otherwise.
fn as_slice_mut(&mut self) -> Option<&mut [A]> where S: DataMut
Return the array’s data as a slice, if it is contiguous and
the element order corresponds to the memory order. Return None
otherwise.
fn reshape<E: Dimension>(&self, shape: E) -> ArrayBase<S, E> where S: DataShared + DataOwned, A: Clone
Transform the array into shape
; any shape with the same number of
elements is accepted.
May clone all elements if needed to arrange elements in standard layout (and break sharing).
Panics if shapes are incompatible.
use ndarray::{arr1, arr2}; assert!( arr1(&[1., 2., 3., 4.]).reshape((2, 2)) == arr2(&[[1., 2.], [3., 4.]]) );
fn into_shape<E>(self, shape: E) -> Result<ArrayBase<S, E>, ShapeError> where E: Dimension
Transform the array into shape
; any shape with the same number of
elements is accepted, but the source array or view must be
contiguous, otherwise we cannot rearrange the dimension.
Errors if the shapes don't have the same number of elements.
Errors if the input array is not c-contiguous (this will be
slightly improved in the future).
use ndarray::{aview1, aview2}; assert!( aview1(&[1., 2., 3., 4.]).into_shape((2, 2)).unwrap() == aview2(&[[1., 2.], [3., 4.]]) );
fn broadcast<E>(&self, dim: E) -> Option<ArrayView<A, E>> where E: Dimension
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 a view with strides set to zero for the axes that are to be repeated.
The broadcasting documentation for Numpy has more information.
use ndarray::arr1; assert!( arr1(&[1., 0.]).broadcast((10, 2)).unwrap().dim() == (10, 2) );
fn broadcast_iter<E>(&self, dim: E) -> Option<Elements<A, E>> where E: Dimension
: use .broadcast() instead
Deprecated: Use .broadcast()
instead.
fn raw_data(&self) -> &[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.
Note: the slice may be empty.
fn raw_data_mut(&mut self) -> &mut [A] where S: DataMut
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 slice may be empty.
Note: The data is uniquely held and nonaliased while it is mutably borrowed.
fn assign<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where S: DataMut, A: Clone, S2: Data<Elem=A>
Perform an elementwise assigment to self
from rhs
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn assign_scalar(&mut self, x: &A) where S: DataMut, A: Clone
Perform an elementwise assigment to self
from scalar x
.
fn zip_mut_with<B, S2, E, F>(&mut self, rhs: &ArrayBase<S2, E>, f: F) where S: DataMut, S2: Data<Elem=B>, E: Dimension, F: FnMut(&mut A, &B)
Traverse two arrays in unspecified order, in lock step,
calling the closure f
on each element pair.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn fold<'a, F, B>(&'a self, init: B, f: F) -> B where F: FnMut(B, &'a A) -> B, A: 'a
Traverse the array elements in order and apply a fold, returning the resulting value.
fn map<'a, B, F>(&'a self, f: F) -> OwnedArray<B, D> where F: FnMut(&'a A) -> B, A: 'a
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]]) );
impl<A, S, D> ArrayBase<S, D> where S: Data<Elem=A>, D: Dimension
[src]
fn sum(&self, axis: usize) -> OwnedArray<A, D::Smaller> where A: Clone + Add<Output=A>, D: RemoveAxis
Return sum along axis
.
use ndarray::{aview0, aview1, arr2}; let a = arr2(&[[1., 2.], [3., 4.]]); assert!( a.sum(0) == aview1(&[4., 6.]) && a.sum(1) == aview1(&[3., 7.]) && a.sum(0).sum(0) == aview0(&10.) );
Panics if axis
is out of bounds.
fn scalar_sum(&self) -> A where A: Clone + Add<Output=A> + Zero
Return the sum of all elements in the array.
use ndarray::arr2; let a = arr2(&[[1., 2.], [3., 4.]]); assert_eq!(a.scalar_sum(), 10.);
fn mean(&self, axis: usize) -> OwnedArray<A, D::Smaller> where A: Copy + Field, D: RemoveAxis
Return mean along axis
.
use ndarray::{aview1, arr2}; let a = arr2(&[[1., 2.], [3., 4.]]); assert!( a.mean(0) == aview1(&[2.0, 3.0]) && a.mean(1) == aview1(&[1.5, 3.5]) );
Panics if axis
is out of bounds.
fn allclose<S2>(&self, rhs: &ArrayBase<S2, D>, tol: A) -> bool where A: Float + PartialOrd, S2: Data<Elem=A>
Return true
if the arrays' elementwise differences are all within
the given absolute tolerance.
Return false
otherwise, or if the shapes disagree.
impl<A, S> ArrayBase<S, (Ix, Ix)> where S: Data<Elem=A>
[src]
fn row_iter(&self, index: Ix) -> Elements<A, Ix>
Return an iterator over the elements of row index
.
Panics if index
is out of bounds.
fn col_iter(&self, index: Ix) -> Elements<A, Ix>
Return an iterator over the elements of column index
.
Panics if index
is out of bounds.
fn mat_mul(&self, rhs: &ArrayBase<S, (Ix, Ix)>) -> Array<A, (Ix, Ix)> where A: Copy + Ring
Perform matrix multiplication of rectangular arrays self
and rhs
.
The array sizes must agree in the way that
if self
is M × N, then rhs
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.]]) );
fn mat_mul_col(&self, rhs: &ArrayBase<S, Ix>) -> Array<A, Ix> where A: Copy + Ring
Perform the matrix multiplication of the rectangular array self
and
column vector rhs
.
The array sizes must agree in the way that
if self
is M × N, then rhs
is N.
Return a result array with shape M.
Panics if sizes are incompatible.
impl<A, S, D> ArrayBase<S, D> where S: DataMut<Elem=A>, D: Dimension
[src]
In-place arithmetic operations.
fn iadd<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Add<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Addition
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn iadd_scalar(&mut self, x: &A) where A: Clone + Add<A, Output=A>
Perform elementwise
Addition
between self
and the scalar x
,
in place.
fn isub<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Sub<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Subtraction
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn isub_scalar(&mut self, x: &A) where A: Clone + Sub<A, Output=A>
Perform elementwise
Subtraction
between self
and the scalar x
,
in place.
fn imul<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Mul<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Multiplication
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn imul_scalar(&mut self, x: &A) where A: Clone + Mul<A, Output=A>
Perform elementwise
Multiplication
between self
and the scalar x
,
in place.
fn idiv<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Div<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Divsion
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn idiv_scalar(&mut self, x: &A) where A: Clone + Div<A, Output=A>
Perform elementwise
Divsion
between self
and the scalar x
,
in place.
fn irem<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Rem<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Remainder
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn irem_scalar(&mut self, x: &A) where A: Clone + Rem<A, Output=A>
Perform elementwise
Remainder
between self
and the scalar x
,
in place.
fn ibitand<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + BitAnd<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Bit and
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn ibitand_scalar(&mut self, x: &A) where A: Clone + BitAnd<A, Output=A>
Perform elementwise
Bit and
between self
and the scalar x
,
in place.
fn ibitor<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + BitOr<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Bit or
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn ibitor_scalar(&mut self, x: &A) where A: Clone + BitOr<A, Output=A>
Perform elementwise
Bit or
between self
and the scalar x
,
in place.
fn ibitxor<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + BitXor<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Bit xor
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn ibitxor_scalar(&mut self, x: &A) where A: Clone + BitXor<A, Output=A>
Perform elementwise
Bit xor
between self
and the scalar x
,
in place.
fn ishl<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Shl<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Left shift
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn ishl_scalar(&mut self, x: &A) where A: Clone + Shl<A, Output=A>
Perform elementwise
Left shift
between self
and the scalar x
,
in place.
fn ishr<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>) where A: Clone + Shr<A, Output=A>, S2: Data<Elem=A>
Perform elementwise
Right shift
between self
and rhs
,
in place.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
fn ishr_scalar(&mut self, x: &A) where A: Clone + Shr<A, Output=A>
Perform elementwise
Right shift
between self
and the scalar x
,
in place.
fn ineg(&mut self) where A: Clone + Neg<Output=A>
Perform an elementwise negation of self
, in place.
fn inot(&mut self) where A: Clone + Not<Output=A>
Perform an elementwise unary not of self
, in place.
Trait Implementations
impl<S, D> Index<D> for ArrayBase<S, D> where D: Dimension, S: Data
[src]
Access the element at index.
Panics if index is out of bounds.
type Output = S::Elem
The returned type after indexing
fn index(&self, index: D) -> &S::Elem
The method for the indexing (Foo[Bar]
) operation
impl<S, D> IndexMut<D> for ArrayBase<S, D> where D: Dimension, S: DataMut
[src]
Access the element at index mutably.
Panics if index is out of bounds.
fn index_mut(&mut self, index: D) -> &mut S::Elem
The method for the indexing (Foo[Bar]
) operation
impl<S, S2, D> PartialEq<ArrayBase<S2, D>> for ArrayBase<S, D> where D: Dimension, S: Data, S2: Data<Elem=S::Elem>, S::Elem: PartialEq
[src]
fn eq(&self, other: &ArrayBase<S2, D>) -> bool
Return true
if the array shapes and all elements of self
and
other
are equal. Return false
otherwise.
fn ne(&self, other: &Rhs) -> bool
1.0.0
This method tests for !=
.
impl<S, D> Eq for ArrayBase<S, D> where D: Dimension, S: Data, S::Elem: Eq
[src]
impl<'a, S, D> IntoIterator for &'a ArrayBase<S, D> where D: Dimension, S: Data
[src]
type Item = &'a S::Elem
The type of the elements being iterated over.
type IntoIter = Elements<'a, S::Elem, D>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, S, D> IntoIterator for &'a mut ArrayBase<S, D> where D: Dimension, S: DataMut
[src]
type Item = &'a mut S::Elem
The type of the elements being iterated over.
type IntoIter = ElementsMut<'a, S::Elem, D>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
Creates an iterator from a value. Read more
impl<'a, S, D> Hash for ArrayBase<S, D> where D: Dimension, S: Data, S::Elem: Hash
[src]
fn hash<H: Hasher>(&self, state: &mut H)
Feeds this value into the state given, updating the hasher as necessary.
fn hash_slice<H>(data: &[Self], state: &mut H) where H: Hasher
1.3.0
Feeds a slice of this type into the state provided.
impl<S, D> Sync for ArrayBase<S, D> where S: Sync + Data, D: Sync
[src]
ArrayBase
is Sync
when the storage type is.
impl<S, D> Send for ArrayBase<S, D> where S: Send + Data, D: Send
[src]
ArrayBase
is Send
when the storage type is.
impl<'a, A: Display, S, D: Dimension> Display for ArrayBase<S, D> where S: Data<Elem=A>
[src]
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. {:#}
.
impl<'a, A: Debug, S, D: Dimension> Debug for ArrayBase<S, D> where S: Data<Elem=A>
[src]
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. {:#}
.
impl<'a, A: LowerExp, S, D: Dimension> LowerExp for ArrayBase<S, D> where S: Data<Elem=A>
[src]
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}
.
impl<'a, A: UpperExp, S, D: Dimension> UpperExp for ArrayBase<S, D> where S: Data<Elem=A>
[src]
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}
.
impl<A, S, S2, D, E> Add<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Add<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Addition
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the +
operator
fn add(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the +
operator
impl<'a, A, S, S2, D, E> Add<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Add<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Addition
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the +
operator
fn add(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the +
operator
impl<A, S, S2, D, E> Sub<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Sub<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Subtraction
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the -
operator
fn sub(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the -
operator
impl<'a, A, S, S2, D, E> Sub<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Sub<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Subtraction
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the -
operator
fn sub(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the -
operator
impl<A, S, S2, D, E> Mul<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Mul<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Multiplication
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the *
operator
fn mul(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the *
operator
impl<'a, A, S, S2, D, E> Mul<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Mul<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Multiplication
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the *
operator
fn mul(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the *
operator
impl<A, S, S2, D, E> Div<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Div<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Divsion
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the /
operator
fn div(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the /
operator
impl<'a, A, S, S2, D, E> Div<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Div<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Divsion
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the /
operator
fn div(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the /
operator
impl<A, S, S2, D, E> Rem<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Rem<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Remainder
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the %
operator
fn rem(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the %
operator
impl<'a, A, S, S2, D, E> Rem<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Rem<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Remainder
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the %
operator
fn rem(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the %
operator
impl<A, S, S2, D, E> BitAnd<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + BitAnd<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Bit and
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the &
operator
fn bitand(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the &
operator
impl<'a, A, S, S2, D, E> BitAnd<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + BitAnd<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Bit and
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the &
operator
fn bitand(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the &
operator
impl<A, S, S2, D, E> BitOr<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + BitOr<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Bit or
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the |
operator
fn bitor(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the |
operator
impl<'a, A, S, S2, D, E> BitOr<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + BitOr<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Bit or
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the |
operator
fn bitor(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the |
operator
impl<A, S, S2, D, E> BitXor<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + BitXor<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Bit xor
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the ^
operator
impl<'a, A, S, S2, D, E> BitXor<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + BitXor<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Bit xor
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the ^
operator
fn bitxor(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the ^
operator
impl<A, S, S2, D, E> Shl<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Shl<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Left shift
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the <<
operator
fn shl(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the <<
operator
impl<'a, A, S, S2, D, E> Shl<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Shl<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Left shift
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the <<
operator
fn shl(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the <<
operator
impl<A, S, S2, D, E> Shr<ArrayBase<S2, E>> for ArrayBase<S, D> where A: Clone + Shr<A, Output=A>, S: DataMut<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Right shift
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = ArrayBase<S, D>
The resulting type after applying the >>
operator
fn shr(self, rhs: ArrayBase<S2, E>) -> ArrayBase<S, D>
The method for the >>
operator
impl<'a, A, S, S2, D, E> Shr<&'a ArrayBase<S2, E>> for &'a ArrayBase<S, D> where A: Clone + Shr<A, Output=A>, S: Data<Elem=A>, S2: Data<Elem=A>, D: Dimension, E: Dimension
[src]
Perform elementwise
Right shift
between self
and rhs
,
and return the result.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
type Output = OwnedArray<A, D>
The resulting type after applying the >>
operator
fn shr(self, rhs: &'a ArrayBase<S2, E>) -> OwnedArray<A, D>
The method for the >>
operator
impl<A, S, D> Neg for ArrayBase<S, D> where A: Clone + Neg<Output=A>, S: DataMut<Elem=A>, D: Dimension
[src]
type Output = Self
The resulting type after applying the -
operator
fn neg(self) -> Self
Perform an elementwise negation of self
and return the result.
impl<A, S, D> Not for ArrayBase<S, D> where A: Clone + Not<Output=A>, S: DataMut<Elem=A>, D: Dimension
[src]
type Output = Self
The resulting type after applying the !
operator
fn not(self) -> Self
Perform an elementwise unary not of self
and return the result.
impl<S: DataClone, D: Clone> Clone for ArrayBase<S, D>
[src]
fn clone(&self) -> ArrayBase<S, D>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more