Skip to content

Commit 7658a76

Browse files
committed
Merge branch 'update-lapack'
2 parents 5e33905 + ee1acc4 commit 7658a76

File tree

18 files changed

+145
-79
lines changed

18 files changed

+145
-79
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ Cargo.lock
1010

1111
# cargo fmt
1212
*.bk
13+
14+
# IntelliJ Rust
15+
.idea
16+
*.iml

Cargo.toml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ndarray-linalg"
3-
version = "0.7.1"
3+
version = "0.8.0"
44
authors = ["Toshiki Teramura <[email protected]>"]
55

66
description = "Linear algebra package for rust-ndarray using LAPACK"
@@ -12,35 +12,32 @@ readme = "README.md"
1212
categories = ["algorithms", "science"]
1313

1414
[features]
15-
default = ["openblas-static"]
16-
openblas-shared = ["lapack/openblas"]
17-
openblas-static = ["lapack/openblas", "openblas-src/static"]
18-
openblas-system = ["lapack/openblas", "openblas-src/system"]
19-
netlib-shared = ["lapack/netlib"]
20-
netlib-static = ["lapack/netlib", "netlib-src/static"]
21-
netlib-system = ["lapack/netlib", "netlib-src/system"]
22-
intel-mkl = ["intel-mkl-src"]
15+
default = []
16+
openblas = ["openblas-src"]
17+
netlib = ["netlib-src"]
18+
intel-mkl = ["intel-mkl-src"]
2319

2420
[dependencies]
2521
rand = "0.3"
26-
derive-new = "0.4"
22+
derive-new = "0.5"
2723
procedurals = "0.2"
2824
num-traits = "0.1"
29-
num-complex = "0.1"
30-
lapack = { version = "0.13", default-features = false }
31-
lapack-sys = { version = "0.11", default-features = false }
25+
num-complex = { version = "0.1", default-features = false }
26+
lapacke = "0.1.4"
3227

3328
[dependencies.ndarray]
3429
version = "0.10"
3530
default-features = false
3631

3732
[dependencies.openblas-src]
3833
version = "0.5.3"
34+
features = ["static", "cblas", "lapacke"]
3935
default-features = false
4036
optional = true
4137

4238
[dependencies.netlib-src]
4339
version = "0.7.0"
40+
features = ["static", "cblas", "lapacke", "tmg"]
4441
default-features = false
4542
optional = true
4643

