ndarray

Library Featured

An n-dimensional array for general elements and for numerics. Lightweight array views and slicing; views support chunking and splitting.

Checked · Sources

Downloads
13,748,379
Dependents
2,888
Stars
4,344
Forks
394
Contributors
115
Commits
3,360
Latest release
0.17.2 ·

About

From the project README ·

The ndarray crate provides an n-dimensional container for general elements and for numerics.

Please read the API documentation on docs.rs__ or take a look at the quickstart tutorial <./README-quick-start.md>_.

__ https://docs.rs/ndarray/

|build_status|_ |crates|_ |matrix-chat|_ |irc|_

.. |build_status| image:: https://github.com/rust-ndarray/ndarray/actions/workflows/ci.yaml/badge.svg :alt: CI build status .. _build_status: https://github.com/rust-ndarray/ndarray/actions

.. |crates| image:: https://img.shields.io/crates/v/ndarray.svg :alt: ndarray at crates.io .. _crates: https://crates.io/crates/ndarray

.. |matrix-chat| image:: https://img.shields.io/badge/Matrix-%23rust--sci%3Amatrix.org-lightgrey :alt: Matrix chat at #rust-sci:matrix.org .. _matrix-chat: https://matrix.to/#/#rust-sci:matrix.org

.. |irc| image:: https://img.shields.io/badge/IRC-%23rust--sci%20on%20OFTC-lightgrey :alt: IRC at #rust-sci on OFTC .. _irc: https://webchat.oftc.net/?channels=rust-sci

Read the full README

Highlights

  • Generic 1, 2, ..., n-dimensional arrays
  • Owned arrays and array views
  • Slicing, also with arbitrary step size, and negative indices to mean elements from the end of the axis.
  • Views and subviews of arrays; iterators that yield subviews.

Installation

From a shell in your project folder, run cargo add ndarray to add the latest version.

Status and Lookout

  • Still iterating on and evolving the crate

    • The crate is continuously developing, and breaking changes are expected during evolution from version to version. We adopt the newest stable rust features if we need them.
  • Performance:

    • Prefer higher order methods and arithmetic operations on arrays first, then iteration, and as a last priority using indexed algorithms.
    • Efficient floating point matrix multiplication even for very large matrices; can optionally use BLAS to improve it further.

Crate Feature Flags

The following crate feature flags are available. They are configured in your Cargo.toml.

  • std

    • Rust standard library (enabled by default)

    • This crate can be used without the standard library by disabling the default std feature. To do so, use this in your Cargo.toml:

      [dependencies] ndarray = { version = "0.x.y", default-features = false }

    • The geomspace linspace logspace range std var var_axis and std_axis methods are only available when std is enabled.

  • serde

    • Enables serialization support for serde 1.x
  • rayon

    • Enables parallel iterators, parallelized methods and par_azip!.
    • Implies std
  • approx

    • Implementations of traits from the [approx] crate.
  • blas

    • Enable transparent BLAS support for matrix multiplication. Uses blas-src for pluggable backend, which needs to be configured separately (see below).
  • matrixmultiply-threading

    • Enable the threading feature in the matrixmultiply package
  • portable-atomic-critical-section

    • Whether portable-atomic should use critical-section

How to enable BLAS integration

