Docs.rs
  • ndarray-0.13.0
    • ndarray 0.13.0
    • Docs.rs crate page
    • MIT/Apache-2.0
    • 23 September 2019
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • bluss
    • jturner314
    • akern40
    • Dependencies
      • approx ^0.3.2 normal
      • blas-src ^0.2.0 normal
      • cblas-sys ^0.1.4 normal
      • itertools ^0.8.0 normal
      • matrixmultiply ^0.2.0 normal
      • num-complex ^0.2 normal
      • num-integer ^0.1.39 normal
      • num-traits ^0.2 normal
      • rawpointer ^0.2 normal
      • rayon ^1.0.3 normal
      • serde ^1.0 normal
      • approx ^0.3.2 dev
      • defmac ^0.2 dev
      • itertools ^0.8.0 dev
      • quickcheck ^0.8 dev
    • Versions
  • Go to latest version
  • Platform
    • i686-apple-darwin
    • i686-pc-windows-msvc
    • i686-unknown-linux-gnu
    • x86_64-apple-darwin
    • x86_64-pc-windows-msvc
    • x86_64-unknown-linux-gnu
  • Feature flags
  • docs.rs
    • About docs.rs
    • Badges
    • Builds
    • Metadata
    • Shorthand URLs
    • Download
    • Rustdoc JSON
    • Build queue
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation
☰
logo

Type Definition ArrayViewMut

ndarray

[src]Type Definition ndarray::ArrayViewMut
type ArrayViewMut<'a, A, D> = ArrayBase<ViewRepr<&'a mut A>, D>;

A read-write array view.

An array view represents an array or a part of it, created from an iterator, subview or slice of an array.

The ArrayViewMut<'a, A, D> is parameterized by 'a for the scope of the borrow, A for the element type and D for the dimensionality.

Array views have all the methods of an array (see ArrayBase).

See also ArrayView.

Methods

impl<'a, A, D> [src]

Methods for read-write array views.

pub fn from_shape<Sh>(shape: Sh, xs: [src]

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]);

pub unsafe fn from_shape_ptr<Sh>(shape: Sh, ptr: [src]

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 the counts 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 overflowing isize 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 exceed isize::MAX. This constraint prevents overflow when calculating the count parameter to .offset() regardless of the starting point due to past offsets.

  • The product of non-zero axis lengths must not exceed isize::MAX.

pub fn reborrow<'b>(self) -> [src]

Convert the view into an ArrayViewMut<'b, A, D> where 'b is a lifetime outlived by 'a'.

impl<'a, A> [src]

Methods specific to ArrayViewMut0.

See also all methods for ArrayViewMut and ArrayBase

pub fn into_scalar(self) -> [src]

Consume the mutable view and return a mutable reference to the single element in the array.

The lifetime of the returned reference matches the lifetime of the data the array view was pointing to.

use ndarray::{arr0, Array0};

let mut array: Array0<f64> = arr0(5.);
let view = array.view_mut();
let mut scalar = view.into_scalar();
*scalar = 7.;
assert_eq!(scalar, &7.);
assert_eq!(array[()], 7.);

impl<'a, A, D> [src]

Methods for read-write array views.

pub fn into_slice(self) -> [src]

Return the array’s data as a slice, if it is contiguous and in standard order. Return None otherwise.

impl<'a, A, D> [src]

Methods for read-write array views.

pub fn split_at(self, axis: [src]

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.

Trait Implementations

impl<'a, A, D: [src]

type Item = &'a mut A

The element produced per iteration.

type Dim = D

Dimension type

type Ptr = Stride = contiguous_stride(&self) -> Self::[src]

fn __private__(&self) -> PrivateMarker[src]

This trait is private to implement; this method exists to make it impossible to implement outside the crate. Read more

impl<'a, I, A, D> [src]

type Output = &'a mut A

The type of the reference to the element that is produced, including its lifetime. Read more

fn index(self, index: I) -> [src]

Convert a mutable array view to a mutable reference of a element.

This method is like IndexMut::index_mut but with a longer lifetime (matching the array view); which we can only do for the array view and not in the Index trait.

See also the get_mut method which works for all arrays and array views.

Panics if index is out of bounds.

fn get(self, index: I) -> [src]

Convert a mutable array view to a mutable reference of a element, with checked access.

See also the get_mut method which works for all arrays and array views.

unsafe fn uget(self, index: I) -> [src]

Convert a mutable array view to a mutable reference of a element without boundary check.

See also the uget_mut method which works for all arrays and array views.

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

impl<'a, A, D> [src]

type Item = &'a mut A

The type of the elements being iterated over.

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

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::[src]

Creates an iterator from a value. Read more

impl<'a, A, Slice: ?[src]

Implementation of ArrayViewMut::from(&mut S) where S is a slice or slicable.

fn from(slice: [src]

Create a one-dimensional read-write array view of the data in slice.

Panics if the slice length is greater than isize::MAX.

impl<'a, A, S, D> [src]

Implementation of ArrayViewMut::from(&mut A) where A is an array.

fn from(array: &'a mut [src]

Create a read-write array view of the array.

impl<'a, A, D> [src]

Requires crate feature rayon.

type Item = Self::Item

The type of item that the parallel iterator will produce.

type Iter = Parallel<Self>

The parallel iterator type that will be created.

fn into_par_iter(self) -> Self::[src]

Converts self into a parallel iterator. Read more

Help

Keyboard Shortcuts

?
Show this help dialog
S
Focus the search field
↑
Move up in search results
↓
Move down in search results
↹
Switch tab
⏎
Go to active search result
+
Expand all sections
-
Collapse all sections

Search Tricks

Prefix searches with a type followed by a colon (e.g., fn:) to restrict the search to a given type.

Accepted types are: fn, mod, struct, enum, trait, type, macro, and const.

Search functions by type signature (e.g., vec -> usize or * -> vec)

Search multiple things at once by splitting your query with comma (e.g., str,u8 or String,struct:Vec,test)