The ndarray
crate provides an N-dimensional container for general elements
and for numerics. Requires Rust 1.11.
Please read the API documentation here: (0.6 / master)
, (0.5)
, (0.4)
, (0.3)
, (0.2)
__
_ http://bluss.github.io/rust-ndarray/ _ http://bluss.github.io/rust-ndarray/0.5/ _ http://bluss.github.io/rust-ndarray/0.4/ _ http://bluss.github.io/rust-ndarray/0.3/ __ http://bluss.github.io/rust-ndarray/0.2/
|buildstatus| |crates|_
.. |buildstatus| image:: https://travis-ci.org/bluss/rust-ndarray.svg?branch=master .. _buildstatus: https://travis-ci.org/bluss/rust-ndarray
.. |crates| image:: http://meritbadge.herokuapp.com/ndarray .. _crates: https://crates.io/crates/ndarray
Owned arrays and views
ArrayBase
:
The N-dimensional array type itself.Array
:
An array where the data is owned uniquely.RcArray
:
An array where the data has shared ownership and is copy on write.ArrayView
, ArrayViewMut
:
Lightweight array views.Slicing, also with arbitrary step size, and negative indices to mean elements from the end of the axis.
[T]
data.Still iterating on and evolving the API
Performance status:
.map()
, .map_inplace()
and
.zip_mut_with()
are the most efficient ways to
perform single traversal and lock step traversal respectively..iter()
is efficient for c-contiguous arrays.The following crate feature flags are available. They are configured in
your Cargo.toml
.
rustc-serialize
serde
blas
blas-sys
.How to use with cargo::
[dependencies]
ndarray = "0.6"
0.6.8
.fold()
.
(Note that users are recommended to use not use the elements iterator,
but the higher level functions which are the maps, folds and other methods
of the array types themselves.)0.6.7
.fold(), .map(),
.to_owned()
, arithmetic operations with scalars).0.6.6
Array0, Array1, Array2, ...
and so on (there are many), also Ix0, Ix1, Ix2, ...
.Array::from_shape_fn(D, |D| -> A)
.Array::default
, and .fold()
for noncontiguous
array iterators.0.6.5
.into_raw_vec()
to turn an Array
into the its
underlying element storage vector, in whatever element order it is using.0.6.4
.map_axis()
which is used to flatten an array along
one axis by mapping it to a scalar.0.6.3
Default
implementations for owned arrays0.6.2
serde
0.6.1
unsafe
array view constructors ArrayView::from_shape_ptr
for read-only and read-write array views. These make it easier to
create views from raw pointers.0.6.0
OwnedArray
to Array
. The old name is deprecated.0.5.2
0.5.1
0.5.0
iadd, iadd_scalar
and similar methods are now deprecated.use ndarray::prelude::*;
..select(Axis, &[Ix]) -> OwnedArray
, to create an array
from a non-contiguous pick of subviews along an axis..mat_mul()
to just .dot()
and add a function general_mat_mul
for matrix multiplication with scaling into an existing array.0.5.0-alpha.2
0.4.9
0.5.0-alpha.1
use ndarray::prelude::*;
0.5.0-alpha.0
.mat_mul()
to .dot()
. The same method name now handles
dot product and matrix multiplication.0.4.8
.dot()
when using BLAS and arrays with negative stride.0.4.7
0.4.6
0.4.5
.all_close()
which replaces the now deprecated .allclose()
.
The new method has a stricter protocol: it panics if the array
shapes are not compatible. We don't want errors to pass silently..axis_iter()
.OuterIter, OuterIterMut
to AxisIter, AxisIterMut
.
The old name is now deprecated.0.4.4
.mapv(), .mapv_into(), .map_inplace(),
.mapv_inplace(), .visit()
. The mapv
versions
have the transformation function receive the element by value (hence v)..scaled_add()
(a.k.a axpy) and constructor from_vec_dim_f
..rows(), .cols()
..fold()
because it dictates a specific visit order.0.4.3
.t()
as a shorthand to create a transposed view.mat_mul
so that it accepts arguments of different array kindmat_mul
when using BLAS and multiplying with a column
matrix (#154)0.4.2
blas
). Uses pluggable backend.ndarray::blas
and crate feature rblas
. This module
was moved to the crate ndarray-rblas
.as_slice_memory_order, as_slice_memory_order_mut, as_ptr,
as_mut_ptr
.raw_data, raw_data_mut
.Send + Sync
to NdFloat
.from_vec_dim_stride
did not accept arrays with unitary axes.to_owned, map, scalar_sum, assign_scalar
,
and arithmetic operations between array and scalar.to_owned, map, mat_mul
(matrix multiplication
only if both inputs are the same memory order), and arithmetic operations
that allocate a new result.dot, mat_mul
due to more efficient
glue code for calling BLAS..assign_scalar
.0.4.1
Send + Sync
when possible.0.4.0 Release Announcement
__
.split_at(Axis, Ix)
and .axis_chunks_iter()
NdFloat
, AsArray
and From for ArrayView
which
improve generic programming.usize
. (Would be a debug assertion for overflow before.).map()
.stack
and macro stack![axis, arrays..]
to concatenate arrays.OwnedArray::range(start, end, step)
.Array
was renamed to RcArray
(and the old name deprecated).__ http://bluss.github.io/rust/2016/03/06/ndarray-0.4/
0.4.0-alpha.8
NdFloat
which makes it easy to be generic over f32, f64
.From
implementations that convert slices or references to arrays
into array views. This replaces from_slice
from a previous alpha.AsArray
trait, which is simply based on those From
implementations..map()
so that it can autovectorize.Axis
argument in RemoveAxis
too.DataOwned
in the raw data methods.ShapeError
, which uses no allocated data.0.4.0-alpha.7
&a @ &b
.0.4.0-alpha.6
Axis
..split_at(Axis, Ix)
to read-only and read-write array views.ArrayView{,Mut}::from_slice
and array view methods
are now visible in the docs.0.4.0-alpha.5
LinalgScalar
for operations where we want type-based specialization.
This shrinks the set of types that allow dot product, matrix multiply, mean..dot()
(this is the first step).See arithmetic operations docs!
__linalg
(it was already mostly empty)zeros
in favour of static method zeros
.__ https://bluss.github.io/rust-ndarray/master/ndarray/struct.ArrayBase.html#arithmetic-operations
0.4.0-alpha.4
Array
to RcArray
. Old name is deprecated.OuterIter::split_at
, OuterIterMut::split_at
arr0, arr1, arr2, arr3
to return OwnedArray
.
Add rcarr1, rcarr2, rcarr3
that return RcArray
.0.4.0-alpha.3
rblas
integration.
Added methods AsBlas::{blas_view_checked, blas_view_mut_checked, bv, bvm}
.Hash
impl for arrays.0.4.0-alpha.2
ArrayBase::reversed_axes
which transposes an array.0.4.0-alpha.1
Add checked and unchecked constructor methods for creating arrays
from a vector and explicit dimension and stride, or with
fortran (column major) memory order (marked f
):
ArrayBase::from_vec_dim
, from_vec_dim_stride
,
from_vec_dim_stride_unchecked
,
from_vec_dim_unchecked_f
, from_elem_f
, zeros_f
ArrayView::from_slice_dim_stride
,
ArrayViewMut::from_slice_dim_stride
.Rename old ArrayBase::from_vec_dim
to from_vec_dim_unchecked
.
Check better for wraparound when computing the number of elements in a shape;
this adds error cases that panic in from_elem
, zeros
etc,
however the new check will only ever panic in cases that would
trigger debug assertions for overflow in the previous versions!.
.axis_chunks_iter()
and mutable version;
it allows traversing the array in for example chunks of n rows at a time.0.3.1
.row_mut()
, .column_mut()
.axis_iter()
, .axis_iter_mut()
0.3.0
Ix
changed to usize
.a[[i, j, k]]
syntax.ArrayBase::eye(n)
0.3.0-alpha.4
type
aliases..mat_mul()
and .mat_mul_col()
now return OwnedArray
.
Use .into_shared()
if you need an Array
..outer_iter()
(and _mut).0.3.0-alpha.3
.subview()
changed to return an array view, also added into_subview()
..outer_iter()
and .outer_iter_mut()
for iteration along the
greatest axis of the array. Views also implement into_outer_iter()
for
“lifetime preserving” iterators.0.3.0-alpha.2
zip_mut_with
slightly
(affects all binary operations)..row(i), .column(i)
for 2D arrays..row_iter(), .col_iter()
..dot()
for computing the dot product between two 1D arrays.0.3.0-alpha.1
Ix
changed to usize
(#9). Gives better iterator codegen
and 64-bit size arrays..slice()
and .diag()
to return array views, add .into_diag()
.a[[i, j]]
for indexing..ndim()
0.2.0
s![]
0.2.0-alpha.9
rblas
bridge, and fix a bug with
non square matrices.linalg
.0.2.0-alpha.8
ndarray
. Having package != crate ran
into many quirks of various tools. Changing the package name is easier for
everyone involved!scalar_sum()
so that it will vectorize for the floating point
element case too.0.2.0-alpha.7
Optimized arithmetic operations!
For c-contiguous arrays or arrays with c-contiguous lowest dimension they optimize very well, and can vectorize!
Add .inner_iter()
, .inner_iter_mut()
.fold()
, .zip_mut_with()
.scalar_sum()
examples/life.rs
0.2.0-alpha.6
#[deprecated]
attributes (enabled with new enough nightly)ArrayBase::linspace
, deprecate constructor range
.0.2.0-alpha.5
s![...]
, a slice argument macro.aview_mut1()
, zeros()
.diag_mut()
and deprecate .diag_iter_mut()
, .sub_iter_mut()
.uget()
, .uget_mut()
for unchecked indexing and deprecate the
old names.ArrayBase::from_elem
SliceRange
, replaced by From
impls for Si
.0.2.0-alpha.4
.slice()
now take a fixed size array of Si
as the slice description. This allows more type checking to verify that the
number of axes is correct.rblas
integration.into_shape()
which allows reshaping any array or view kind.0.2.0-alpha.3
0.2.0-alpha.2
.indexed()
on iterators. Changed Indexed
and added
ÌndexedMut
..as_slice(), .as_mut_slice()
0.2.0-alpha
ArrayBase
, OwnedArray
, ArrayView
, ArrayViewMut
Array
continues to refer to the default reference counted copy on write
array.view()
, .view_mut()
, .to_owned()
, .into_shared()
.slice_mut()
, .subview_mut()
Some operations now return OwnedArray
:
.map()
.sum()
.mean()
Add get
, get_mut
to replace the now deprecated at
, at_mut
.
0.1.1
0.1.0
0.1.0
0.2.0
0.1.0
Dual-licensed to be compatible with the Rust project.
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.