README.md

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,58 @@ ndarray-linalg
44
[![docs.rs](https://docs.rs/ndarray-linalg/badge.svg)](https://docs.rs/ndarray-linalg)
55
[![wercker status](https://app.wercker.com/status/f04aeba682ea6e79577e15bd946344a5/s/master "wercker status")](https://app.wercker.com/project/byKey/f04aeba682ea6e79577e15bd946344a5)
66

7-
Linear algebra package for Rust.
7+
Linear algebra package for Rust with [rust-ndarray](https://github.com/bluss/rust-ndarray).
88

9-
Dependencies
10-
-------------
9+
LAPACKE Backend
10+
----------------
1111

12-
- [bluss/rust-ndarray](https://github.com/bluss/rust-ndarray)
13-
- [stainless-steel/lapack](https://github.com/stainless-steel/lapack)
14-
15-
and more (See Cargo.toml).
16-
17-
Feature flags
18-
--------------
12+
Currently three LAPACKE implementations are supported and tested:
1913

2014
- [OpenBLAS](https://github.com/cmr/openblas-src)
21-
- `openblas-static`: use OpenBLAS with static link (default)
22-
- `openblas-shared`: use OpenBLAS with shared link
23-
- `openblas-system`: use system OpenBLAS (experimental)
2415
- [Netlib](https://github.com/cmr/netlib-src)
25-
- `netlib-static`: use Netlib with static link (default)
26-
- `netlib-shared`: use Netlib with shared link
27-
- `netlib-system`: use system Netlib (experimental)
2816
- [Intel MKL](https://github.com/termoshtt/rust-intel-mkl) (non-free license, see the linked page)
29-
- `intel-mkl`: use Intel MKL shared link (experimental)
17+
18+
There are two ways to link LAPACKE backend:
19+
20+
### backend features (recommended)
21+
There are three features corresponding to the backend implementations (`openblas` / `netlib` / `intel-mkl`):
22+
23+
```toml
24+
[depencdencies]
25+
ndarray = "0.10"
26+
ndarray-linalg = { version = "0.8", features = ["openblas"] }
27+
```
28+
29+
### link backend crate manually
30+
For the sake of linking flexibility, you can provide LAPACKE implementation (as an `extern crate`) yourself.
31+
You should link a LAPACKE implementation to a final crate (like binary executable or dylib) only, not to a Rust library.
32+
33+
```toml
34+
[depencdencies]
35+
ndarray = "0.10"
36+
ndarray-linalg = "0.8"
37+
openblas-src = "0.5" # or another backend of your choice
38+
39+
```
40+
41+
You must add `extern crate` to your code in this case:
42+
43+
```rust
44+
extern crate ndarray;
45+
extern crate ndarray_linalg;
46+
extern crate openblas_src; // or another backend of your choice
47+
```
48+
49+
### For librarian
50+
If you creating a library depending on this crate, we encourage you not to link any backend for flexibility:
51+
52+
```toml
53+
[depencdencies]
54+
ndarray = "0.10"
55+
ndarray-linalg = { version = "0.8", default-features = false }
56+
```
57+
58+
However, if you hope simplicity instead of the flexibility, you can link your favorite backend in the way described above.
3059

3160
Examples
3261
---------

examples/eigh.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
extern crate ndarray;
33
extern crate ndarray_linalg;
4+
#[cfg(feature = "lapack-src")]
5+
extern crate lapack_src;
46

57
use ndarray::*;
68
use ndarray_linalg::*;

examples/solve.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
extern crate ndarray;
33
extern crate ndarray_linalg;
4+
#[cfg(feature = "lapack-src")]
5+
extern crate lapack_src;
46

57
use ndarray::*;
68
use ndarray_linalg::*;

examples/solveh.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11

22
extern crate ndarray;
33
extern crate ndarray_linalg;
4+
#[cfg(feature = "lapack-src")]
5+
extern crate lapack_src;
46

57
use ndarray::*;
68
use ndarray_linalg::*;

src/lapack_traits/cholesky.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Cholesky decomposition
22
3-
use lapack::c;
3+
use lapacke;
44

55
use error::*;
66
use layout::MatrixLayout;
@@ -46,7 +46,7 @@ impl Cholesky_ for $scalar {
4646
}
4747
}} // end macro_rules
4848

49-
impl_cholesky!(f64, c::dpotrf, c::dpotri, c::dpotrs);
50-
impl_cholesky!(f32, c::spotrf, c::spotri, c::spotrs);
51-
impl_cholesky!(c64, c::zpotrf, c::zpotri, c::zpotrs);
52-
impl_cholesky!(c32, c::cpotrf, c::cpotri, c::cpotrs);
49+
impl_cholesky!(f64, lapacke::dpotrf, lapacke::dpotri, lapacke::dpotrs);
50+
impl_cholesky!(f32, lapacke::spotrf, lapacke::spotri, lapacke::spotrs);
51+
impl_cholesky!(c64, lapacke::zpotrf, lapacke::zpotri, lapacke::zpotrs);
52+
impl_cholesky!(c32, lapacke::cpotrf, lapacke::cpotri, lapacke::cpotrs);

src/lapack_traits/eigh.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Eigenvalue decomposition for Hermite matrices
22
3-
use lapack::c;
3+
use lapacke;
44
use num_traits::Zero;
55

66
use error::*;
@@ -27,7 +27,7 @@ impl Eigh_ for $scalar {
2727
}
2828
}} // impl_eigh!
2929

30-
impl_eigh!(f64, c::dsyev);
31-
impl_eigh!(f32, c::ssyev);
32-
impl_eigh!(c64, c::zheev);
33-
impl_eigh!(c32, c::cheev);
30+
impl_eigh!(f64, lapacke::dsyev);
31+
impl_eigh!(f32, lapacke::ssyev);
32+
impl_eigh!(c64, lapacke::zheev);
33+
impl_eigh!(c32, lapacke::cheev);

src/lapack_traits/opnorm.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Operator norms of matrices
22
3-
use lapack::c;
4-
use lapack::c::Layout::ColumnMajor as cm;
3+
use lapacke;
4+
use lapacke::Layout::ColumnMajor as cm;
55

66
use layout::MatrixLayout;
77
use types::*;
@@ -24,7 +24,7 @@ impl OperatorNorm_ for $scalar {
2424
}
2525
}} // impl_opnorm!
2626

27-
impl_opnorm!(f64, c::dlange);
28-
impl_opnorm!(f32, c::slange);
29-
impl_opnorm!(c64, c::zlange);
30-
impl_opnorm!(c32, c::clange);
27+
impl_opnorm!(f64, lapacke::dlange);
28+
impl_opnorm!(f32, lapacke::slange);
29+
impl_opnorm!(c64, lapacke::zlange);
30+
impl_opnorm!(c32, lapacke::clange);

src/lapack_traits/qr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! QR decomposition
22
3-
use lapack::c;
3+
use lapacke;
44
use num_traits::Zero;
55
use std::cmp::min;
66

@@ -44,7 +44,7 @@ impl QR_ for $scalar {
4444
}
4545
}} // endmacro
4646

47-
impl_qr!(f64, c::dgeqrf, c::dorgqr);
48-
impl_qr!(f32, c::sgeqrf, c::sorgqr);
49-
impl_qr!(c64, c::zgeqrf, c::zungqr);
50-
impl_qr!(c32, c::cgeqrf, c::cungqr);
47+
impl_qr!(f64, lapacke::dgeqrf, lapacke::dorgqr);
48+
impl_qr!(f32, lapacke::sgeqrf, lapacke::sorgqr);
49+
impl_qr!(c64, lapacke::zgeqrf, lapacke::zungqr);
50+
impl_qr!(c32, lapacke::cgeqrf, lapacke::cungqr);

0 commit comments

Comments
 (0)