Docs.rs
  • ndarray-parallel-0.9.1
    • ndarray-parallel 0.9.1
    • Permalink
    • Docs.rs crate page
    • MIT/Apache-2.0
    • Links
    • Repository
    • crates.io
    • Source
    • Owners
    • bluss
    • jturner314
    • Dependencies
      • ndarray ^0.12.0 normal
      • rayon ^1.0 normal
      • itertools ^0.7.0 dev
      • num_cpus ^1.2 dev
    • Versions
    • 34.38% of the crate is documented
  • Platform
    • 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
    • Privacy policy
  • Rust
    • Rust website
    • The Book
    • Standard Library API Reference
    • Rust by Example
    • The Cargo Guide
    • Clippy Documentation

Crate ndarray_parallel

ndarray_parallel0.9.1

  • All Items

Sections

  • Examples
    • Arrays and array views
    • Axis iterators
    • Zip

Crate Items

  • Re-exports
  • Modules
  • Macros
  • Structs
  • Traits

Crates

  • ndarray_parallel

Crate ndarray_parallel

Source
Expand description

Parallelization features for ndarray.

This crate is deprecated and was replaced by equivalent rayon support directly integrated to ndarray.

The array views and references to owned arrays all implement NdarrayIntoParallelIterator (*); the default parallel iterators (each element by reference or mutable reference) have no ordering guarantee in their parallel implementations.

.axis_iter() and .axis_iter_mut() also have parallel counterparts, and their parallel iterators are indexed (and thus ordered) and exact length.

Zip also implements NdarrayIntoParallelIterator, and there is an extension trait so that it can use a method .par_apply directly.

(*) This regime of a custom trait instead of rayon’s own is since we use this intermediate ndarray-parallel crate.

§Examples

§Arrays and array views

Compute the exponential of each element in an array, parallelized.

extern crate ndarray;
extern crate ndarray_parallel;

use ndarray::Array2;
use ndarray_parallel::prelude::*;

fn main() {
    let mut a = Array2::<f64>::zeros((128, 128));

    // Parallel versions of regular array methods (ParMap trait)
    a.par_map_inplace(|x| *x = x.exp());
    a.par_mapv_inplace(f64::exp);

    // You can also use the parallel iterator directly
    a.par_iter_mut().for_each(|x| *x = x.exp());
}

§Axis iterators

Use the parallel .axis_iter() to compute the sum of each row.

extern crate ndarray;
extern crate ndarray_parallel;

use ndarray::Array;
use ndarray::Axis;
use ndarray_parallel::prelude::*;

fn main() {
    let a = Array::linspace(0., 63., 64).into_shape((4, 16)).unwrap();
    let mut sums = Vec::new();
    a.axis_iter(Axis(0))
     .into_par_iter()
     .map(|row| row.scalar_sum())
     .collect_into_vec(&mut sums);

    assert_eq!(sums, [120., 376., 632., 888.]);
}

§Zip

Use zip for lock step function application across several arrays

extern crate ndarray;
extern crate ndarray_parallel;

use ndarray::Array3;
use ndarray::Zip;
use ndarray_parallel::prelude::*;

type Array3f64 = Array3<f64>;

fn main() {
    const N: usize = 128;
    let a = Array3f64::from_elem((N, N, N), 1.);
    let b = Array3f64::from_elem(a.dim(), 2.);
    let mut c = Array3f64::zeros(a.dim());

    Zip::from(&mut c)
        .and(&a)
        .and(&b)
        .par_apply(|c, &a, &b| {
            *c += a - b;
        });
}

Re-exports§

pub extern crate ndarray;
pub extern crate rayon;

Modules§

prelude
Into- traits for creating parallelized iterators.

Macros§

par_azip
Parallel version of the azip! macro.

Structs§

Parallel
Parallel iterator wrapper.

Traits§

NdarrayIntoParallelIterator
NdarrayIntoParallelRefIterator
NdarrayIntoParallelRefMutIterator

Results

Settings
Help
    re-export
    ndarray_parallel::prelude::NdarrayIntoParallelRefMutIterator
    trait method
    ndarray_parallel::NdarrayIntoParallelRefMutIterator::par_iter_mut
    &mut NdarrayIntoParallelRefMutIterator -> NdarrayIntoParallelRefMutIterator::Iter
No results :(
Try on DuckDuckGo?

Or try looking in one of these:
  • The Rust Reference for technical details about the language.
  • Rust By Example for expository code examples.
  • The Rust Book for introductions to language features and the language itself.
  • Docs.rs for documentation of crates released on crates.io.