Skip to content

Ready for 0.10 #117

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 34 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,65 @@
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)
- [Netlib](https://github.com/cmr/netlib-src)
- 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

```
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion examples/eigh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down