Skip to content

Commit 2dcb205

Browse files
committed
Migrate to lapacke library
Also bumped version to 0.8
1 parent 29c4228 commit 2dcb205

38 files changed

+135
-94
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: 8 additions & 28 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"
@@ -11,40 +11,20 @@ license = "MIT"
1111
readme = "README.md"
1212
categories = ["algorithms", "science"]
1313

14-
[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"]
23-
2414
[dependencies]
2515
rand = "0.3"
2616
derive-new = "0.5"
2717
procedurals = "0.2"
2818
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 }
19+
num-complex = { version = "0.1", default-features = false }
20+
lapacke = "0.1.4"
21+
lapack-src = { git = "https://github.com/alexbool/lapack-src", rev = "da33354", optional = true }
3222

3323
[dependencies.ndarray]
3424
version = "0.10"
3525
default-features = false
3626

37-
[dependencies.openblas-src]
38-
version = "0.5.3"
39-
default-features = false
40-
optional = true
41-
42-
[dependencies.netlib-src]
43-
version = "0.7.0"
44-
default-features = false
45-
optional = true
46-
47-
[dependencies.intel-mkl-src]
48-
version = "0.2.5"
49-
default-features = false
50-
optional = true
27+
[features]
28+
openblas = ["lapack-src", "lapack-src/openblas"]
29+
netlib = ["lapack-src", "lapack-src/netlib"]
30+
intel-mkl = ["lapack-src", "lapack-src/intel-mkl"]

README.md

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,38 @@ Dependencies
1010
-------------
1111

1212
- [bluss/rust-ndarray](https://github.com/bluss/rust-ndarray)
13-
- [stainless-steel/lapack](https://github.com/stainless-steel/lapack)
13+
- [blas-lapack-rs/lapacke](https://github.com/blas-lapack-rs/lapacke)
1414

1515
and more (See Cargo.toml).
1616

17-
Feature flags
18-
--------------
17+
Choosing LAPACKE implementation
18+
--------------------------------
19+
20+
For the sake of linking flexibility, you must provide LAPACKE implementation (as an `extern crate`) yourself.
21+
Currently three LAPACKE implementations are supported and tested:
1922

2023
- [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)
2424
- [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)
2825
- [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)
26+
27+
You should link a LAPACKE implementation to a final crate (like binary executable or dylib) only, not to a Rust library.
28+
Example:
29+
30+
`Cargo.toml`:
31+
```toml
32+
[depencdencies]
33+
ndarray = "0.10"
34+
ndarray-linalg = "0.8"
35+
openblas-src = "0.5" # or another backend of your choice
36+
37+
```
38+
39+
`main.rs`:
40+
```rust
41+
extern crate ndarray;
42+
extern crate ndarray_linalg;
43+
extern crate openblas_src; // or another backend of your choice
44+
```
3045

3146
Examples
3247
---------

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/cholesky.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! Using the Cholesky decomposition of `A` for various operations, where `A`
1010
//! is a Hermitian (or real symmetric) positive definite matrix:
1111
//!
12-
//! ```
12+
//! ```no_run
1313
//! #[macro_use]
1414
//! extern crate ndarray;
1515
//! extern crate 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);

0 commit comments

Comments
 (0)