pub struct ArrayBase<S, D>where
S: Data,{ /* private fields */ }
Expand description
An n-dimensional array.
The array is a general container of elements. It cannot grow or shrink, but can be sliced into subsets of its data. The array supports arithmetic operations by applying them elementwise.
In n-dimensional we include for example 1-dimensional rows or columns, 2-dimensional matrices, and higher dimensional arrays. If the array has n dimensions, then an element is accessed by using that many indices.
The ArrayBase<S, D>
is parameterized by S
for the data container and
D
for the dimensionality.
Type aliases Array
, ArcArray
, ArrayView
, and ArrayViewMut
refer
to ArrayBase
with different types for the data container.
Contents
- Array
- ArcArray
- Array Views
- Indexing and Dimension
- Loops, Producers and Iterators
- Slicing
- Subviews
- Arithmetic Operations
- Broadcasting
- Conversions
- Constructor Methods for Owned Arrays
- Methods For All Array Types
- Methods For 1-D Arrays
- Methods For 2-D Arrays
- Methods for Dynamic-Dimensional Arrays
- Numerical Methods for Arrays
Array
Array
is an owned array that owns the underlying array
elements directly (just like a Vec
) and it is the default way to create and
store n-dimensional data. Array<A, D>
has two type parameters: A
for
the element type, and D
for the dimensionality. A particular
dimensionality’s type alias like Array3<A>
just has the type parameter
A
for element type.
An example:
// Create a three-dimensional f64 array, initialized with zeros
use ndarray::Array3;
let mut temperature = Array3::<f64>::zeros((3, 4, 5));
// Increase the temperature in this location
temperature[[2, 2, 2]] += 0.5;
ArcArray
ArcArray
is an owned array with reference counted
data (shared ownership).
Sharing requires that it uses copy-on-write for mutable operations.
Calling a method for mutating elements on ArcArray
, for example
view_mut()
or get_mut()
,
will break sharing and require a clone of the data (if it is not uniquely held).
Array Views
ArrayView
and ArrayViewMut
are read-only and read-write array views
respectively. They use dimensionality, indexing, and almost all other
methods the same was as the other array types.
Methods for ArrayBase
apply to array views too, when the trait bounds
allow.
Please see the documentation for the respective array view for an overview
of methods specific to array views: ArrayView
, ArrayViewMut
.
A view is created from an array using .view()
, .view_mut()
, using
slicing (.slice()
, .slice_mut()
) or from one of the many iterators
that yield array views.
You can also create an array view from a regular slice of data not
allocated with Array
— see array view methods or their From
impls.
Note that all ArrayBase
variants can change their view (slicing) of the
data freely, even when their data can’t be mutated.
Indexing and Dimension
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.
In a 2D array the index of each element is [row, column]
as seen in this
4 × 3 example:
[[ [0, 0], [0, 1], [0, 2] ], // row 0
[ [1, 0], [1, 1], [1, 2] ], // row 1
[ [2, 0], [2, 1], [2, 2] ], // row 2
[ [3, 0], [3, 1], [3, 2] ]] // row 3
// \ \ \
// column 0 \ column 2
// column 1
The number of axes for an array is fixed by its D
type parameter: Ix1
for a 1D array, Ix2
for a 2D array etc. The dimension type IxDyn
allows
a dynamic number of axes.
A fixed size array ([usize; N]
) of the corresponding dimensionality is
used to index the Array
, making the syntax array[[
i, j, …]]
use ndarray::Array2;
let mut array = Array2::zeros((4, 3));
array[[1, 1]] = 7;
Important traits and types for dimension and indexing:
- A
Dim
value represents a dimensionality or index. - Trait
Dimension
is implemented by all dimensionalities. It defines many operations for dimensions and indices. - Trait
IntoDimension
is used to convert into aDim
value. - Trait
ShapeBuilder
is an extension ofIntoDimension
and is used when constructing an array. A shape describes not just the extent of each axis but also their strides. - Trait
NdIndex
is an extension ofDimension
and is for values that can be used with indexing syntax.
The default memory order of an array is row major order (a.k.a “c” order), where each row is contiguous in memory. A column major (a.k.a. “f” or fortran) memory order array has columns (or, in general, the outermost axis) with contiguous elements.
The logical order of any array’s elements is the row major order
(the rightmost index is varying the fastest).
The iterators .iter(), .iter_mut()
always adhere to this order, for example.
Loops, Producers and Iterators
Using Zip
is the most general way to apply a procedure
across one or several arrays or producers.
NdProducer
is like an iterable but for
multidimensional data. All producers have dimensions and axes, like an
array view, and they can be split and used with parallelization using Zip
.
For example, ArrayView<A, D>
is a producer, it has the same dimensions
as the array view and for each iteration it produces a reference to
the array element (&A
in this case).
Another example, if we have a 10 × 10 array and use .exact_chunks((2, 2))
we get a producer of chunks which has the dimensions 5 × 5 (because
there are 10 / 2 = 5 chunks in either direction). The 5 × 5 chunks producer
can be paired with any other producers of the same dimension with Zip
, for
example 5 × 5 arrays.
.iter()
and .iter_mut()
These are the element iterators of arrays and they produce an element sequence in the logical order of the array, that means that the elements will be visited in the sequence that corresponds to increasing the last index first: 0, …, 0, 0; 0, …, 0, 1; 0, …0, 2 and so on.
.outer_iter()
and .axis_iter()
These iterators produce array views of one smaller dimension.
For example, for a 2D array, .outer_iter()
will produce the 1D rows.
For a 3D array, .outer_iter()
produces 2D subviews.
.axis_iter()
is like outer_iter()
but allows you to pick which
axis to traverse.
The outer_iter
and axis_iter
are one dimensional producers.
.genrows()
, .gencolumns()
and .lanes()
.genrows()
is a producer (and iterable) of all rows in an array.
use ndarray::Array;
// 1. Loop over the rows of a 2D array
let mut a = Array::zeros((10, 10));
for mut row in a.genrows_mut() {
row.fill(1.);
}
// 2. Use Zip to pair each row in 2D `a` with elements in 1D `b`
use ndarray::Zip;
let mut b = Array::zeros(a.rows());
Zip::from(a.genrows())
.and(&mut b)
.apply(|a_row, b_elt| {
*b_elt = a_row[a.cols() - 1] - a_row[0];
});
The lanes of an array are 1D segments along an axis and when pointed along the last axis they are rows, when pointed along the first axis they are columns.
A m × n array has m rows each of length n and conversely n columns each of length m.
To generalize this, we say that an array of dimension a × m × n has a m rows. It’s composed of a times the previous array, so it has a times as many rows.
All methods: .genrows()
, .genrows_mut()
,
.gencolumns()
, .gencolumns_mut()
,
.lanes(axis)
, .lanes_mut(axis)
.
Yes, for 2D arrays .genrows()
and .outer_iter()
have about the same
effect:
genrows()
is a producer with n - 1 dimensions of 1 dimensional itemsouter_iter()
is a producer with 1 dimension of n - 1 dimensional items
Slicing
You can use slicing to create a view of a subset of the data in
the array. Slicing methods include .slice()
, .slice_mut()
,
.slice_move()
, and .slice_collapse()
.
The slicing argument can be passed using the macro s![]
,
which will be used in all examples. (The explicit form is an instance of
&SliceInfo
; see its docs for more information.)
If a range is used, the axis is preserved. If an index is used, that index
is selected and the axis is removed; this selects a subview. See
Subviews for more information about subviews. Note that
.slice_collapse()
behaves like .collapse_axis()
by preserving
the number of dimensions.
// import the s![] macro
#[macro_use(s)]
extern crate ndarray;
use ndarray::{arr2, 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, ..]);
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);
assert_eq!(d.shape(), &[2, 1, 3]);
// Let’s create a slice while selecting a subview with
//
// - Both submatrices of the greatest dimension: `..`
// - The last row in each submatrix, removing that axis: `-1`
// - Row elements in reverse order: `..;-1`
let f = a.slice(s![.., -1, ..;-1]);
let g = arr2(&[[ 6, 5, 4],
[12, 11, 10]]);
assert_eq!(f, g);
assert_eq!(f.shape(), &[2, 3]);
}
Subviews
Subview methods allow you to restrict the array view while removing one
axis from the array. Methods for selecting individual subviews include
.index_axis()
, .index_axis_mut()
, .index_axis_move()
, and
.index_axis_inplace()
. You can also select a subview by using a single
index instead of a range when slicing. Some other methods, such as
.fold_axis()
, .axis_iter()
, .axis_iter_mut()
,
.outer_iter()
, and .outer_iter_mut()
operate on all the subviews
along an axis.
A related method is .collapse_axis()
, which modifies the view in the
same way as .index_axis()
except for removing the collapsed axis, since
it operates in place. The length of the axis becomes 1.
Methods for selecting an individual subview take two arguments: axis
and
index
.
#[macro_use(s)] extern crate ndarray;
use ndarray::{arr3, aview1, aview2, Axis};
// 2 submatrices of 2 rows with 3 elements per row, 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.index_axis(Axis(0), 0);
let sub_1 = a.index_axis(Axis(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.index_axis(Axis(2), 0);
assert_eq!(sub_col, aview2(&[[ 1, 4],
[ 7, 10]]));
// You can take multiple subviews at once (and slice at the same time)
let double_sub = a.slice(s![1, .., 0]);
assert_eq!(double_sub, aview1(&[7, 10]));
Arithmetic Operations
Arrays support all arithmetic operations the same way: they apply elementwise.
Since the trait implementations are hard to overview, here is a summary.
Binary Operators with Two Arrays
Let A
be an array or view of any kind. Let B
be an array
with owned storage (either Array
or ArcArray
).
Let C
be an array with mutable data (either Array
, ArcArray
or ArrayViewMut
).
The following combinations of operands
are supported for an arbitrary binary operator denoted by @
(it can be
+
, -
, *
, /
and so on).
&A @ &A
which produces a newArray
B @ A
which consumesB
, updates it with the result, and returns itB @ &A
which consumesB
, updates it with the result, and returns itC @= &A
which performs an arithmetic operation in place
Binary Operators with Array and Scalar
The trait ScalarOperand
marks types that can be used in arithmetic
with arrays directly. For a scalar K
the following combinations of operands
are supported (scalar can be on either the left or right side, but
ScalarOperand
docs has the detailed condtions).
&A @ K
orK @ &A
which produces a newArray
B @ K
orK @ B
which consumesB
, updates it with the result and returns itC @= K
which performs an arithmetic operation in place
Unary Operators
Let A
be an array or view of any kind. Let B
be an array with owned
storage (either Array
or ArcArray
). The following operands are supported
for an arbitrary unary operator denoted by @
(it can be -
or !
).
@&A
which produces a newArray
@B
which consumesB
, updates it with the result, and returns it
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.],
[0., 3.],
[0., 4.]]);
let b = arr2(&[[0., 1.]]);
let c = arr2(&[[1., 2.],
[1., 3.],
[0., 4.],
[0., 5.]]);
// We can add because the shapes are compatible even if not equal.
// The `b` array is shape 1 × 2 but acts like a 4 × 2 array.
assert!(
c == a + b
);
Conversions
Conversions Between Array Types
This table is a summary of the conversions between arrays of different ownership, dimensionality, and element type. All of the conversions in this table preserve the shape of the array.
Output | Input | |||
---|---|---|---|---|
|
|
|
|
|
|
no-op |
|||
|
no-op |
|||
|
||||
|
illegal |
|||
equivalent with dim |
||||
equivalent with dim |
||||
|
Conversions Between Arrays and Vec
s/Slices/Scalars
This is a table of the safe conversions between arrays and
Vec
s/slices/scalars. Note that some of the return values are actually
Result
/Option
wrappers around the indicated output types.
Input | Output | Methods |
---|---|---|
Vec<A> | ArrayBase<S: DataOwned, Ix1> | ::from_vec() |
Vec<A> | ArrayBase<S: DataOwned, D> | ::from_shape_vec() |
&[A] | ArrayView1<A> | ::from() |
&[A] | ArrayView<A, D> | ::from_shape() |
&mut [A] | ArrayViewMut1<A> | ::from() |
&mut [A] | ArrayViewMut<A, D> | ::from_shape() |
&ArrayBase<S, Ix1> | Vec<A> | .to_vec() |
Array<A, D> | Vec<A> | .into_raw_vec() 1 |
&ArrayBase<S, D> | &[A] | .as_slice() 2, .as_slice_memory_order() 3 |
&mut ArrayBase<S: DataMut, D> | &mut [A] | .as_slice_mut() 2, .as_slice_memory_order_mut() 3 |
ArrayView<A, D> | &[A] | .into_slice() |
ArrayViewMut<A, D> | &mut [A] | .into_slice() |
Array0<A> | A | .into_scalar() |
1Returns the data in memory order.
2Works only if the array is contiguous and in standard order.
3Works only if the array is contiguous.
The table above does not include all the constructors; it only shows
conversions to/from Vec
s/slices. See below for more constructors.
Implementations§
source§impl<S, A> ArrayBase<S, Ix1>where
S: DataOwned<Elem = A>,
impl<S, A> ArrayBase<S, Ix1>where
S: DataOwned<Elem = A>,
Constructor Methods for Owned Arrays
Note that the constructor methods apply to Array
and ArcArray
,
the two array types that have owned storage.
Constructor methods for one-dimensional arrays.
sourcepub fn from_vec(v: Vec<A>) -> Self
pub fn from_vec(v: Vec<A>) -> Self
Create a one-dimensional array from a vector (no copying needed).
Panics if the length is greater than isize::MAX
.
use ndarray::Array;
let array = Array::from_vec(vec![1., 2., 3., 4.]);
sourcepub fn from_iter<I>(iterable: I) -> Selfwhere
I: IntoIterator<Item = A>,
pub fn from_iter<I>(iterable: I) -> Selfwhere
I: IntoIterator<Item = A>,
Create a one-dimensional array from an iterable.
Panics if the length is greater than isize::MAX
.
use ndarray::{Array, arr1};
let array = Array::from_iter((0..5).map(|x| x * x));
assert!(array == arr1(&[0, 1, 4, 9, 16]))
sourcepub fn linspace(start: A, end: A, n: usize) -> Selfwhere
A: Float,
pub fn linspace(start: A, end: A, n: usize) -> Selfwhere
A: Float,
Create a one-dimensional array from the inclusive interval
[start, end]
with n
elements. A
must be a floating point type.
Panics if n
is greater than isize::MAX
.
use ndarray::{Array, arr1};
let array = Array::linspace(0., 1., 5);
assert!(array == arr1(&[0.0, 0.25, 0.5, 0.75, 1.0]))
sourcepub fn range(start: A, end: A, step: A) -> Selfwhere
A: Float,
pub fn range(start: A, end: A, step: A) -> Selfwhere
A: Float,
Create a one-dimensional array from the half-open interval
[start, end)
with elements spaced by step
. A
must be a floating
point type.
Panics if the length is greater than isize::MAX
.
use ndarray::{Array, arr1};
let array = Array::range(0., 5., 1.);
assert!(array == arr1(&[0., 1., 2., 3., 4.]))
source§impl<S, A, D> ArrayBase<S, D>where
S: DataOwned<Elem = A>,
D: Dimension,
impl<S, A, D> ArrayBase<S, D>where
S: DataOwned<Elem = A>,
D: Dimension,
Constructor methods for n-dimensional arrays.
The shape
argument can be an integer or a tuple of integers to specify
a static size. For example 10
makes a length 10 one-dimensional array
(dimension type Ix1
) and (5, 6)
a 5 × 6 array (dimension type Ix2
).
With the trait ShapeBuilder
in scope, there is the method .f()
to select
column major (“f” order) memory layout instead of the default row major.
For example Array::zeros((5, 6).f())
makes a column major 5 × 6 array.
Use IxDyn
for the shape to create an array with dynamic
number of axes.
Finally, the few constructors that take a completely general
Into<StrideShape>
argument optionally support custom strides, for
example a shape given like (10, 2, 2).strides((1, 10, 20))
is valid.
sourcepub fn from_elem<Sh>(shape: Sh, elem: A) -> Selfwhere
A: Clone,
Sh: ShapeBuilder<Dim = D>,
pub fn from_elem<Sh>(shape: Sh, elem: A) -> Selfwhere
A: Clone,
Sh: ShapeBuilder<Dim = D>,
Create an array with copies of elem
, shape shape
.
Panics if the product of non-zero axis lengths overflows isize
.
use ndarray::{Array, arr3, ShapeBuilder};
let a = Array::from_elem((2, 2, 2), 1.);
assert!(
a == arr3(&[[[1., 1.],
[1., 1.]],
[[1., 1.],
[1., 1.]]])
);
assert!(a.strides() == &[4, 2, 1]);
let b = Array::from_elem((2, 2, 2).f(), 1.);
assert!(b.strides() == &[1, 2, 4]);
sourcepub fn zeros<Sh>(shape: Sh) -> Selfwhere
A: Clone + Zero,
Sh: ShapeBuilder<Dim = D>,
pub fn zeros<Sh>(shape: Sh) -> Selfwhere
A: Clone + Zero,
Sh: ShapeBuilder<Dim = D>,
Create an array with zeros, shape shape
.
Panics if the product of non-zero axis lengths overflows isize
.
sourcepub fn ones<Sh>(shape: Sh) -> Selfwhere
A: Clone + One,
Sh: ShapeBuilder<Dim = D>,
pub fn ones<Sh>(shape: Sh) -> Selfwhere
A: Clone + One,
Sh: ShapeBuilder<Dim = D>,
Create an array with ones, shape shape
.
Panics if the product of non-zero axis lengths overflows isize
.
sourcepub fn default<Sh>(shape: Sh) -> Selfwhere
A: Default,
Sh: ShapeBuilder<Dim = D>,
pub fn default<Sh>(shape: Sh) -> Selfwhere
A: Default,
Sh: ShapeBuilder<Dim = D>,
Create an array with default values, shape shape
Panics if the product of non-zero axis lengths overflows isize
.
sourcepub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> Selfwhere
Sh: ShapeBuilder<Dim = D>,
F: FnMut(D::Pattern) -> A,
pub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> Selfwhere
Sh: ShapeBuilder<Dim = D>,
F: FnMut(D::Pattern) -> A,
Create an array with values created by the function f
.
f
is called with the index of the element to create; the elements are
visited in arbitirary order.
Panics if the product of non-zero axis lengths overflows isize
.
sourcepub fn from_shape_vec<Sh>(shape: Sh, v: Vec<A>) -> Result<Self, ShapeError>where
Sh: Into<StrideShape<D>>,
pub fn from_shape_vec<Sh>(shape: Sh, v: Vec<A>) -> Result<Self, ShapeError>where
Sh: Into<StrideShape<D>>,
Create an array with the given shape from a vector. (No cloning of elements needed.)
For a contiguous c- or f-order shape, the following applies:
Errors if shape
does not correspond to the number of elements in
v
or if the shape/strides would result in overflowing isize
.
For custom strides, the following applies:
Errors if strides and dimensions can point out of bounds of v
, if
strides allow multiple indices to point to the same element, or if the
shape/strides would result in overflowing isize
.
use ndarray::Array;
use ndarray::ShapeBuilder; // Needed for .strides() method
use ndarray::arr2;
let a = Array::from_shape_vec((2, 2), vec![1., 2., 3., 4.]);
assert!(a.is_ok());
let b = Array::from_shape_vec((2, 2).strides((1, 2)),
vec![1., 2., 3., 4.]).unwrap();
assert!(
b == arr2(&[[1., 3.],
[2., 4.]])
);
sourcepub unsafe fn from_shape_vec_unchecked<Sh>(shape: Sh, v: Vec<A>) -> Selfwhere
Sh: Into<StrideShape<D>>,
pub unsafe fn from_shape_vec_unchecked<Sh>(shape: Sh, v: Vec<A>) -> Selfwhere
Sh: Into<StrideShape<D>>,
Creates an array from a vector and interpret it according to the provided shape and strides. (No cloning of elements needed.)
The caller must ensure that the following conditions are met:
-
The ndim of
dim
andstrides
must be the same. -
The product of non-zero axis lengths must not exceed
isize::MAX
. -
For axes with length > 1, the stride must be nonnegative.
-
If the array will be empty (any axes are zero-length), the difference between the least address and greatest address accessible by moving along all axes must be ≤
v.len()
.If the array will not be empty, the difference between the least address and greatest address accessible by moving along all axes must be <
v.len()
. -
The strides must not allow any element to be referenced by two different indices.
sourcepub unsafe fn uninitialized<Sh>(shape: Sh) -> Selfwhere
A: Copy,
Sh: ShapeBuilder<Dim = D>,
pub unsafe fn uninitialized<Sh>(shape: Sh) -> Selfwhere
A: Copy,
Sh: ShapeBuilder<Dim = D>,
Create an array with uninitalized elements, shape shape
.
Panics if the number of elements in shape
would overflow isize.
Safety
Accessing uninitalized values is undefined behaviour. You must
overwrite all the elements in the array after it is created; for
example using the methods .fill()
or .assign()
.
The contents of the array is indeterminate before initialization and it
is an error to perform operations that use the previous values. For
example it would not be legal to use a += 1.;
on such an array.
This constructor is limited to elements where A: Copy
(no destructors)
to avoid users shooting themselves too hard in the foot; it is not
a problem to drop an array created with this method even before elements
are initialized. (Note that constructors from_shape_vec
and
from_shape_vec_unchecked
allow the user yet more control).
Examples
#[macro_use(s)]
extern crate ndarray;
use ndarray::Array2;
// Example Task: Let's create a column shifted copy of a in b
fn shift_by_two(a: &Array2<f32>) -> Array2<f32> {
let mut b = unsafe { Array2::uninitialized(a.dim()) };
// two first columns in b are two last in a
// rest of columns in b are the initial columns in a
b.slice_mut(s![.., ..2]).assign(&a.slice(s![.., -2..]));
b.slice_mut(s![.., 2..]).assign(&a.slice(s![.., ..-2]));
// `b` is safe to use with all operations at this point
b
}
source§impl<A, S, D> ArrayBase<S, D>where
S: Data<Elem = A>,
D: Dimension,
impl<A, S, D> ArrayBase<S, D>where
S: Data<Elem = A>,
D: Dimension,
sourcepub fn len_of(&self, axis: Axis) -> usize
pub fn len_of(&self, axis: Axis) -> usize
Return the length of axis
.
The axis should be in the range Axis(
0 .. n )
where n is the
number of dimensions (axes) of the array.
Panics if the axis is out of bounds.
sourcepub fn dim(&self) -> D::Pattern
pub fn dim(&self) -> D::Pattern
Return the shape of the array in its “pattern” form, an integer in the one-dimensional case, tuple in the n-dimensional cases and so on.
sourcepub fn stride_of(&self, axis: Axis) -> isize
pub fn stride_of(&self, axis: Axis) -> isize
Return the stride of axis
.
The axis should be in the range Axis(
0 .. n )
where n is the
number of dimensions (axes) of the array.
Panics if the axis is out of bounds.
sourcepub fn view_mut(&mut self) -> ArrayViewMut<'_, A, D>where
S: DataMut,
pub fn view_mut(&mut self) -> ArrayViewMut<'_, A, D>where
S: DataMut,
Return a read-write view of the array
sourcepub fn to_owned(&self) -> Array<A, D>where
A: Clone,
pub fn to_owned(&self) -> Array<A, D>where
A: Clone,
Return an uniquely owned copy of the array.
If the input array is contiguous and its strides are positive, then the
output array will have the same memory layout. Otherwise, the layout of
the output array is unspecified. If you need a particular layout, you
can allocate a new array with the desired memory layout and
.assign()
the data. Alternatively, you can collect
an iterator, like this for a result in standard layout:
Array::from_shape_vec(arr.raw_dim(), arr.iter().cloned().collect()).unwrap()
or this for a result in column-major (Fortran) layout:
Array::from_shape_vec(arr.raw_dim().f(), arr.t().iter().cloned().collect()).unwrap()
Return a shared ownership (copy on write) array.
sourcepub fn into_owned(self) -> Array<A, D>where
A: Clone,
pub fn into_owned(self) -> Array<A, D>where
A: Clone,
Turn the array into a uniquely owned array, cloning the array elements if necessary.
Turn the array into a shared ownership (copy on write) array, without any copying.
sourcepub fn first(&self) -> Option<&A>
pub fn first(&self) -> Option<&A>
Returns a reference to the first element of the array, or None
if it
is empty.
sourcepub fn first_mut(&mut self) -> Option<&mut A>where
S: DataMut,
pub fn first_mut(&mut self) -> Option<&mut A>where
S: DataMut,
Returns a mutable reference to the first element of the array, or
None
if it is empty.
sourcepub fn iter(&self) -> Iter<'_, A, D> ⓘ
pub fn iter(&self) -> Iter<'_, A, D> ⓘ
Return an iterator of references to the elements of the array.
Elements are visited in the logical order of the array, which is where the rightmost index is varying the fastest.
Iterator element type is &A
.
sourcepub fn iter_mut(&mut self) -> IterMut<'_, A, D> ⓘwhere
S: DataMut,
pub fn iter_mut(&mut self) -> IterMut<'_, A, D> ⓘwhere
S: DataMut,
Return an iterator of mutable references to the elements of the array.
Elements are visited in the logical order of the array, which is where the rightmost index is varying the fastest.
Iterator element type is &mut A
.
sourcepub fn indexed_iter(&self) -> IndexedIter<'_, A, D> ⓘ
pub fn indexed_iter(&self) -> IndexedIter<'_, A, D> ⓘ
Return an iterator of indexes and references to the elements of the array.
Elements are visited in the logical order of the array, which is where the rightmost index is varying the fastest.
Iterator element type is (D::Pattern, &A)
.
See also Zip::indexed
sourcepub fn indexed_iter_mut(&mut self) -> IndexedIterMut<'_, A, D> ⓘwhere
S: DataMut,
pub fn indexed_iter_mut(&mut self) -> IndexedIterMut<'_, A, D> ⓘwhere
S: DataMut,
Return an iterator of indexes and mutable references to the elements of the array.
Elements are visited in the logical order of the array, which is where the rightmost index is varying the fastest.
Iterator element type is (D::Pattern, &mut A)
.
sourcepub fn slice<Do>(
&self,
info: &SliceInfo<D::SliceArg, Do>
) -> ArrayView<'_, A, Do>where
Do: Dimension,
pub fn slice<Do>(
&self,
info: &SliceInfo<D::SliceArg, Do>
) -> ArrayView<'_, A, Do>where
Do: Dimension,
Return a sliced view of the array.
See Slicing for full documentation.
See also SliceInfo
and D::SliceArg
.
Panics if an index is out of bounds or step size is zero.
(Panics if D
is IxDyn
and info
does not match the number of array axes.)
sourcepub fn slice_mut<Do>(
&mut self,
info: &SliceInfo<D::SliceArg, Do>
) -> ArrayViewMut<'_, A, Do>where
Do: Dimension,
S: DataMut,
pub fn slice_mut<Do>(
&mut self,
info: &SliceInfo<D::SliceArg, Do>
) -> ArrayViewMut<'_, A, Do>where
Do: Dimension,
S: DataMut,
Return a sliced read-write view of the array.
See Slicing for full documentation.
See also SliceInfo
and D::SliceArg
.
Panics if an index is out of bounds or step size is zero.
(Panics if D
is IxDyn
and info
does not match the number of array axes.)
sourcepub fn slice_move<Do>(
self,
info: &SliceInfo<D::SliceArg, Do>
) -> ArrayBase<S, Do>where
Do: Dimension,
pub fn slice_move<Do>(
self,
info: &SliceInfo<D::SliceArg, Do>
) -> ArrayBase<S, Do>where
Do: Dimension,
Slice the array, possibly changing the number of dimensions.
See Slicing for full documentation.
See also SliceInfo
and D::SliceArg
.
Panics if an index is out of bounds or step size is zero.
(Panics if D
is IxDyn
and info
does not match the number of array axes.)
sourcepub fn slice_collapse(&mut self, indices: &D::SliceArg)
pub fn slice_collapse(&mut self, indices: &D::SliceArg)
Slice the array in place without changing the number of dimensions.
Note that &SliceInfo
(produced by the
s![]
macro) will usually coerce into &D::SliceArg
automatically, but in some cases (e.g. if D
is IxDyn
), you may need
to call .as_ref()
.
See Slicing for full documentation.
See also D::SliceArg
.
Panics if an index is out of bounds or step size is zero.
(Panics if D
is IxDyn
and indices
does not match the number of array axes.)
sourcepub fn slice_inplace(&mut self, indices: &D::SliceArg)
👎Deprecated since 0.12.1: renamed to slice_collapse
pub fn slice_inplace(&mut self, indices: &D::SliceArg)
slice_collapse
Slice the array in place without changing the number of dimensions.
Panics if an index is out of bounds or step size is zero.
(Panics if D
is IxDyn
and indices
does not match the number of array axes.)
sourcepub fn slice_axis(&self, axis: Axis, indices: Slice) -> ArrayView<'_, A, D>
pub fn slice_axis(&self, axis: Axis, indices: Slice) -> ArrayView<'_, A, D>
Return a view of the array, sliced along the specified axis.
Panics if an index is out of bounds or step size is zero.
Panics if axis
is out of bounds.
sourcepub fn slice_axis_mut(
&mut self,
axis: Axis,
indices: Slice
) -> ArrayViewMut<'_, A, D>where
S: DataMut,
pub fn slice_axis_mut(
&mut self,
axis: Axis,
indices: Slice
) -> ArrayViewMut<'_, A, D>where
S: DataMut,
Return a mutable view of the array, sliced along the specified axis.
Panics if an index is out of bounds or step size is zero.
Panics if axis
is out of bounds.
sourcepub fn slice_axis_inplace(&mut self, axis: Axis, indices: Slice)
pub fn slice_axis_inplace(&mut self, axis: Axis, indices: Slice)
Slice the array in place along the specified axis.
Panics if an index is out of bounds or step size is zero.
Panics if axis
is out of bounds.
sourcepub fn get<I>(&self, index: I) -> Option<&A>where
I: NdIndex<D>,
pub fn get<I>(&self, index: I) -> Option<&A>where
I: NdIndex<D>,
Return a reference to the element at index
, or return None
if the index is out of bounds.
Arrays also support indexing syntax: array[index]
.
use ndarray::arr2;
let a = arr2(&[[1., 2.],
[3., 4.]]);
assert!(
a.get((0, 1)) == Some(&2.) &&
a.get((0, 2)) == None &&
a[(0, 1)] == 2. &&
a[[0, 1]] == 2.
);
sourcepub fn get_mut<I>(&mut self, index: I) -> Option<&mut A>where
S: DataMut,
I: NdIndex<D>,
pub fn get_mut<I>(&mut self, index: I) -> Option<&mut A>where
S: DataMut,
I: NdIndex<D>,
Return a mutable reference to the element at index
, or return None
if the index is out of bounds.
sourcepub unsafe fn uget<I>(&self, index: I) -> &Awhere
I: NdIndex<D>,
pub unsafe fn uget<I>(&self, index: I) -> &Awhere
I: NdIndex<D>,
Perform unchecked array indexing.
Return a reference to the element at index
.
Note: only unchecked for non-debug builds of ndarray.
sourcepub unsafe fn uget_mut<I>(&mut self, index: I) -> &mut Awhere
S: DataMut,
I: NdIndex<D>,
pub unsafe fn uget_mut<I>(&mut self, index: I) -> &mut Awhere
S: DataMut,
I: NdIndex<D>,
Perform unchecked array indexing.
Return a mutable reference to the element at index
.
Note: Only unchecked for non-debug builds of ndarray.
Note: (For ArcArray
) The array must be uniquely held when mutating it.
sourcepub fn swap<I>(&mut self, index1: I, index2: I)where
S: DataMut,
I: NdIndex<D>,
pub fn swap<I>(&mut self, index1: I, index2: I)where
S: DataMut,
I: NdIndex<D>,
Swap elements at indices index1
and index2
.
Indices may be equal.
Panics if an index is out of bounds.
sourcepub unsafe fn uswap<I>(&mut self, index1: I, index2: I)where
S: DataMut,
I: NdIndex<D>,
pub unsafe fn uswap<I>(&mut self, index1: I, index2: I)where
S: DataMut,
I: NdIndex<D>,
Swap elements unchecked at indices index1
and index2
.
Indices may be equal.
Note: only unchecked for non-debug builds of ndarray.
Note: (For ArcArray
) The array must be uniquely held.
sourcepub fn index_axis(&self, axis: Axis, index: usize) -> ArrayView<'_, A, D::Smaller>where
D: RemoveAxis,
pub fn index_axis(&self, axis: Axis, index: usize) -> ArrayView<'_, A, D::Smaller>where
D: RemoveAxis,
Returns a view restricted to index
along the axis, with the axis
removed.
See Subviews for full documentation.
Panics if axis
or index
is out of bounds.
use ndarray::{arr2, ArrayView, Axis};
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.index_axis(Axis(0), 1) == ArrayView::from(&[3., 4.]) &&
a.index_axis(Axis(1), 1) == ArrayView::from(&[2., 4., 6.])
);
sourcepub fn index_axis_mut(
&mut self,
axis: Axis,
index: usize
) -> ArrayViewMut<'_, A, D::Smaller>where
S: DataMut,
D: RemoveAxis,
pub fn index_axis_mut(
&mut self,
axis: Axis,
index: usize
) -> ArrayViewMut<'_, A, D::Smaller>where
S: DataMut,
D: RemoveAxis,
Returns a mutable view restricted to index
along the axis, with the
axis removed.
Panics if axis
or index
is out of bounds.
use ndarray::{arr2, aview2, Axis};
let mut a = arr2(&[[1., 2. ],
[3., 4. ]]);
// . \
// . axis 1, column 1
// axis 1, column 0
{
let mut column1 = a.index_axis_mut(Axis(1), 1);
column1 += 10.;
}
assert!(
a == aview2(&[[1., 12.],
[3., 14.]])
);
sourcepub fn index_axis_move(self, axis: Axis, index: usize) -> ArrayBase<S, D::Smaller>where
D: RemoveAxis,
pub fn index_axis_move(self, axis: Axis, index: usize) -> ArrayBase<S, D::Smaller>where
D: RemoveAxis,
Collapses the array to index
along the axis and removes the axis.
See .index_axis()
and Subviews for full documentation.
Panics if axis
or index
is out of bounds.
sourcepub fn collapse_axis(&mut self, axis: Axis, index: usize)
pub fn collapse_axis(&mut self, axis: Axis, index: usize)
Selects index
along the axis, collapsing the axis into length one.
Panics if axis
or index
is out of bounds.
sourcepub fn subview(&self, axis: Axis, index: Ix) -> ArrayView<'_, A, D::Smaller>where
D: RemoveAxis,
👎Deprecated since 0.12.1: renamed to index_axis
pub fn subview(&self, axis: Axis, index: Ix) -> ArrayView<'_, A, D::Smaller>where
D: RemoveAxis,
index_axis
Along axis
, select the subview index
and return a
view with that axis removed.
Panics if axis
or index
is out of bounds.
sourcepub fn subview_mut(
&mut self,
axis: Axis,
index: Ix
) -> ArrayViewMut<'_, A, D::Smaller>where
S: DataMut,
D: RemoveAxis,
👎Deprecated since 0.12.1: renamed to index_axis_mut
pub fn subview_mut(
&mut self,
axis: Axis,
index: Ix
) -> ArrayViewMut<'_, A, D::Smaller>where
S: DataMut,
D: RemoveAxis,
index_axis_mut
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.
sourcepub fn subview_inplace(&mut self, axis: Axis, index: Ix)
👎Deprecated since 0.12.1: renamed to collapse_axis
pub fn subview_inplace(&mut self, axis: Axis, index: Ix)
collapse_axis
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.
sourcepub fn into_subview(self, axis: Axis, index: Ix) -> ArrayBase<S, D::Smaller>where
D: RemoveAxis,
👎Deprecated since 0.12.1: renamed to index_axis_move
pub fn into_subview(self, axis: Axis, index: Ix) -> ArrayBase<S, D::Smaller>where
D: RemoveAxis,
index_axis_move
Along axis
, select the subview index
and return self
with that axis removed.
sourcepub fn select(&self, axis: Axis, indices: &[Ix]) -> Array<A, D>where
A: Copy,
D: RemoveAxis,
pub fn select(&self, axis: Axis, indices: &[Ix]) -> Array<A, D>where
A: Copy,
D: RemoveAxis,
Along axis
, select arbitrary subviews corresponding to indices
and and copy them into a new array.
Panics if axis
or an element of indices
is out of bounds.
use ndarray::{arr2, Axis};
let x = arr2(&[[0., 1.],
[2., 3.],
[4., 5.],
[6., 7.],
[8., 9.]]);
let r = x.select(Axis(0), &[0, 4, 3]);
assert!(
r == arr2(&[[0., 1.],
[8., 9.],
[6., 7.]])
);
sourcepub fn genrows(&self) -> Lanes<'_, A, D::Smaller>
pub fn genrows(&self) -> Lanes<'_, A, D::Smaller>
Return a producer and iterable that traverses over the generalized rows of the array. For a 2D array these are the regular rows.
This is equivalent to .lanes(Axis(n - 1))
where n is self.ndim()
.
For an array of dimensions a × b × c × … × l × m it has a × b × c × … × l rows each of length m.
For example, in a 2 × 2 × 3 array, each row is 3 elements long and there are 2 × 2 = 4 rows in total.
Iterator element is ArrayView1<A>
(1D array view).
use ndarray::{arr3, Axis, arr1};
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
// `genrows` will yield the four generalized rows of the array.
for row in a.genrows() {
/* loop body */
}
sourcepub fn genrows_mut(&mut self) -> LanesMut<'_, A, D::Smaller>where
S: DataMut,
pub fn genrows_mut(&mut self) -> LanesMut<'_, A, D::Smaller>where
S: DataMut,
Return a producer and iterable that traverses over the generalized rows of the array and yields mutable array views.
Iterator element is ArrayView1<A>
(1D read-write array view).
sourcepub fn gencolumns(&self) -> Lanes<'_, A, D::Smaller>
pub fn gencolumns(&self) -> Lanes<'_, A, D::Smaller>
Return a producer and iterable that traverses over the generalized columns of the array. For a 2D array these are the regular columns.
This is equivalent to .lanes(Axis(0))
.
For an array of dimensions a × b × c × … × l × m it has b × c × … × l × m columns each of length a.
For example, in a 2 × 2 × 3 array, each column is 2 elements long and there are 2 × 3 = 6 columns in total.
Iterator element is ArrayView1<A>
(1D array view).
use ndarray::{arr3, Axis, arr1};
// The generalized columns of a 3D array:
// are directed along the 0th axis: 0 and 6, 1 and 7 and so on...
let a = arr3(&[[[ 0, 1, 2], [ 3, 4, 5]],
[[ 6, 7, 8], [ 9, 10, 11]]]);
// Here `gencolumns` will yield the six generalized columns of the array.
for row in a.gencolumns() {
/* loop body */
}
sourcepub fn gencolumns_mut(&mut self) -> LanesMut<'_, A, D::Smaller>where
S: DataMut,
pub fn gencolumns_mut(&mut self) -> LanesMut<'_, A, D::Smaller>where
S: DataMut,
Return a producer and iterable that traverses over the generalized columns of the array and yields mutable array views.
Iterator element is ArrayView1<A>
(1D read-write array view).
sourcepub fn lanes(&self, axis: Axis) -> Lanes<'_, A, D::Smaller>
pub fn lanes(&self, axis: Axis) -> Lanes<'_, A, D::Smaller>
Return a producer and iterable that traverses over all 1D lanes
pointing in the direction of axis
.
When the pointing in the direction of the first axis, they are columns, in the direction of the last axis rows; in general they are all lanes and are one dimensional.
Iterator element is ArrayView1<A>
(1D array view).
use ndarray::{arr3, aview1, Axis};
let a = arr3(&[[[ 0, 1, 2],
[ 3, 4, 5]],
[[ 6, 7, 8],
[ 9, 10, 11]]]);
let inner0 = a.lanes(Axis(0));
let inner1 = a.lanes(Axis(1));
let inner2 = a.lanes(Axis(2));
// The first lane for axis 0 is [0, 6]
assert_eq!(inner0.into_iter().next().unwrap(), aview1(&[0, 6]));
// The first lane for axis 1 is [0, 3]
assert_eq!(inner1.into_iter().next().unwrap(), aview1(&[0, 3]));
// The first lane for axis 2 is [0, 1, 2]
assert_eq!(inner2.into_iter().next().unwrap(), aview1(&[0, 1, 2]));
sourcepub fn lanes_mut(&mut self, axis: Axis) -> LanesMut<'_, A, D::Smaller>where
S: DataMut,
pub fn lanes_mut(&mut self, axis: Axis) -> LanesMut<'_, A, D::Smaller>where
S: DataMut,
Return a producer and iterable that traverses over all 1D lanes
pointing in the direction of axis
.
Iterator element is ArrayViewMut1<A>
(1D read-write array view).
sourcepub fn outer_iter(&self) -> AxisIter<'_, A, D::Smaller> ⓘwhere
D: RemoveAxis,
pub fn outer_iter(&self) -> AxisIter<'_, A, D::Smaller> ⓘwhere
D: RemoveAxis,
Return an iterator that traverses over the outermost dimension and yields each subview.
This is equivalent to .axis_iter(Axis(0))
.
Iterator element is ArrayView<A, D::Smaller>
(read-only array view).
sourcepub fn outer_iter_mut(&mut self) -> AxisIterMut<'_, A, D::Smaller> ⓘwhere
S: DataMut,
D: RemoveAxis,
pub fn outer_iter_mut(&mut self) -> AxisIterMut<'_, A, D::Smaller> ⓘwhere
S: DataMut,
D: RemoveAxis,
Return an iterator that traverses over the outermost dimension and yields each subview.
This is equivalent to .axis_iter_mut(Axis(0))
.
Iterator element is ArrayViewMut<A, D::Smaller>
(read-write array view).
sourcepub fn axis_iter(&self, axis: Axis) -> AxisIter<'_, A, D::Smaller> ⓘwhere
D: RemoveAxis,
pub fn axis_iter(&self, axis: Axis) -> AxisIter<'_, A, D::Smaller> ⓘwhere
D: RemoveAxis,
Return an iterator that traverses over axis
and yields each subview along it.
For example, in a 3 × 4 × 5 array, with axis
equal to Axis(2)
,
the iterator element
is a 3 × 4 subview (and there are 5 in total), as shown
in the picture below.
Iterator element is ArrayView<A, D::Smaller>
(read-only array view).
See Subviews for full documentation.
Panics if axis
is out of bounds.
sourcepub fn axis_iter_mut(&mut self, axis: Axis) -> AxisIterMut<'_, A, D::Smaller> ⓘwhere
S: DataMut,
D: RemoveAxis,
pub fn axis_iter_mut(&mut self, axis: Axis) -> AxisIterMut<'_, A, D::Smaller> ⓘwhere
S: DataMut,
D: RemoveAxis,
Return an iterator that traverses over axis
and yields each mutable subview along it.
Iterator element is ArrayViewMut<A, D::Smaller>
(read-write array view).
Panics if axis
is out of bounds.
sourcepub fn axis_chunks_iter(
&self,
axis: Axis,
size: usize
) -> AxisChunksIter<'_, A, D> ⓘ
pub fn axis_chunks_iter(
&self,
axis: Axis,
size: usize
) -> AxisChunksIter<'_, A, D> ⓘ
Return an iterator that traverses over axis
by chunks of size
,
yielding non-overlapping views along that axis.
Iterator element is ArrayView<A, D>
The last view may have less elements if size
does not divide
the axis’ dimension.
Panics if axis
is out of bounds.
use ndarray::Array;
use ndarray::{arr3, Axis};
let a = Array::from_iter(0..28).into_shape((2, 7, 2)).unwrap();
let mut iter = a.axis_chunks_iter(Axis(1), 2);
// first iteration yields a 2 × 2 × 2 view
assert_eq!(iter.next().unwrap(),
arr3(&[[[ 0, 1], [ 2, 3]],
[[14, 15], [16, 17]]]));
// however the last element is a 2 × 1 × 2 view since 7 % 2 == 1
assert_eq!(iter.next_back().unwrap(), arr3(&[[[12, 13]],
[[26, 27]]]));
sourcepub fn axis_chunks_iter_mut(
&mut self,
axis: Axis,
size: usize
) -> AxisChunksIterMut<'_, A, D> ⓘwhere
S: DataMut,
pub fn axis_chunks_iter_mut(
&mut self,
axis: Axis,
size: usize
) -> AxisChunksIterMut<'_, A, D> ⓘwhere
S: DataMut,
Return an iterator that traverses over axis
by chunks of size
,
yielding non-overlapping read-write views along that axis.
Iterator element is ArrayViewMut<A, D>
Panics if axis
is out of bounds.
sourcepub fn exact_chunks<E>(&self, chunk_size: E) -> ExactChunks<'_, A, D>where
E: IntoDimension<Dim = D>,
pub fn exact_chunks<E>(&self, chunk_size: E) -> ExactChunks<'_, A, D>where
E: IntoDimension<Dim = D>,
Return an exact chunks producer (and iterable).
It produces the whole chunks of a given n-dimensional chunk size, skipping the remainder along each dimension that doesn’t fit evenly.
The produced element is a ArrayView<A, D>
with exactly the dimension
chunk_size
.
Panics if any dimension of chunk_size
is zero
(Panics if D
is IxDyn
and chunk_size
does not match the
number of array axes.)
sourcepub fn exact_chunks_mut<E>(&mut self, chunk_size: E) -> ExactChunksMut<'_, A, D>where
E: IntoDimension<Dim = D>,
S: DataMut,
pub fn exact_chunks_mut<E>(&mut self, chunk_size: E) -> ExactChunksMut<'_, A, D>where
E: IntoDimension<Dim = D>,
S: DataMut,
Return an exact chunks producer (and iterable).
It produces the whole chunks of a given n-dimensional chunk size, skipping the remainder along each dimension that doesn’t fit evenly.
The produced element is a ArrayViewMut<A, D>
with exactly
the dimension chunk_size
.
Panics if any dimension of chunk_size
is zero
(Panics if D
is IxDyn
and chunk_size
does not match the
number of array axes.)
use ndarray::Array;
use ndarray::arr2;
let mut a = Array::zeros((6, 7));
// Fill each 2 × 2 chunk with the index of where it appeared in iteration
for (i, mut chunk) in a.exact_chunks_mut((2, 2)).into_iter().enumerate() {
chunk.fill(i);
}
// The resulting array is:
assert_eq!(
a,
arr2(&[[0, 0, 1, 1, 2, 2, 0],
[0, 0, 1, 1, 2, 2, 0],
[3, 3, 4, 4, 5, 5, 0],
[3, 3, 4, 4, 5, 5, 0],
[6, 6, 7, 7, 8, 8, 0],
[6, 6, 7, 7, 8, 8, 0]]));
sourcepub fn windows<E>(&self, window_size: E) -> Windows<'_, A, D>where
E: IntoDimension<Dim = D>,
pub fn windows<E>(&self, window_size: E) -> Windows<'_, A, D>where
E: IntoDimension<Dim = D>,
Return a window producer and iterable.
The windows are all distinct overlapping views of size window_size
that fit into the array’s shape.
Will yield over no elements if window size is larger than the actual array size of any dimension.
The produced element is an ArrayView<A, D>
with exactly the dimension
window_size
.
Panics if any dimension of window_size
is zero.
(Panics if D
is IxDyn
and window_size
does not match the
number of array axes.)
sourcepub fn diag(&self) -> ArrayView1<'_, A>
pub fn diag(&self) -> ArrayView1<'_, A>
Return an view of 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.
sourcepub fn diag_mut(&mut self) -> ArrayViewMut1<'_, A>where
S: DataMut,
pub fn diag_mut(&mut self) -> ArrayViewMut1<'_, A>where
S: DataMut,
Return a read-write view over the diagonal elements of the array.
sourcepub fn is_standard_layout(&self) -> bool
pub 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.
sourcepub fn as_ptr(&self) -> *const A
pub fn as_ptr(&self) -> *const A
Return a pointer to the first element in the array.
Raw access to array elements needs to follow the strided indexing scheme: an element at multi-index I in an array with strides S is located at offset
Σ0 ≤ k < d Ik × Sk
where d is self.ndim()
.
sourcepub fn as_mut_ptr(&mut self) -> *mut Awhere
S: DataMut,
pub fn as_mut_ptr(&mut self) -> *mut Awhere
S: DataMut,
Return a mutable pointer to the first element in the array.
sourcepub fn as_slice(&self) -> Option<&[A]>
pub fn as_slice(&self) -> Option<&[A]>
Return the array’s data as a slice, if it is contiguous and in standard order.
Return None
otherwise.
If this function returns Some(_)
, then the element order in the slice
corresponds to the logical order of the array’s elements.
sourcepub fn as_slice_mut(&mut self) -> Option<&mut [A]>where
S: DataMut,
pub 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 in standard order.
Return None
otherwise.
sourcepub fn as_slice_memory_order(&self) -> Option<&[A]>
pub fn as_slice_memory_order(&self) -> Option<&[A]>
Return the array’s data as a slice if it is contiguous,
return None
otherwise.
If this function returns Some(_)
, then the elements in the slice
have whatever order the elements have in memory.
Implementation notes: Does not yet support negatively strided arrays.
sourcepub fn as_slice_memory_order_mut(&mut self) -> Option<&mut [A]>where
S: DataMut,
pub fn as_slice_memory_order_mut(&mut self) -> Option<&mut [A]>where
S: DataMut,
Return the array’s data as a slice if it is contiguous,
return None
otherwise.
sourcepub fn into_shape<E>(self, shape: E) -> Result<ArrayBase<S, E::Dim>, ShapeError>where
E: IntoDimension,
pub fn into_shape<E>(self, shape: E) -> Result<ArrayBase<S, E::Dim>, ShapeError>where
E: IntoDimension,
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- or f-contiguous.
use ndarray::{aview1, aview2};
assert!(
aview1(&[1., 2., 3., 4.]).into_shape((2, 2)).unwrap()
== aview2(&[[1., 2.],
[3., 4.]])
);
sourcepub fn reshape<E>(&self, shape: E) -> ArrayBase<S, E::Dim>where
S: DataShared + DataOwned,
A: Clone,
E: IntoDimension,
pub fn reshape<E>(&self, shape: E) -> ArrayBase<S, E::Dim>where
S: DataShared + DataOwned,
A: Clone,
E: IntoDimension,
Note: Reshape is for ArcArray
only. Use .into_shape()
for
other arrays and array views.
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::{rcarr1, rcarr2};
assert!(
rcarr1(&[1., 2., 3., 4.]).reshape((2, 2))
== rcarr2(&[[1., 2.],
[3., 4.]])
);
sourcepub fn into_dyn(self) -> ArrayBase<S, IxDyn>
pub fn into_dyn(self) -> ArrayBase<S, IxDyn>
Convert any array or array view to a dynamic dimensional array or array view (respectively).
use ndarray::{arr2, ArrayD};
let array: ArrayD<i32> = arr2(&[[1, 2],
[3, 4]]).into_dyn();
sourcepub fn into_dimensionality<D2>(self) -> Result<ArrayBase<S, D2>, ShapeError>where
D2: Dimension,
pub fn into_dimensionality<D2>(self) -> Result<ArrayBase<S, D2>, ShapeError>where
D2: Dimension,
Convert an array or array view to another with the same type, but different dimensionality type. Errors if the dimensions don’t agree.
use ndarray::{ArrayD, Ix2, IxDyn};
// Create a dynamic dimensionality array and convert it to an Array2
// (Ix2 dimension type).
let array = ArrayD::<f64>::zeros(IxDyn(&[10, 10]));
assert!(array.into_dimensionality::<Ix2>().is_ok());
sourcepub fn broadcast<E>(&self, dim: E) -> Option<ArrayView<'_, A, E::Dim>>where
E: IntoDimension,
pub fn broadcast<E>(&self, dim: E) -> Option<ArrayView<'_, A, E::Dim>>where
E: IntoDimension,
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::{aview1, aview2};
assert!(
aview1(&[1., 0.]).broadcast((10, 2)).unwrap()
== aview2(&[[1., 0.]; 10])
);
sourcepub fn swap_axes(&mut self, ax: usize, bx: usize)
pub fn swap_axes(&mut self, ax: usize, bx: usize)
Swap axes ax
and bx
.
This does not move any data, it just adjusts the array’s dimensions and strides.
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.]])
);
sourcepub fn permuted_axes<T>(self, axes: T) -> ArrayBase<S, D>where
T: IntoDimension<Dim = D>,
pub fn permuted_axes<T>(self, axes: T) -> ArrayBase<S, D>where
T: IntoDimension<Dim = D>,
Permute the axes.
This does not move any data, it just adjusts the array’s dimensions and strides.
i in the j-th place in the axes sequence means self
’s i-th axis
becomes self.permuted_axes()
’s j-th axis
Panics if any of the axes are out of bounds, if an axis is missing, or if an axis is repeated more than once.
Examples
use ndarray::{arr2, Array3};
let a = arr2(&[[0, 1], [2, 3]]);
assert_eq!(a.view().permuted_axes([1, 0]), a.t());
let b = Array3::<u8>::zeros((1, 2, 3));
assert_eq!(b.permuted_axes([1, 0, 2]).shape(), &[2, 1, 3]);
sourcepub fn reversed_axes(self) -> ArrayBase<S, D>
pub fn reversed_axes(self) -> ArrayBase<S, D>
Transpose the array by reversing axes.
Transposition reverses the order of the axes (dimensions and strides) while retaining the same data.
sourcepub fn t(&self) -> ArrayView<'_, A, D>
pub fn t(&self) -> ArrayView<'_, A, D>
Return a transposed view of the array.
This is a shorthand for self.view().reversed_axes()
.
See also the more general methods .reversed_axes()
and .swap_axes()
.
sourcepub fn axes(&self) -> Axes<'_, D> ⓘ
pub fn axes(&self) -> Axes<'_, D> ⓘ
Return an iterator over the length and stride of each axis.
sourcepub fn max_stride_axis(&self) -> Axis
pub fn max_stride_axis(&self) -> Axis
Return the axis with the greatest stride (by absolute value), preferring axes with len > 1.
sourcepub fn invert_axis(&mut self, axis: Axis)
pub fn invert_axis(&mut self, axis: Axis)
Reverse the stride of axis
.
Panics if the axis is out of bounds.
sourcepub fn merge_axes(&mut self, take: Axis, into: Axis) -> bool
pub fn merge_axes(&mut self, take: Axis, into: Axis) -> bool
If possible, merge in the axis take
to into
.
Returns true
iff the axes are now merged.
This method merges the axes if movement along the two original axes
(moving fastest along the into
axis) can be equivalently represented
as movement along one (merged) axis. Merging the axes preserves this
order in the merged axis. If take
and into
are the same axis, then
the axis is “merged” if its length is ≤ 1.
If the return value is true
, then the following hold:
-
The new length of the
into
axis is the product of the original lengths of the two axes. -
The new length of the
take
axis is 0 if the product of the original lengths of the two axes is 0, and 1 otherwise.
If the return value is false
, then merging is not possible, and the
original shape and strides have been preserved.
Note that the ordering constraint means that if it’s possible to merge
take
into into
, it’s usually not possible to merge into
into
take
, and vice versa.
use ndarray::Array3;
use ndarray::Axis;
let mut a = Array3::<f64>::zeros((2, 3, 4));
assert!(a.merge_axes(Axis(1), Axis(2)));
assert_eq!(a.shape(), &[2, 1, 12]);
Panics if an axis is out of bounds.
sourcepub fn insert_axis(self, axis: Axis) -> ArrayBase<S, D::Larger>
pub fn insert_axis(self, axis: Axis) -> ArrayBase<S, D::Larger>
Insert new array axis at axis
and return the result.
use ndarray::{Array3, Axis, arr1, arr2};
// Convert a 1-D array into a row vector (2-D).
let a = arr1(&[1, 2, 3]);
let row = a.insert_axis(Axis(0));
assert_eq!(row, arr2(&[[1, 2, 3]]));
// Convert a 1-D array into a column vector (2-D).
let b = arr1(&[1, 2, 3]);
let col = b.insert_axis(Axis(1));
assert_eq!(col, arr2(&[[1], [2], [3]]));
// The new axis always has length 1.
let b = Array3::<f64>::zeros((3, 4, 5));
assert_eq!(b.insert_axis(Axis(2)).shape(), &[3, 4, 1, 5]);
Panics if the axis is out of bounds.
sourcepub fn remove_axis(self, axis: Axis) -> ArrayBase<S, D::Smaller>where
D: RemoveAxis,
👎Deprecated since 0.12.1: use .index_axis_move(Axis(_), 0)
instead
pub fn remove_axis(self, axis: Axis) -> ArrayBase<S, D::Smaller>where
D: RemoveAxis,
.index_axis_move(Axis(_), 0)
insteadRemove array axis axis
and return the result.
Panics if the axis is out of bounds or its length is zero.
sourcepub fn assign<E: Dimension, S2>(&mut self, rhs: &ArrayBase<S2, E>)where
S: DataMut,
A: Clone,
S2: Data<Elem = A>,
pub 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.
sourcepub fn fill(&mut self, x: A)where
S: DataMut,
A: Clone,
pub fn fill(&mut self, x: A)where
S: DataMut,
A: Clone,
Perform an elementwise assigment to self
from element x
.
sourcepub 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),
pub 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.
sourcepub fn fold<'a, F, B>(&'a self, init: B, f: F) -> Bwhere
F: FnMut(B, &'a A) -> B,
A: 'a,
pub fn fold<'a, F, B>(&'a self, init: B, f: F) -> Bwhere
F: FnMut(B, &'a A) -> B,
A: 'a,
Traverse the array elements and apply a fold, returning the resulting value.
Elements are visited in arbitrary order.
sourcepub fn map<'a, B, F>(&'a self, f: F) -> Array<B, D>where
F: FnMut(&'a A) -> B,
A: 'a,
pub fn map<'a, B, F>(&'a self, f: F) -> Array<B, D>where
F: FnMut(&'a A) -> B,
A: 'a,
Call f
by reference on each element and create a new array
with the new values.
Elements are visited in arbitrary order.
Return an array with the same shape as self
.
use ndarray::arr2;
let a = arr2(&[[ 0., 1.],
[-1., 2.]]);
assert!(
a.map(|x| *x >= 1.0)
== arr2(&[[false, true],
[false, true]])
);
sourcepub fn map_mut<'a, B, F>(&'a mut self, f: F) -> Array<B, D>where
F: FnMut(&'a mut A) -> B,
A: 'a,
S: DataMut,
pub fn map_mut<'a, B, F>(&'a mut self, f: F) -> Array<B, D>where
F: FnMut(&'a mut A) -> B,
A: 'a,
S: DataMut,
Call f
on a mutable reference of each element and create a new array
with the new values.
Elements are visited in arbitrary order.
Return an array with the same shape as self
.
sourcepub fn mapv<B, F>(&self, f: F) -> Array<B, D>where
F: FnMut(A) -> B,
A: Clone,
pub fn mapv<B, F>(&self, f: F) -> Array<B, D>where
F: FnMut(A) -> B,
A: Clone,
Call f
by value on each element and create a new array
with the new values.
Elements are visited in arbitrary order.
Return an array with the same shape as self
.
use ndarray::arr2;
let a = arr2(&[[ 0., 1.],
[-1., 2.]]);
assert!(
a.mapv(f32::abs) == arr2(&[[0., 1.],
[1., 2.]])
);
sourcepub fn mapv_into<F>(self, f: F) -> Selfwhere
S: DataMut,
F: FnMut(A) -> A,
A: Clone,
pub fn mapv_into<F>(self, f: F) -> Selfwhere
S: DataMut,
F: FnMut(A) -> A,
A: Clone,
Call f
by value on each element, update the array with the new values
and return it.
Elements are visited in arbitrary order.
sourcepub fn map_inplace<F>(&mut self, f: F)where
S: DataMut,
F: FnMut(&mut A),
pub fn map_inplace<F>(&mut self, f: F)where
S: DataMut,
F: FnMut(&mut A),
Modify the array in place by calling f
by mutable reference on each element.
Elements are visited in arbitrary order.
sourcepub fn mapv_inplace<F>(&mut self, f: F)where
S: DataMut,
F: FnMut(A) -> A,
A: Clone,
pub fn mapv_inplace<F>(&mut self, f: F)where
S: DataMut,
F: FnMut(A) -> A,
A: Clone,
Modify the array in place by calling f
by value on each element.
The array is updated with the new values.
Elements are visited in arbitrary order.
use ndarray::arr2;
let mut a = arr2(&[[ 0., 1.],
[-1., 2.]]);
a.mapv_inplace(f32::exp);
assert!(
a.all_close(&arr2(&[[1.00000, 2.71828],
[0.36788, 7.38906]]), 1e-5)
);
sourcepub fn visit<'a, F>(&'a self, f: F)where
F: FnMut(&'a A),
A: 'a,
pub fn visit<'a, F>(&'a self, f: F)where
F: FnMut(&'a A),
A: 'a,
Visit each element in the array by calling f
by reference
on each element.
Elements are visited in arbitrary order.
sourcepub fn fold_axis<B, F>(&self, axis: Axis, init: B, fold: F) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(&B, &A) -> B,
B: Clone,
pub fn fold_axis<B, F>(&self, axis: Axis, init: B, fold: F) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(&B, &A) -> B,
B: Clone,
Fold along an axis.
Combine the elements of each subview with the previous using the fold
function and initial value init
.
Return the result as an Array
.
Panics if axis
is out of bounds.
sourcepub fn map_axis<'a, B, F>(
&'a self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(ArrayView1<'a, A>) -> B,
A: 'a,
pub fn map_axis<'a, B, F>(
&'a self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(ArrayView1<'a, A>) -> B,
A: 'a,
Reduce the values along an axis into just one value, producing a new array with one less dimension.
Elements are visited in arbitrary order.
Return the result as an Array
.
Panics if axis
is out of bounds.
sourcepub fn map_axis_mut<'a, B, F>(
&'a mut self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(ArrayViewMut1<'a, A>) -> B,
A: 'a,
S: DataMut,
pub fn map_axis_mut<'a, B, F>(
&'a mut self,
axis: Axis,
mapping: F
) -> Array<B, D::Smaller>where
D: RemoveAxis,
F: FnMut(ArrayViewMut1<'a, A>) -> B,
A: 'a,
S: DataMut,
Reduce the values along an axis into just one value, producing a new array with one less dimension. 1-dimensional lanes are passed as mutable references to the reducer, allowing for side-effects.
Elements are visited in arbitrary order.
Return the result as an Array
.
Panics if axis
is out of bounds.
source§impl<A> ArrayBase<OwnedRepr<A>, D>
impl<A> ArrayBase<OwnedRepr<A>, D>
Methods specific to Array0
.
See also all methods for ArrayBase
sourcepub fn into_scalar(self) -> A
pub fn into_scalar(self) -> A
Returns the single element in the array without cloning it.
use ndarray::{arr0, Array0};
// `Foo` doesn't implement `Clone`.
#[derive(Debug, Eq, PartialEq)]
struct Foo;
let array: Array0<Foo> = arr0(Foo);
let scalar: Foo = array.into_scalar();
assert_eq!(scalar, Foo);
source§impl<A, D> ArrayBase<OwnedRepr<A>, D>where
D: Dimension,
impl<A, D> ArrayBase<OwnedRepr<A>, D>where
D: Dimension,
Methods specific to Array
.
See also all methods for ArrayBase
sourcepub fn into_raw_vec(self) -> Vec<A>
pub fn into_raw_vec(self) -> Vec<A>
Return a vector of the elements in the array, in the way they are stored internally.
If the array is in standard memory layout, the logical element order
of the array (.iter()
order) and of the returned vector will be the same.
source§impl<A, S> ArrayBase<S, Ix2>where
S: Data<Elem = A>,
impl<A, S> ArrayBase<S, Ix2>where
S: Data<Elem = A>,
sourcepub fn row(&self, index: Ix) -> ArrayView1<'_, A>
pub fn row(&self, index: Ix) -> ArrayView1<'_, A>
Return an array view of row index
.
Panics if index
is out of bounds.
sourcepub fn row_mut(&mut self, index: Ix) -> ArrayViewMut1<'_, A>where
S: DataMut,
pub fn row_mut(&mut self, index: Ix) -> ArrayViewMut1<'_, A>where
S: DataMut,
Return a mutable array view of row index
.
Panics if index
is out of bounds.
sourcepub fn rows(&self) -> usize
pub fn rows(&self) -> usize
Return the number of rows (length of Axis(0)
) in the two-dimensional array.
sourcepub fn column(&self, index: Ix) -> ArrayView1<'_, A>
pub fn column(&self, index: Ix) -> ArrayView1<'_, A>
Return an array view of column index
.
Panics if index
is out of bounds.
sourcepub fn column_mut(&mut self, index: Ix) -> ArrayViewMut1<'_, A>where
S: DataMut,
pub fn column_mut(&mut self, index: Ix) -> ArrayViewMut1<'_, A>where
S: DataMut,
Return a mutable array view of column index
.
Panics if index
is out of bounds.
source§impl<A, S> ArrayBase<S, IxDyn>where
S: Data<Elem = A>,
impl<A, S> ArrayBase<S, IxDyn>where
S: Data<Elem = A>,
sourcepub fn insert_axis_inplace(&mut self, axis: Axis)
pub fn insert_axis_inplace(&mut self, axis: Axis)
Insert new array axis of length 1 at axis
, modifying the shape and
strides in-place.
Panics if the axis is out of bounds.
use ndarray::{Axis, arr2, arr3};
let mut a = arr2(&[[1, 2, 3], [4, 5, 6]]).into_dyn();
assert_eq!(a.shape(), &[2, 3]);
a.insert_axis_inplace(Axis(1));
assert_eq!(a, arr3(&[[[1, 2, 3]], [[4, 5, 6]]]).into_dyn());
assert_eq!(a.shape(), &[2, 1, 3]);
sourcepub fn index_axis_inplace(&mut self, axis: Axis, index: usize)
pub fn index_axis_inplace(&mut self, axis: Axis, index: usize)
Collapses the array to index
along the axis and removes the axis,
modifying the shape and strides in-place.
Panics if axis
or index
is out of bounds.
use ndarray::{Axis, arr1, arr2};
let mut a = arr2(&[[1, 2, 3], [4, 5, 6]]).into_dyn();
assert_eq!(a.shape(), &[2, 3]);
a.index_axis_inplace(Axis(1), 1);
assert_eq!(a, arr1(&[2, 5]).into_dyn());
assert_eq!(a.shape(), &[2]);
source§impl<A, S, D> ArrayBase<S, D>where
S: Data<Elem = A>,
D: Dimension,
impl<A, S, D> ArrayBase<S, D>where
S: Data<Elem = A>,
D: Dimension,
sourcepub fn sum(&self) -> Awhere
A: Clone + Add<Output = A> + Zero,
pub fn sum(&self) -> Awhere
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.sum(), 10.);
sourcepub fn scalar_sum(&self) -> Awhere
A: Clone + Add<Output = A> + Zero,
pub fn scalar_sum(&self) -> Awhere
A: Clone + Add<Output = A> + Zero,
Return the sum of all elements in the array.
This method has been renamed to .sum()
and will be deprecated in the
next version.
sourcepub fn product(&self) -> Awhere
A: Clone + Mul<Output = A> + One,
pub fn product(&self) -> Awhere
A: Clone + Mul<Output = A> + One,
Return the product of all elements in the array.
use ndarray::arr2;
let a = arr2(&[[1., 2.],
[3., 4.]]);
assert_eq!(a.product(), 24.);
sourcepub fn sum_axis(&self, axis: Axis) -> Array<A, D::Smaller>where
A: Clone + Zero + Add<Output = A>,
D: RemoveAxis,
pub fn sum_axis(&self, axis: Axis) -> Array<A, D::Smaller>where
A: Clone + Zero + Add<Output = A>,
D: RemoveAxis,
Return sum along axis
.
use ndarray::{aview0, aview1, arr2, Axis};
let a = arr2(&[[1., 2.],
[3., 4.]]);
assert!(
a.sum_axis(Axis(0)) == aview1(&[4., 6.]) &&
a.sum_axis(Axis(1)) == aview1(&[3., 7.]) &&
a.sum_axis(Axis(0)).sum_axis(Axis(0)) == aview0(&10.)
);
Panics if axis
is out of bounds.
sourcepub fn mean_axis(&self, axis: Axis) -> Array<A, D::Smaller>where
A: Clone + Zero + One + Add<Output = A> + Div<Output = A>,
D: RemoveAxis,
pub fn mean_axis(&self, axis: Axis) -> Array<A, D::Smaller>where
A: Clone + Zero + One + Add<Output = A> + Div<Output = A>,
D: RemoveAxis,
Return mean along axis
.
Panics if axis
is out of bounds or if the length of the axis is
zero and division by zero panics for type A
.
use ndarray::{aview1, arr2, Axis};
let a = arr2(&[[1., 2.],
[3., 4.]]);
assert!(
a.mean_axis(Axis(0)) == aview1(&[2.0, 3.0]) &&
a.mean_axis(Axis(1)) == aview1(&[1.5, 3.5])
);
sourcepub fn var_axis(&self, axis: Axis, ddof: A) -> Array<A, D::Smaller>where
A: Float,
D: RemoveAxis,
pub fn var_axis(&self, axis: Axis, ddof: A) -> Array<A, D::Smaller>where
A: Float,
D: RemoveAxis,
Return variance along axis
.
The variance is computed using the Welford one-pass algorithm.
The parameter ddof
specifies the “delta degrees of freedom”. For
example, to calculate the population variance, use ddof = 0
, or to
calculate the sample variance, use ddof = 1
.
The variance is defined as:
1 n
variance = ―――――――― ∑ (xᵢ - x̅)²
n - ddof i=1
where
1 n
x̅ = ― ∑ xᵢ
n i=1
Panics if ddof
is greater than or equal to the length of the
axis, if axis
is out of bounds, or if the length of the axis is zero.
Example
use ndarray::{aview1, arr2, Axis};
let a = arr2(&[[1., 2.],
[3., 4.],
[5., 6.]]);
let var = a.var_axis(Axis(0), 1.);
assert_eq!(var, aview1(&[4., 4.]));
sourcepub fn std_axis(&self, axis: Axis, ddof: A) -> Array<A, D::Smaller>where
A: Float,
D: RemoveAxis,
pub fn std_axis(&self, axis: Axis, ddof: A) -> Array<A, D::Smaller>where
A: Float,
D: RemoveAxis,
Return standard deviation along axis
.
The standard deviation is computed from the variance using the Welford one-pass algorithm.
The parameter ddof
specifies the “delta degrees of freedom”. For
example, to calculate the population standard deviation, use ddof = 0
,
or to calculate the sample standard deviation, use ddof = 1
.
The standard deviation is defined as:
1 n
stddev = sqrt ( ―――――――― ∑ (xᵢ - x̅)² )
n - ddof i=1
where
1 n
x̅ = ― ∑ xᵢ
n i=1
Panics if ddof
is greater than or equal to the length of the
axis, if axis
is out of bounds, or if the length of the axis is zero.
Example
use ndarray::{aview1, arr2, Axis};
let a = arr2(&[[1., 2.],
[3., 4.],
[5., 6.]]);
let stddev = a.std_axis(Axis(0), 1.);
assert_eq!(stddev, aview1(&[2., 2.]));
sourcepub fn all_close<S2, E>(&self, rhs: &ArrayBase<S2, E>, tol: A) -> boolwhere
A: Float,
S2: Data<Elem = A>,
E: Dimension,
pub fn all_close<S2, E>(&self, rhs: &ArrayBase<S2, E>, tol: A) -> boolwhere
A: Float,
S2: Data<Elem = A>,
E: Dimension,
Return true
if the arrays’ elementwise differences are all within
the given absolute tolerance, false
otherwise.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting to the same shape isn’t possible.
source§impl<A, S> ArrayBase<S, Ix1>where
S: Data<Elem = A>,
impl<A, S> ArrayBase<S, Ix1>where
S: Data<Elem = A>,
sourcepub fn dot<Rhs>(&self, rhs: &Rhs) -> <Self as Dot<Rhs>>::Outputwhere
Self: Dot<Rhs>,
pub fn dot<Rhs>(&self, rhs: &Rhs) -> <Self as Dot<Rhs>>::Outputwhere
Self: Dot<Rhs>,
Perform dot product or matrix multiplication of arrays self
and rhs
.
Rhs
may be either a one-dimensional or a two-dimensional array.
If Rhs
is one-dimensional, then the operation is a vector dot
product, which is the sum of the elementwise products (no conjugation
of complex operands, and thus not their inner product). In this case,
self
and rhs
must be the same length.
If Rhs
is two-dimensional, then the operation is matrix
multiplication, where self
is treated as a row vector. In this case,
if self
is shape M, then rhs
is shape M × N and the result is
shape N.
Panics if the array shapes are incompatible.
Note: If enabled, uses blas dot
for elements of f32, f64
when memory
layout allows.
source§impl<A, S> ArrayBase<S, Ix2>where
S: Data<Elem = A>,
impl<A, S> ArrayBase<S, Ix2>where
S: Data<Elem = A>,
sourcepub fn dot<Rhs>(&self, rhs: &Rhs) -> <Self as Dot<Rhs>>::Outputwhere
Self: Dot<Rhs>,
pub fn dot<Rhs>(&self, rhs: &Rhs) -> <Self as Dot<Rhs>>::Outputwhere
Self: Dot<Rhs>,
Perform matrix multiplication of rectangular arrays self
and rhs
.
Rhs
may be either a one-dimensional or a two-dimensional array.
If Rhs is two-dimensional, they array shapes 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 shapes are incompatible or the number of elements in the
result would overflow isize
.
Note: If enabled, uses blas gemv/gemm
for elements of f32, f64
when memory layout allows. The default matrixmultiply backend
is otherwise used for f32, f64
for all memory layouts.
use ndarray::arr2;
let a = arr2(&[[1., 2.],
[0., 1.]]);
let b = arr2(&[[1., 2.],
[2., 3.]]);
assert!(
a.dot(&b) == arr2(&[[5., 8.],
[2., 3.]])
);
source§impl<A, S, D> ArrayBase<S, D>where
S: Data<Elem = A>,
D: Dimension,
impl<A, S, D> ArrayBase<S, D>where
S: Data<Elem = A>,
D: Dimension,
sourcepub fn scaled_add<S2, E>(&mut self, alpha: A, rhs: &ArrayBase<S2, E>)where
S: DataMut,
S2: Data<Elem = A>,
A: LinalgScalar,
E: Dimension,
pub fn scaled_add<S2, E>(&mut self, alpha: A, rhs: &ArrayBase<S2, E>)where
S: DataMut,
S2: Data<Elem = A>,
A: LinalgScalar,
E: Dimension,
Perform the operation self += alpha * rhs
efficiently, where
alpha
is a scalar and rhs
is another array. This operation is
also known as axpy
in BLAS.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, D> ArrayBase<ViewRepr<&'a A>, D>where
D: Dimension,
impl<'a, A, D> ArrayBase<ViewRepr<&'a A>, D>where
D: Dimension,
Methods for read-only array views.
sourcepub fn from_shape<Sh>(shape: Sh, xs: &'a [A]) -> Result<Self, ShapeError>where
Sh: Into<StrideShape<D>>,
pub fn from_shape<Sh>(shape: Sh, xs: &'a [A]) -> Result<Self, ShapeError>where
Sh: Into<StrideShape<D>>,
Create a read-only array view borrowing its data from a slice.
Checks whether shape
are compatible with the slice’s
length, returning an Err
if not compatible.
use ndarray::ArrayView;
use ndarray::arr3;
use ndarray::ShapeBuilder;
let s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
let a = ArrayView::from_shape((2, 3, 2).strides((1, 4, 2)),
&s).unwrap();
assert!(
a == arr3(&[[[0, 2],
[4, 6],
[8, 10]],
[[1, 3],
[5, 7],
[9, 11]]])
);
assert!(a.strides() == &[1, 4, 2]);
sourcepub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *const A) -> Selfwhere
Sh: Into<StrideShape<D>>,
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *const A) -> Selfwhere
Sh: Into<StrideShape<D>>,
Create an ArrayView<A, D>
from shape information and a raw pointer to
the elements.
Unsafe because caller is responsible for ensuring all of the following:
-
The elements seen by moving
ptr
according to the shape and strides must live at least as long as'a
and must not be not mutably aliased for the duration of'a
. -
ptr
must be non-null and aligned, and it must be safe to.offset()
ptr
by zero. -
It must be safe to
.offset()
the pointer repeatedly along all axes and calculate thecount
s for the.offset()
calls without overflow, even if the array is empty or the elements are zero-sized.In other words,
-
All possible pointers generated by moving along all axes must be in bounds or one byte past the end of a single allocation with element type
A
. The only exceptions are if the array is empty or the element type is zero-sized. In these cases,ptr
may be dangling, but it must still be safe to.offset()
the pointer along the axes. -
The offset in units of bytes between the least address and greatest address by moving along all axes must not exceed
isize::MAX
. This constraint prevents the computed offset, in bytes, from overflowingisize
regardless of the starting point due to past offsets. -
The offset in units of
A
between the least address and greatest address by moving along all axes must not exceedisize::MAX
. This constraint prevents overflow when calculating thecount
parameter to.offset()
regardless of the starting point due to past offsets.
-
-
The product of non-zero axis lengths must not exceed
isize::MAX
.
sourcepub fn reborrow<'b>(self) -> ArrayView<'b, A, D>where
'a: 'b,
pub fn reborrow<'b>(self) -> ArrayView<'b, A, D>where
'a: 'b,
Convert the view into an ArrayView<'b, A, D>
where 'b
is a lifetime
outlived by 'a'
.
sourcepub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
Split the array view along axis
and return one view strictly before the
split and one view after the split.
Panics if axis
or index
is out of bounds.
Below, an illustration of .split_at(Axis(2), 2)
on
an array with shape 3 × 5 × 5.
sourcepub fn into_slice(&self) -> Option<&'a [A]>
pub fn into_slice(&self) -> Option<&'a [A]>
Return the array’s data as a slice, if it is contiguous and in standard order.
Return None
otherwise.
source§impl<'a, A, D> ArrayBase<ViewRepr<&'a mut A>, D>where
D: Dimension,
impl<'a, A, D> ArrayBase<ViewRepr<&'a mut A>, D>where
D: Dimension,
Methods for read-write array views.
sourcepub fn from_shape<Sh>(shape: Sh, xs: &'a mut [A]) -> Result<Self, ShapeError>where
Sh: Into<StrideShape<D>>,
pub fn from_shape<Sh>(shape: Sh, xs: &'a mut [A]) -> Result<Self, ShapeError>where
Sh: Into<StrideShape<D>>,
Create a read-write array view borrowing its data from a slice.
Checks whether dim
and strides
are compatible with the slice’s
length, returning an Err
if not compatible.
use ndarray::ArrayViewMut;
use ndarray::arr3;
use ndarray::ShapeBuilder;
let mut s = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
let mut a = ArrayViewMut::from_shape((2, 3, 2).strides((1, 4, 2)),
&mut s).unwrap();
a[[0, 0, 0]] = 1;
assert!(
a == arr3(&[[[1, 2],
[4, 6],
[8, 10]],
[[1, 3],
[5, 7],
[9, 11]]])
);
assert!(a.strides() == &[1, 4, 2]);
sourcepub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *mut A) -> Selfwhere
Sh: Into<StrideShape<D>>,
pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: *mut A) -> Selfwhere
Sh: Into<StrideShape<D>>,
Create an ArrayViewMut<A, D>
from shape information and a
raw pointer to the elements.
Unsafe because caller is responsible for ensuring all of the following:
-
The elements seen by moving
ptr
according to the shape and strides must live at least as long as'a
and must not be aliased for the duration of'a
. -
ptr
must be non-null and aligned, and it must be safe to.offset()
ptr
by zero. -
It must be safe to
.offset()
the pointer repeatedly along all axes and calculate thecount
s for the.offset()
calls without overflow, even if the array is empty or the elements are zero-sized.In other words,
-
All possible pointers generated by moving along all axes must be in bounds or one byte past the end of a single allocation with element type
A
. The only exceptions are if the array is empty or the element type is zero-sized. In these cases,ptr
may be dangling, but it must still be safe to.offset()
the pointer along the axes. -
The offset in units of bytes between the least address and greatest address by moving along all axes must not exceed
isize::MAX
. This constraint prevents the computed offset, in bytes, from overflowingisize
regardless of the starting point due to past offsets. -
The offset in units of
A
between the least address and greatest address by moving along all axes must not exceedisize::MAX
. This constraint prevents overflow when calculating thecount
parameter to.offset()
regardless of the starting point due to past offsets.
-
-
The product of non-zero axis lengths must not exceed
isize::MAX
.
sourcepub fn reborrow<'b>(self) -> ArrayViewMut<'b, A, D>where
'a: 'b,
pub fn reborrow<'b>(self) -> ArrayViewMut<'b, A, D>where
'a: 'b,
Convert the view into an ArrayViewMut<'b, A, D>
where 'b
is a lifetime
outlived by 'a'
.
sourcepub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
pub fn split_at(self, axis: Axis, index: Ix) -> (Self, Self)
Split the array view along axis
and return one mutable view strictly
before the split and one mutable view after the split.
Panics if axis
or index
is out of bounds.
sourcepub fn into_slice(self) -> Option<&'a mut [A]>
pub fn into_slice(self) -> Option<&'a mut [A]>
Return the array’s data as a slice, if it is contiguous and in standard order.
Return None
otherwise.
Trait Implementations§
source§impl<'a, S, D> Add<&'a ArrayBase<S, D>> for Complex<f32>where
S: Data<Elem = Complex<f32>>,
D: Dimension,
impl<'a, S, D> Add<&'a ArrayBase<S, D>> for Complex<f32>where
S: Data<Elem = Complex<f32>>,
D: Dimension,
source§impl<'a, S, D> Add<&'a ArrayBase<S, D>> for Complex<f64>where
S: Data<Elem = Complex<f64>>,
D: Dimension,
impl<'a, S, D> Add<&'a ArrayBase<S, D>> for Complex<f64>where
S: Data<Elem = Complex<f64>>,
D: Dimension,
source§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,
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,
Perform elementwise
addition
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> Add<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Add<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> Add<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Add<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
addition
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> Add<ArrayBase<S, D>> for Complex<f32>where
S: DataOwned<Elem = Complex<f32>> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for Complex<f32>where
S: DataOwned<Elem = Complex<f32>> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for Complex<f64>where
S: DataOwned<Elem = Complex<f64>> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for Complex<f64>where
S: DataOwned<Elem = Complex<f64>> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> Add<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> Add<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> Add<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Add<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> Add<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Add<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
addition
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> Add<B> for &'a ArrayBase<S, D>where
A: Clone + Add<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> Add<B> for &'a ArrayBase<S, D>where
A: Clone + Add<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
addition
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> Add<B> for ArrayBase<S, D>where
A: Clone + Add<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> Add<B> for ArrayBase<S, D>where
A: Clone + Add<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
addition
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> AddAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + AddAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> AddAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + AddAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self += rhs
as elementwise addition (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn add_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn add_assign(&mut self, rhs: &ArrayBase<S2, E>)
+=
operation. Read moresource§impl<A, S, D> AddAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + AddAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> AddAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + AddAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self += rhs
as elementwise addition (in place).
source§fn add_assign(&mut self, rhs: A)
fn add_assign(&mut self, rhs: A)
+=
operation. Read moresource§impl<'a, A: Binary, S, D: Dimension> Binary for ArrayBase<S, D>where
S: Data<Elem = A>,
impl<'a, A: Binary, S, D: Dimension> Binary for ArrayBase<S, D>where
S: Data<Elem = A>,
Format the array using Binary
and apply the formatting parameters used
to each element.
The array is shown in multiline style.
source§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,
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,
Perform elementwise
bit and
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> BitAnd<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitAnd<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> BitAnd<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitAnd<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
bit and
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> BitAnd<ArrayBase<S, D>> for boolwhere
S: DataOwned<Elem = bool> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for boolwhere
S: DataOwned<Elem = bool> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for i8where
S: DataOwned<Elem = i8> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for i8where
S: DataOwned<Elem = i8> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<S, D> BitAnd<ArrayBase<S, D>> for u8where
S: DataOwned<Elem = u8> + DataMut,
D: Dimension,
impl<S, D> BitAnd<ArrayBase<S, D>> for u8where
S: DataOwned<Elem = u8> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> BitAnd<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitAnd<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> BitAnd<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitAnd<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
bit and
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> BitAnd<B> for &'a ArrayBase<S, D>where
A: Clone + BitAnd<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> BitAnd<B> for &'a ArrayBase<S, D>where
A: Clone + BitAnd<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
bit and
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> BitAnd<B> for ArrayBase<S, D>where
A: Clone + BitAnd<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> BitAnd<B> for ArrayBase<S, D>where
A: Clone + BitAnd<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
bit and
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> BitAndAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitAndAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> BitAndAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitAndAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self &= rhs
as elementwise bit and (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn bitand_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn bitand_assign(&mut self, rhs: &ArrayBase<S2, E>)
&=
operation. Read moresource§impl<A, S, D> BitAndAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + BitAndAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> BitAndAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + BitAndAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self &= rhs
as elementwise bit and (in place).
source§fn bitand_assign(&mut self, rhs: A)
fn bitand_assign(&mut self, rhs: A)
&=
operation. Read moresource§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,
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,
Perform elementwise
bit or
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> BitOr<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitOr<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> BitOr<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitOr<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
bit or
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> BitOr<ArrayBase<S, D>> for boolwhere
S: DataOwned<Elem = bool> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for boolwhere
S: DataOwned<Elem = bool> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for i8where
S: DataOwned<Elem = i8> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for i8where
S: DataOwned<Elem = i8> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<S, D> BitOr<ArrayBase<S, D>> for u8where
S: DataOwned<Elem = u8> + DataMut,
D: Dimension,
impl<S, D> BitOr<ArrayBase<S, D>> for u8where
S: DataOwned<Elem = u8> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> BitOr<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitOr<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> BitOr<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitOr<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
bit or
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> BitOr<B> for &'a ArrayBase<S, D>where
A: Clone + BitOr<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> BitOr<B> for &'a ArrayBase<S, D>where
A: Clone + BitOr<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
bit or
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> BitOr<B> for ArrayBase<S, D>where
A: Clone + BitOr<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> BitOr<B> for ArrayBase<S, D>where
A: Clone + BitOr<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
bit or
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> BitOrAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitOrAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> BitOrAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitOrAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self |= rhs
as elementwise bit or (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn bitor_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn bitor_assign(&mut self, rhs: &ArrayBase<S2, E>)
|=
operation. Read moresource§impl<A, S, D> BitOrAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + BitOrAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> BitOrAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + BitOrAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self |= rhs
as elementwise bit or (in place).
source§fn bitor_assign(&mut self, rhs: A)
fn bitor_assign(&mut self, rhs: A)
|=
operation. Read moresource§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,
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,
Perform elementwise
bit xor
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> BitXor<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitXor<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> BitXor<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitXor<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
bit xor
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> BitXor<ArrayBase<S, D>> for boolwhere
S: DataOwned<Elem = bool> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for boolwhere
S: DataOwned<Elem = bool> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for i8where
S: DataOwned<Elem = i8> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for i8where
S: DataOwned<Elem = i8> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<S, D> BitXor<ArrayBase<S, D>> for u8where
S: DataOwned<Elem = u8> + DataMut,
D: Dimension,
impl<S, D> BitXor<ArrayBase<S, D>> for u8where
S: DataOwned<Elem = u8> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> BitXor<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitXor<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> BitXor<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitXor<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
bit xor
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> BitXor<B> for &'a ArrayBase<S, D>where
A: Clone + BitXor<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> BitXor<B> for &'a ArrayBase<S, D>where
A: Clone + BitXor<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
bit xor
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> BitXor<B> for ArrayBase<S, D>where
A: Clone + BitXor<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> BitXor<B> for ArrayBase<S, D>where
A: Clone + BitXor<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
bit xor
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> BitXorAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitXorAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> BitXorAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + BitXorAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self ^= rhs
as elementwise bit xor (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn bitxor_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn bitxor_assign(&mut self, rhs: &ArrayBase<S2, E>)
^=
operation. Read moresource§impl<A, S, D> BitXorAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + BitXorAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> BitXorAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + BitXorAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self ^= rhs
as elementwise bit xor (in place).
source§fn bitxor_assign(&mut self, rhs: A)
fn bitxor_assign(&mut self, rhs: A)
^=
operation. Read moresource§impl<'a, A: Debug, S, D: Dimension> Debug for ArrayBase<S, D>where
S: Data<Elem = A>,
impl<'a, A: Debug, S, D: Dimension> Debug for ArrayBase<S, D>where
S: Data<Elem = A>,
Format the array using Debug
and apply the formatting parameters used
to each element.
The array is shown in multiline style.
source§impl<A, S, D> Decodable for ArrayBase<S, D>where
A: Decodable,
D: Dimension + Decodable,
S: DataOwned<Elem = A>,
impl<A, S, D> Decodable for ArrayBase<S, D>where
A: Decodable,
D: Dimension + Decodable,
S: DataOwned<Elem = A>,
Requires crate feature "rustc-serialize"
source§impl<A, S, D> Default for ArrayBase<S, D>where
S: DataOwned<Elem = A>,
D: Dimension,
A: Default,
impl<A, S, D> Default for ArrayBase<S, D>where
S: DataOwned<Elem = A>,
D: Dimension,
A: Default,
Create an owned array with a default state.
The array is created with dimension D::default()
, which results
in for example dimensions 0
and (0, 0)
with zero elements for the
one-dimensional and two-dimensional cases respectively.
The default dimension for IxDyn
is IxDyn(&[0])
(array has zero
elements). And the default for the dimension ()
is ()
(array has
one element).
Since arrays cannot grow, the intention is to use the default value as placeholder.
source§impl<'de, A, Di, S> Deserialize<'de> for ArrayBase<S, Di>where
A: Deserialize<'de>,
Di: Deserialize<'de> + Dimension,
S: DataOwned<Elem = A>,
impl<'de, A, Di, S> Deserialize<'de> for ArrayBase<S, Di>where
A: Deserialize<'de>,
Di: Deserialize<'de> + Dimension,
S: DataOwned<Elem = A>,
Requires crate feature "serde-1"
source§fn deserialize<D>(deserializer: D) -> Result<ArrayBase<S, Di>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<ArrayBase<S, Di>, D::Error>where
D: Deserializer<'de>,
source§impl<'a, A: Display, S, D: Dimension> Display for ArrayBase<S, D>where
S: Data<Elem = A>,
impl<'a, A: Display, S, D: Dimension> Display for ArrayBase<S, D>where
S: Data<Elem = A>,
Format the array using Display
and apply the formatting parameters used
to each element.
The array is shown in multiline style.
source§impl<'a, S, D> Div<&'a ArrayBase<S, D>> for Complex<f32>where
S: Data<Elem = Complex<f32>>,
D: Dimension,
impl<'a, S, D> Div<&'a ArrayBase<S, D>> for Complex<f32>where
S: Data<Elem = Complex<f32>>,
D: Dimension,
source§impl<'a, S, D> Div<&'a ArrayBase<S, D>> for Complex<f64>where
S: Data<Elem = Complex<f64>>,
D: Dimension,
impl<'a, S, D> Div<&'a ArrayBase<S, D>> for Complex<f64>where
S: Data<Elem = Complex<f64>>,
D: Dimension,
source§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,
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,
Perform elementwise
division
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> Div<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Div<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> Div<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Div<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
division
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> Div<ArrayBase<S, D>> for Complex<f32>where
S: DataOwned<Elem = Complex<f32>> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for Complex<f32>where
S: DataOwned<Elem = Complex<f32>> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for Complex<f64>where
S: DataOwned<Elem = Complex<f64>> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for Complex<f64>where
S: DataOwned<Elem = Complex<f64>> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> Div<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> Div<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> Div<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Div<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> Div<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Div<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
division
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> Div<B> for &'a ArrayBase<S, D>where
A: Clone + Div<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> Div<B> for &'a ArrayBase<S, D>where
A: Clone + Div<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
division
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> Div<B> for ArrayBase<S, D>where
A: Clone + Div<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> Div<B> for ArrayBase<S, D>where
A: Clone + Div<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
division
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> DivAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + DivAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> DivAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + DivAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self /= rhs
as elementwise division (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn div_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn div_assign(&mut self, rhs: &ArrayBase<S2, E>)
/=
operation. Read moresource§impl<A, S, D> DivAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + DivAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> DivAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + DivAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self /= rhs
as elementwise division (in place).
source§fn div_assign(&mut self, rhs: A)
fn div_assign(&mut self, rhs: A)
/=
operation. Read moresource§impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 1]>>> for ArrayBase<S, Ix1>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 1]>>> for ArrayBase<S, Ix1>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
source§fn dot(&self, rhs: &ArrayBase<S2, Ix1>) -> A
fn dot(&self, rhs: &ArrayBase<S2, Ix1>) -> A
Compute the dot product of one-dimensional arrays.
The dot product is a sum of the elementwise products (no conjugation of complex operands, and thus not their inner product).
Panics if the arrays are not of the same length.
Note: If enabled, uses blas dot
for elements of f32, f64
when memory
layout allows.
source§impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 1]>>> for ArrayBase<S, Ix2>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 1]>>> for ArrayBase<S, Ix2>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
Perform the matrix multiplication of the rectangular array self
and
column vector rhs
.
The array shapes must agree in the way that
if self
is M × N, then rhs
is N.
Return a result array with shape M.
Panics if shapes are incompatible.
source§impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 2]>>> for ArrayBase<S, Ix1>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 2]>>> for ArrayBase<S, Ix1>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
source§impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 2]>>> for ArrayBase<S, Ix2>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
impl<A, S, S2> Dot<ArrayBase<S2, Dim<[usize; 2]>>> for ArrayBase<S, Ix2>where
S: Data<Elem = A>,
S2: Data<Elem = A>,
A: LinalgScalar,
source§impl<A, S, D> Encodable for ArrayBase<S, D>where
A: Encodable,
D: Dimension + Encodable,
S: Data<Elem = A>,
impl<A, S, D> Encodable for ArrayBase<S, D>where
A: Encodable,
D: Dimension + Encodable,
S: Data<Elem = A>,
Requires crate feature "rustc-serialize"
source§impl<'a, A, S, D> From<&'a ArrayBase<S, D>> for ArrayView<'a, A, D>where
S: Data<Elem = A>,
D: Dimension,
impl<'a, A, S, D> From<&'a ArrayBase<S, D>> for ArrayView<'a, A, D>where
S: Data<Elem = A>,
D: Dimension,
Implementation of ArrayView::from(&A)
where A
is an array.
Create a read-only array view of the array.
source§impl<'a, A, S, D> From<&'a mut ArrayBase<S, D>> for ArrayViewMut<'a, A, D>where
S: DataMut<Elem = A>,
D: Dimension,
impl<'a, A, S, D> From<&'a mut ArrayBase<S, D>> for ArrayViewMut<'a, A, D>where
S: DataMut<Elem = A>,
D: Dimension,
Implementation of ArrayViewMut::from(&mut A)
where A
is an array.
Create a read-write array view of the array.
source§impl<S, D, I> Index<I> for ArrayBase<S, D>where
D: Dimension,
I: NdIndex<D>,
S: Data,
impl<S, D, I> Index<I> for ArrayBase<S, D>where
D: Dimension,
I: NdIndex<D>,
S: Data,
Access the element at index.
Panics if index is out of bounds.
source§impl<S, D, I> IndexMut<I> for ArrayBase<S, D>where
D: Dimension,
I: NdIndex<D>,
S: DataMut,
impl<S, D, I> IndexMut<I> for ArrayBase<S, D>where
D: Dimension,
I: NdIndex<D>,
S: DataMut,
Access the element at index mutably.
Panics if index is out of bounds.
source§impl<'a, A: 'a, S, D> IntoNdProducer for &'a ArrayBase<S, D>where
D: Dimension,
S: Data<Elem = A>,
impl<'a, A: 'a, S, D> IntoNdProducer for &'a ArrayBase<S, D>where
D: Dimension,
S: Data<Elem = A>,
An array reference is an n-dimensional producer of element references (like ArrayView).
source§impl<'a, A: 'a, S, D> IntoNdProducer for &'a mut ArrayBase<S, D>where
D: Dimension,
S: DataMut<Elem = A>,
impl<'a, A: 'a, S, D> IntoNdProducer for &'a mut ArrayBase<S, D>where
D: Dimension,
S: DataMut<Elem = A>,
A mutable array reference is an n-dimensional producer of mutable element references (like ArrayViewMut).
source§impl<'a, A: LowerExp, S, D: Dimension> LowerExp for ArrayBase<S, D>where
S: Data<Elem = A>,
impl<'a, A: LowerExp, S, D: Dimension> LowerExp for ArrayBase<S, D>where
S: Data<Elem = A>,
Format the array using LowerExp
and apply the formatting parameters used
to each element.
The array is shown in multiline style.
source§impl<'a, A: LowerHex, S, D: Dimension> LowerHex for ArrayBase<S, D>where
S: Data<Elem = A>,
impl<'a, A: LowerHex, S, D: Dimension> LowerHex for ArrayBase<S, D>where
S: Data<Elem = A>,
Format the array using LowerHex
and apply the formatting parameters used
to each element.
The array is shown in multiline style.
source§impl<'a, S, D> Mul<&'a ArrayBase<S, D>> for Complex<f32>where
S: Data<Elem = Complex<f32>>,
D: Dimension,
impl<'a, S, D> Mul<&'a ArrayBase<S, D>> for Complex<f32>where
S: Data<Elem = Complex<f32>>,
D: Dimension,
source§impl<'a, S, D> Mul<&'a ArrayBase<S, D>> for Complex<f64>where
S: Data<Elem = Complex<f64>>,
D: Dimension,
impl<'a, S, D> Mul<&'a ArrayBase<S, D>> for Complex<f64>where
S: Data<Elem = Complex<f64>>,
D: Dimension,
source§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,
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,
Perform elementwise
multiplication
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> Mul<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Mul<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> Mul<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Mul<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
multiplication
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> Mul<ArrayBase<S, D>> for Complex<f32>where
S: DataOwned<Elem = Complex<f32>> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for Complex<f32>where
S: DataOwned<Elem = Complex<f32>> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for Complex<f64>where
S: DataOwned<Elem = Complex<f64>> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for Complex<f64>where
S: DataOwned<Elem = Complex<f64>> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> Mul<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> Mul<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> Mul<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Mul<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> Mul<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Mul<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
multiplication
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> Mul<B> for &'a ArrayBase<S, D>where
A: Clone + Mul<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> Mul<B> for &'a ArrayBase<S, D>where
A: Clone + Mul<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
multiplication
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> Mul<B> for ArrayBase<S, D>where
A: Clone + Mul<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> Mul<B> for ArrayBase<S, D>where
A: Clone + Mul<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
multiplication
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> MulAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + MulAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> MulAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + MulAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self *= rhs
as elementwise multiplication (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn mul_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn mul_assign(&mut self, rhs: &ArrayBase<S2, E>)
*=
operation. Read moresource§impl<A, S, D> MulAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + MulAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> MulAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + MulAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self *= rhs
as elementwise multiplication (in place).
source§fn mul_assign(&mut self, rhs: A)
fn mul_assign(&mut self, rhs: A)
*=
operation. Read moresource§impl<'a, A, S, D> Neg for &'a ArrayBase<S, D>where
&'a A: 'a + Neg<Output = A>,
S: Data<Elem = A>,
D: Dimension,
impl<'a, A, S, D> Neg for &'a ArrayBase<S, D>where
&'a A: 'a + Neg<Output = A>,
S: Data<Elem = A>,
D: Dimension,
source§impl<A, S, D> Neg for ArrayBase<S, D>where
A: Clone + Neg<Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
impl<A, S, D> Neg for ArrayBase<S, D>where
A: Clone + Neg<Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
source§impl<'a, A, S, D> Not for &'a ArrayBase<S, D>where
&'a A: 'a + Not<Output = A>,
S: Data<Elem = A>,
D: Dimension,
impl<'a, A, S, D> Not for &'a ArrayBase<S, D>where
&'a A: 'a + Not<Output = A>,
S: Data<Elem = A>,
D: Dimension,
source§impl<A, S, D> Not for ArrayBase<S, D>where
A: Clone + Not<Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
impl<A, S, D> Not for ArrayBase<S, D>where
A: Clone + Not<Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
source§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,
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,
Return true
if the array shapes and all elements of self
and
rhs
are equal. Return false
otherwise.
source§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,
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,
Perform elementwise
remainder
between references self
and rhs
,
and return the result as a new Array
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, S2, D, E> Rem<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Rem<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> Rem<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Rem<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
remainder
between self
and reference rhs
,
and return the result (based on self
).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<S, D> Rem<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for f32where
S: DataOwned<Elem = f32> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for f64where
S: DataOwned<Elem = f64> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for i128where
S: DataOwned<Elem = i128> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for i16where
S: DataOwned<Elem = i16> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for i32where
S: DataOwned<Elem = i32> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for i64where
S: DataOwned<Elem = i64> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for u128where
S: DataOwned<Elem = u128> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for u16where
S: DataOwned<Elem = u16> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for u32where
S: DataOwned<Elem = u32> + DataMut,
D: Dimension,
source§impl<S, D> Rem<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
impl<S, D> Rem<ArrayBase<S, D>> for u64where
S: DataOwned<Elem = u64> + DataMut,
D: Dimension,
source§impl<A, S, S2, D, E> Rem<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Rem<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<A, S, S2, D, E> Rem<ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + Rem<A, Output = A>,
S: DataOwned<Elem = A> + DataMut,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform elementwise
remainder
between self
and rhs
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§impl<'a, A, S, D, B> Rem<B> for &'a ArrayBase<S, D>where
A: Clone + Rem<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
impl<'a, A, S, D, B> Rem<B> for &'a ArrayBase<S, D>where
A: Clone + Rem<B, Output = A>,
S: Data<Elem = A>,
D: Dimension,
B: ScalarOperand,
Perform elementwise
remainder
between the reference self
and the scalar x
,
and return the result as a new Array
.
source§impl<A, S, D, B> Rem<B> for ArrayBase<S, D>where
A: Clone + Rem<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
impl<A, S, D, B> Rem<B> for ArrayBase<S, D>where
A: Clone + Rem<B, Output = A>,
S: DataOwned<Elem = A> + DataMut,
D: Dimension,
B: ScalarOperand,
Perform elementwise
remainder
between self
and the scalar x
,
and return the result (based on self
).
self
must be an Array
or ArcArray
.
source§impl<'a, A, S, S2, D, E> RemAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + RemAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
impl<'a, A, S, S2, D, E> RemAssign<&'a ArrayBase<S2, E>> for ArrayBase<S, D>where
A: Clone + RemAssign<A>,
S: DataMut<Elem = A>,
S2: Data<Elem = A>,
D: Dimension,
E: Dimension,
Perform self %= rhs
as elementwise remainder (in place).
If their shapes disagree, rhs
is broadcast to the shape of self
.
Panics if broadcasting isn’t possible.
source§fn rem_assign(&mut self, rhs: &ArrayBase<S2, E>)
fn rem_assign(&mut self, rhs: &ArrayBase<S2, E>)
%=
operation. Read moresource§impl<A, S, D> RemAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + RemAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
impl<A, S, D> RemAssign<A> for ArrayBase<S, D>where
A: ScalarOperand + RemAssign<A>,
S: DataMut<Elem = A>,
D: Dimension,
Perform self %= rhs
as elementwise remainder (in place).
source§fn rem_assign(&mut self, rhs: A)
fn rem_assign(&mut self, rhs: A)
%=
operation. Read moresource§impl<A, D, S> Serialize for ArrayBase<S, D>where
A: Serialize,
D: Dimension + Serialize,
S: Data<Elem = A>,
impl<A, D, S> Serialize for ArrayBase<S, D>where
A: Serialize,
D: Dimension + Serialize,
S: Data<Elem = A>,
Requires crate feature "serde-1"