#matrix #lapack #ndarray

ndarray-linalg

Linear algebra package for rust-ndarray using LAPACK

40 releases

0.16.0 Oct 4, 2022
0.14.1 Aug 14, 2021
0.14.0 Jul 17, 2021
0.13.1 Mar 13, 2021
0.1.5 Nov 28, 2016

#48 in Algorithms

Download history 4336/week @ 2024-08-13 4068/week @ 2024-08-20 5734/week @ 2024-08-27 5225/week @ 2024-09-03 4099/week @ 2024-09-10 3972/week @ 2024-09-17 5742/week @ 2024-09-24 4555/week @ 2024-10-01 4877/week @ 2024-10-08 5057/week @ 2024-10-15 4229/week @ 2024-10-22 5015/week @ 2024-10-29 4539/week @ 2024-11-05 4362/week @ 2024-11-12 4861/week @ 2024-11-19 3761/week @ 2024-11-26

18,416 downloads per month
Used in 102 crates (87 directly)

MIT/Apache

355KB
8K SLoC

ndarray-linalg

crate docs.rs master

Linear algebra package for Rust with ndarray based on external LAPACK implementations.

Examples

See examples directory.

Note: To run examples, you must specify which backend will be used (as described below). For example, you can execute the solve example with the OpenBLAS backend like this:

cargo run --example solve --features=openblas

and run all tests of ndarray-linalg with OpenBLAS

cargo test --features=openblas

Backend Features

There are three LAPACK source crates:

ndarray_linalg must link just one of them for LAPACK FFI.

[dependencies]
ndarray = "0.14"
ndarray-linalg = { version = "0.13", features = ["openblas-static"] }

Supported features are following:

Feature Link type Requirements Description
openblas-static static gcc, gfortran, make Build OpenBLAS in your project, and link it statically
openblas-system dynamic/static libopenblas-dev Seek OpenBLAS in system, and link it
netlib-static static gfortran, make Same as openblas-static except for using reference LAPACK
netlib-system dynamic/static liblapack-dev Same as openblas-system except for using reference LAPACK
intel-mkl-static static (pkg-config) Seek static library of Intel MKL from system, or download if not found, and link it statically
intel-mkl-system dynamic (pkg-config) Seek shared library of Intel MKL from system, and link it dynamically
  • You must use just one feature of them.
  • dynamic/static means it depends on what is found in the system. When the system has /usr/lib/libopenblas.so, it will be linked dynamically, and /usr/lib/libopenblas.a will be linked statically. Dynamic linking is prior to static linking.
  • Requirements notices:
    • gcc and gfortran can be another compiler, e.g. icc and ifort.
    • libopenblas-dev is package name in Debian, Ubuntu, and other derived distributions. There are several binary packages of OpenBLAS, i.e. libopenblas-{openmp,pthread,serial}-dev. It can be other names in other distributions, e.g. Fedora, ArchLinux, and so on.
    • pkg-config is used for searching Intel MKL packages in system, and it is optional. See intel-mkl-src/README.md for detail.

For library developer

If you creating a library depending on this crate, we encourage you not to link any backend:

[dependencies]
ndarray = "0.13"
ndarray-linalg = "0.12"

The cargo's feature is additive. If your library (saying lib1) set a feature openblas-static, the application using lib1 builds ndarray_linalg with openblas-static feature though they want to use intel-mkl-static backend.

See the cargo reference for detail

Tested Environments

Only x86_64 system is supported currently.

Backend Linux Windows macOS
OpenBLAS ✔️ - -
Netlib ✔️ - -
Intel MKL ✔️ ✔️ ✔️

License

CAUTION Be sure that if you use intel-mkl-src backend, you have to accept Intel Simplified Software License in addition to the MIT-License or Apache-2.0 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.

Dependencies

~70MB
~877K SLoC