Blas integration is an optional add-on. Without BLAS, ndarray uses the matrixmultiply crate for matrix multiplication for f64 and f32 arrays (and it's always enabled as a fallback since it supports matrices of arbitrary strides in both dimensions).

Depend and link to blas-src directly to pick a blas provider. Ndarray presently requires a blas provider that provides the cblas-sys interface. If further feature selection is wanted or needed then you might need to depend directly on the backend crate's source too. The backend version must be the one that blas-src also depends on.

An example configuration using system openblas is shown below. Note that only end-user projects (not libraries) should select provider::

[dependencies]
ndarray = { version = "0.x.y", features = ["blas"] }
blas-src = { version = "0.10", features = ["openblas"] }
openblas-src = { version = "0.10", features = ["cblas", "system"] }

Using system-installed dependencies can save a long time building dependencies. An example configuration using (compiled) netlib is shown below anyway::

[dependencies]
ndarray = { version = "0.x.y", features = ["blas"] }
blas-src = { version = "0.10.0", default-features = false, features = ["netlib"] }

When this is done, your program must also link to blas_src by using it or explicitly including it in your code::

extern crate blas_src;

The following versions have been verified to work together. For ndarray 0.15 or later, there is no tight coupling to the blas-src version, so version selection is more flexible.

=========== ============ ================ ============== ndarray blas-src openblas-src netlib-src =========== ============ ================ ============== 0.16 0.10 0.10 0.8 0.15 0.8 0.10 0.8 0.15 0.7 0.9 0.8 0.14 0.6.1 0.9.0 0.13 0.2.0 0.6.0 =========== ============ ================ ==============


BLAS on MSRV

Although ndarray currently maintains an MSRV via rust-version, this is separate from the MSRV (either stated or real) of the various BLAS providers. So, while ndarray may be compatible with older toolchains, the BLAS providers it depends on may not be.

Recent Changes

See RELEASES.md <./RELEASES.md>_.

License

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.

Runs on
GPU support unknown
What shows it
  • no dependency or feature matches a backend row
Native code
Optional
  • Binds native code: cblas-sys (feature blas)
Python bindings
No Python binding crate found
License
Apache-2.0 OR MIT

Compare with similar projects

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days. ML Rust runs this catalogue, so its closest project always gets a row.

ndarray beside the projects that share a topic with it
ProjectDownloadsDependentsStarsLatest releaseRuns on (GPU)Native codeLicense
ndarray This page Featured

An n-dimensional array for general elements and for numerics. Lightweight array views and slicing; views support chunking and splitting.

13,748,379 downloads over 30 days 2,888 4,344 0.17.2 GPU support unknown Binds native code: cblas-sys (feature blas) Apache-2.0 OR MIT
nalgebra Featured

General-purpose linear algebra library with transformations and statically-sized or dynamically-sized matrices.

6,251,820 downloads over 30 days 2,119 4,810 0.35.0 GPU support unknown Binds native code: blas-sys, lapack-sys, defmt (feature defmt) Apache-2.0
ndarray-stats Featured

Statistical routines for the n-dimensional array data structures provided by ndarray.

592,313 downloads over 30 days 115 239 0.7.0 GPU support unknown No native code found Apache-2.0 OR MIT
basin Listed

Numerical optimization in pure Rust, with pluggable linear-algebra backends and WASM support.

22,519 downloads over 30 days 9 128 3.2.0 GPU support unknown Binds native code: blas-sys (feature nalgebra_latest-lapack), lapack-sys (feature nalgebra_latest-lapack) Apache-2.0 OR MIT
ndrustfft Listed

N-dimensional FFT, real-to-complex FFT and real-to-real DCT

10,619 downloads over 30 days 12 32 0.6.2 GPU support unknown No native code found MIT
numr Listed

The base for numerical code in Rust, in the role NumPy has in Python: n-dimensional tensors, linear algebra, FFT, statistics and autograd on CPU, CUDA and WebGPU. The backends use native kernels, with no cuBLAS, MKL or other vendor math library.

1,673 downloads over 30 days 7 59 0.15.2 CUDA, WebGPU Binds native code: ring (feature distributed) Apache-2.0
Why FeaturedIt passes every Featured gate.

What it meets

  • It has 881 active dependents and 645 new dependents in 365 days. Featured needs 11 active dependents or 9 new dependents in 365 days.
  • Active dependents are at 100% of their peak. Featured needs at least 50%.
  • Docs are present. The release commit or a manifest ties the crate to the repository.
  • No vulnerability advisory stays unpatched past the grace window. At least one version is neither a prerelease nor 0.0.x.
  • The last activity is on 23 Oct 2026, 17 days ago. The rules expect an update within 1200 days. Dormancy rule

Exact rules: Featured library. The check on applied thresholds version 9.

Every rule outcome, as the check records it
  • expected-interval: version 0.17.2 base 300, doubled for 13748379 downloads per month, doubled for 881.25 active users: E = 1200 days
  • dormancy: last activity 2026-10-23, 17 days ago, E = 1200: active
  • featured: featured: active_users 881.25, new_adopters 644.5, former_glory 1
Crates2 crates

Order: strongest tier first, then most downloads, then name, with unmeasured values last. A library counts downloads over 30 days. An app counts binary downloads per release. An app with none counts its crate downloads over 30 days.

Measurements and sources

Each signal row shows the raw value, its source and the fetch date. The Sources list gathers every distinct source on this page. Movement needs more history.

Sources6 sources
Adoption881 active dependents, 645 new dependents in 365 days1 not measured
Adoption measurements
SignalValueSourceFetchedCounts
Active dependents881.25crates.io database dumpYes
New dependents (365 days)644.5crates.io database dumpYes
Peak active dependents881.25crates.io database dumpYes
Active dependents as a share of the peak1crates.io database dumpYes
Binary downloads per releaseNot measuredYes
MaintenanceLatest human commit: 17 days ago3 not measured
Maintenance measurements
SignalValueSourceFetchedCounts
Latest human commit2026-10-23GitHub repositoryYes
Latest release2026-01-10crates.io database dumpYes
First release2015-12-20crates.io database dumpYes
Latest version0.17.2crates.io database dumpYes
Days the oldest outside issue waits for a reply518GitHub repositoryYes
Maintainer replies over 365 days100GitHub repositoryYes
Repository archivedfalseGitHub repositoryYes
Repository gonefalseGitHub repositoryYes
Release commit or manifest in the repotruecrates.io packageYes
Published docstruecrates.io database dumpYes
Latest release fails cargo checkNot measuredYes
Build check dateNot measuredYes
Build check toolchainNot measuredYes
SecurityUnpatched vulnerabilities: none
Security measurements
SignalValueSourceFetchedCounts
Unpatched vulnerabilities past the grace windownoneRustSec advisory databaseYes
RustSec unmaintained advisorynoneRustSec advisory databaseYes
Deprecation noticenonecrates.io database dumpYes
Deprecated requirementnonecrates.io database dumpYes
Distribution92 releases, 13,748,379 downloads over 30 days5 not measured
Distribution measurements
SignalValueSourceFetchedCounts
Releases92crates.io database dumpYes
Downloads over 30 days13748379crates.io database dumpYes
Binary downloads over the last 3 releasesNot measuredYes
Homebrew installs on request over 365 daysNot measuredYes
Repology repository familiesNot measuredYes
Docker pull growth over 90 daysNot measuredYes
Docker pulls at the growth baselineNot measuredYes
Every version a prereleasefalsecrates.io database dumpYes
Every version 0.0.xfalsecrates.io database dumpYes
Every version yankedfalsecrates.io database dumpYes
Crate deleted from crates.iofalsecrates.io database dumpYes
Repository4,344 stars, 394 forks, 115 contributors, 3,360 commits. Stars alone never qualify a project.
Repository measurements
SignalValueSourceFetchedCounts
GitHub stars4344GitHub repositoryYes — one part of the repository route
GitHub forks394GitHub repositoryYes — one part of the repository route
Contributors with a GitHub account115GitHub contributorsYes — one part of the repository route
Commits on the default branch3360GitHub repositoryNo
Repository's main crate left out of the entrynonecrates.io database dumpYes
Facts that never count
Facts that never count measurements
SignalValueSourceFetchedCounts
LicenseApache-2.0 OR MITcrates.io database dumpNo
Runs on, from listed crates and their direct dependenciesGPU support unknowncrates.io database dumpNo
What shows each backendno dependency or feature matches a backend rowcrates.io database dumpNo
Native code, from listed crates and their dependenciesBinds native code: cblas-sys (feature blas)crates.io database dumpNo
Python bindings, from direct dependencies of listed cratesNo Python binding crate foundcrates.io database dumpNo
Crates that depend on a listed crate directly2888crates.io database dumpNo

Corrections and review history

Report a correction

No correction applies to this entry.

Judgments

A judgment enters only through an approved issue and a merged pull request.

No judgment applies to this entry.