diff --git a/README.md b/README.md index e6ba61a2..e2974186 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,32 @@ ndarray-linalg =============== +[![CircleCI](https://circleci.com/gh/termoshtt/ndarray-linalg.svg?style=shield)](https://circleci.com/gh/termoshtt/ndarray-linalg) [![Crate](http://meritbadge.herokuapp.com/ndarray-linalg)](https://crates.io/crates/ndarray-linalg) [![docs.rs](https://docs.rs/ndarray-linalg/badge.svg)](https://docs.rs/ndarray-linalg) -[![CircleCI](https://circleci.com/gh/termoshtt/ndarray-linalg.svg?style=shield)](https://circleci.com/gh/termoshtt/ndarray-linalg) -[![Gitter chat](https://badges.gitter.im/termoshtt-scirust/ndarray-linalg.png)](https://gitter.im/termoshtt-scirust/ndarray-linalg) -Linear algebra package for Rust with [rust-ndarray](https://github.com/bluss/rust-ndarray). +Linear algebra package for Rust with [ndarray](https://github.com/bluss/ndarray) based on external LAPACK implementations. + +Examples +--------- +See [examples](https://github.com/termoshtt/ndarray-linalg/tree/master/examples) directory. + +**Note**: To run examples, you must specify which backend will be used (as described below). +For example, you can execute the [solve](examples/solve.rs) example with the OpenBLAS backend like this: -LAPACKE Backend ----------------- +```sh +cargo run --example solve --features=openblas +``` -Currently three LAPACKE implementations are supported and tested: +and run all tests of ndarray-linalg with OpenBLAS + +```sh +cargo test --features=openblas +``` + +BLAS/LAPACK Backend +------------------- + +Three BLAS/LAPACK implementations are supported: - [OpenBLAS](https://github.com/cmr/openblas-src) - needs `gfortran` (or other Fortran compiler) @@ -18,25 +34,32 @@ Currently three LAPACKE implementations are supported and tested: - needs `cmake` and `gfortran` - [Intel MKL](https://github.com/termoshtt/rust-intel-mkl) (non-free license, see the linked page) - needs `curl` -There are two ways to link LAPACKE backend: -### backend features (recommended) There are three features corresponding to the backend implementations (`openblas` / `netlib` / `intel-mkl`): ```toml [dependencies] ndarray = "0.12" -ndarray-linalg = { version = "0.9", features = ["openblas"] } +ndarray-linalg = { version = "0.10", features = ["openblas"] } +``` + +### For librarian +If you creating a library depending on this crate, we encourage you not to link any backend: + +```toml +[dependencies] +ndarray = "0.12" +ndarray-linalg = "0.10" ``` -### link backend crate manually +### Link backend crate manually For the sake of linking flexibility, you can provide LAPACKE implementation (as an `extern crate`) yourself. You should link a LAPACKE implementation to a final crate (like binary executable or dylib) only, not to a Rust library. ```toml [dependencies] ndarray = "0.12" -ndarray-linalg = "0.9" +ndarray-linalg = "0.10" openblas-src = "0.5" # or another backend of your choice ``` @@ -48,35 +71,3 @@ extern crate ndarray; extern crate ndarray_linalg; extern crate openblas_src; // or another backend of your choice ``` - -### For librarian -If you creating a library depending on this crate, we encourage you not to link any backend for flexibility: - -```toml -[dependencies] -ndarray = "0.12" -ndarray-linalg = { version = "0.9", default-features = false } -``` - -However, if you hope simplicity instead of the flexibility, you can link your favorite backend in the way described above. - -### Tests and Examples - -To run tests or examples for `ndarray-linalg`, you must specify the desired -backend. For example, you can run the tests with the OpenBLAS backend like -this: - -```sh -cargo test --features=openblas -``` - -Examples ---------- -See [examples](https://github.com/termoshtt/ndarray-linalg/tree/master/examples) directory. - -Note that to run an example, you must specify the desired backend. For example, -you can run the the `solve` example with the OpenBLAS backend like this: - -```sh -cargo run --example solve --features=openblas -``` diff --git a/examples/eigh.rs b/examples/eigh.rs index 622d82d3..c9bcc941 100644 --- a/examples/eigh.rs +++ b/examples/eigh.rs @@ -6,7 +6,7 @@ use ndarray_linalg::*; fn main() { let a = arr2(&[[3.0, 1.0, 1.0], [1.0, 3.0, 1.0], [1.0, 1.0, 3.0]]); - let (e, vecs): (Array1<_>, Array2<_>) = a.clone().eigh(UPLO::Upper).unwrap(); + let (e, vecs) = a.clone().eigh(UPLO::Upper).unwrap(); println!("eigenvalues = \n{:?}", e); println!("V = \n{:?}", vecs); let av = a.dot(&vecs);