Ndarray 0.13 released!


Finally — ndarray 0.13! It has been a long time in the making, and many have contributed, so we have a big list of changes. The following are some highlights, see the full release note for the whole story.

approx Support

Ndarray now supports approx for more flexible (approximate) comparisons.

Abbreviated Formatting Output

Arrays now have a limit of how many elements are shown in formatting by default, and it will ellipsize the middle of each axis, if they get too long. Full output can be forced using the # modifier (the alternate flag).

Integrated rayon Support

Rayon support moved into the crate itself as an optional feature. You can run parallel iterators from arrays and parallelize the Zip primitive for lock-step iteration of several arrays or other NdProducers.

Improved azip!() Syntax

azip is a macro for writing lock-step loops over several arrays or NdProducers, and it now has a syntax that's more similar to the usual for loop: first the pattern and then the producer.

// Here A, B and C are arrays of matching shape.
// Example: Compute a simple ternary operation;
// elementwise addition of B and C, stored in A
azip!((a in &mut A, &b in &B, &c in &C) *a = b + c);

The parallel version is par_azip.

Raw Views

If ArrayViewMut is like a &mut T, then the new RawArrayViewMut is like a *mut T but as an array view. This is a useful low level primitive for our internals, and will help us hone in on writing a Rust that's compatible with the developing unsafe code guidelines.

The raw array views are NdProducers and support some of the ndarray API; like axes, dimensions, splitting and slicing (in place).

More Improvements

New constructors like logspace, new method .as_standard_layout() and a new array storage type CowArray, new method .mean(), matrixmultiply with runtime-detected SIMD support, and more in the full release note. :slight_smile:


This looks really useful for my current project. Is the RawArrayViewMut able to be passed between threads and maintain a constant pointee location? I.e., would I be able to add data to the table and then pass around the mutable pointer for access to the data entry?

It doesn't sound like ndarray can do that. In particular, the borrow rules have to be followed even with the raw views, only manually, and it is not valid to use them across a point where the original array is modified.

1 Like