The Matrix and ndarray

Learn how to use ndarray to model matrix operations in Rust.

What is ndarray and why it’s useful

The Rust crate ndarray is used to work with arrays. It covers all the classic uses of an array-handling framework, such as numpy for Python.

Some use cases that are not covered by the main crate are covered by corollary crates, such as ndarray-linalg for linear algebra, ndarray-rand to generate randomness, and ndarray-stats for statistics.

Additionally, ndarray also has some nice extra features. These include support for rayon for parallelization and the popular BLAS low-level specs, through one of the working backends (using blas-src).

We can add ndarray to our project with the following command in Cargo.toml:

[dependencies]
ndarray = "0.14.0"

Create a free account to view this lesson.

Continue your learning journey with a 14-day free trial.

By signing up, you agree to Educative's Terms of Service and Privacy Policy