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

+4
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

+8-28
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

+25-10
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

+2
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

+2
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

+2
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

+1-1
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

+5-5
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

+5-5
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

+6-6
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

+5-5
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);

src/lapack_traits/solve.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Solve linear problem using LU decomposition
22
3-
use lapack::c;
3+
use lapacke;
44

55
use error::*;
66
use layout::MatrixLayout;
@@ -65,7 +65,7 @@ impl Solve_ for $scalar {
6565

6666
}} // impl_solve!
6767

68-
impl_solve!(f64, c::dgetrf, c::dgetri, c::dgecon, c::dgetrs);
69-
impl_solve!(f32, c::sgetrf, c::sgetri, c::sgecon, c::sgetrs);
70-
impl_solve!(c64, c::zgetrf, c::zgetri, c::zgecon, c::zgetrs);
71-
impl_solve!(c32, c::cgetrf, c::cgetri, c::cgecon, c::cgetrs);
68+
impl_solve!(f64, lapacke::dgetrf, lapacke::dgetri, lapacke::dgecon, lapacke::dgetrs);
69+
impl_solve!(f32, lapacke::sgetrf, lapacke::sgetri, lapacke::sgecon, lapacke::sgetrs);
70+
impl_solve!(c64, lapacke::zgetrf, lapacke::zgetri, lapacke::zgecon, lapacke::zgetrs);
71+
impl_solve!(c32, lapacke::cgetrf, lapacke::cgetri, lapacke::cgecon, lapacke::cgetrs);

src/lapack_traits/solveh.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//!
33
//! See also [the manual of dsytrf](http://www.netlib.org/lapack/lapack-3.1.1/html/dsytrf.f.html)
44
5-
use lapack::c;
5+
use lapacke;
66

77
use error::*;
88
use layout::MatrixLayout;
@@ -55,7 +55,7 @@ impl Solveh_ for $scalar {
5555

5656
}} // impl_solveh!
5757

58-
impl_solveh!(f64, c::dsytrf, c::dsytri, c::dsytrs);
59-
impl_solveh!(f32, c::ssytrf, c::ssytri, c::ssytrs);
60-
impl_solveh!(c64, c::zhetrf, c::zhetri, c::zhetrs);
61-
impl_solveh!(c32, c::chetrf, c::chetri, c::chetrs);
58+
impl_solveh!(f64, lapacke::dsytrf, lapacke::dsytri, lapacke::dsytrs);
59+
impl_solveh!(f32, lapacke::ssytrf, lapacke::ssytri, lapacke::ssytrs);
60+
impl_solveh!(c64, lapacke::zhetrf, lapacke::zhetri, lapacke::zhetrs);
61+
impl_solveh!(c32, lapacke::chetrf, lapacke::chetri, lapacke::chetrs);

src/lapack_traits/svd.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Singular-value decomposition
22
3-
use lapack::c;
3+
use lapacke;
44
use num_traits::Zero;
55

66
use error::*;
@@ -63,7 +63,7 @@ impl SVD_ for $scalar {
6363

6464
}} // impl_svd!
6565

66-
impl_svd!(f64, c::dgesvd);
67-
impl_svd!(f32, c::sgesvd);
68-
impl_svd!(c64, c::zgesvd);
69-
impl_svd!(c32, c::cgesvd);
66+
impl_svd!(f64, lapacke::dgesvd);
67+
impl_svd!(f32, lapacke::sgesvd);
68+
impl_svd!(c64, lapacke::zgesvd);
69+
impl_svd!(c32, lapacke::cgesvd);

src/lapack_traits/triangular.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Implement linear solver and inverse matrix
22
3-
use lapack::c;
3+
use lapacke;
44

55
use super::{Transpose, UPLO, into_result};
66
use error::*;
@@ -50,7 +50,7 @@ impl Triangular_ for $scalar {
5050

5151
}} // impl_triangular!
5252

53-
impl_triangular!(f64, c::dtrtri, c::dtrtrs);
54-
impl_triangular!(f32, c::strtri, c::strtrs);
55-
impl_triangular!(c64, c::ztrtri, c::ztrtrs);
56-
impl_triangular!(c32, c::ctrtri, c::ctrtrs);
53+
impl_triangular!(f64, lapacke::dtrtri, lapacke::dtrtrs);
54+
impl_triangular!(f32, lapacke::strtri, lapacke::strtrs);
55+
impl_triangular!(c64, lapacke::ztrtri, lapacke::ztrtrs);
56+
impl_triangular!(c32, lapacke::ctrtri, lapacke::ctrtrs);

src/layout.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Memory layout of matrices
22
3-
use lapack::c;
3+
use lapacke;
44
use ndarray::*;
55

66
use super::error::*;
@@ -44,10 +44,10 @@ impl MatrixLayout {
4444
}
4545
}
4646

47-
pub fn lapacke_layout(&self) -> c::Layout {
47+
pub fn lapacke_layout(&self) -> lapacke::Layout {
4848
match *self {
49-
MatrixLayout::C(_) => c::Layout::RowMajor,
50-
MatrixLayout::F(_) => c::Layout::ColumnMajor,
49+
MatrixLayout::C(_) => lapacke::Layout::RowMajor,
50+
MatrixLayout::F(_) => lapacke::Layout::ColumnMajor,
5151
}
5252
}
5353

src/lib.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@
1717
//! - [generator functions](generate/index.html)
1818
//! - [Scalar trait](types/trait.Scalar.html)
1919
20-
extern crate lapack;
21-
extern crate lapack_sys;
20+
extern crate lapacke;
2221
extern crate num_traits;
2322
extern crate num_complex;
2423
extern crate rand;
@@ -29,8 +28,8 @@ extern crate procedurals;
2928
#[macro_use]
3029
extern crate derive_new;
3130

32-
#[cfg(feature = "intel-mkl")]
33-
extern crate intel_mkl_src;
31+
//#[cfg(feature = "intel-mkl")]
32+
//extern crate intel_mkl_src;
3433

3534
pub mod assert;
3635
pub mod cholesky;

src/solve.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//!
55
//! Solve `A * x = b`:
66
//!
7-
//! ```
7+
//! ```no_run
88
//! #[macro_use]
99
//! extern crate ndarray;
1010
//! extern crate ndarray_linalg;
@@ -28,9 +28,10 @@
2828
//! coefficient matrix `A`, it's faster to compute the LU factorization once at
2929
//! the beginning than solving directly using `A`:
3030
//!
31-
//! ```
31+
//! ```no_run
3232
//! # extern crate ndarray;
3333
//! # extern crate ndarray_linalg;
34+
//!
3435
//! use ndarray::prelude::*;
3536
//! use ndarray_linalg::*;
3637
//! # fn main() {

src/solveh.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//!
88
//! Solve `A * x = b`, where `A` is a Hermitian (or real symmetric) matrix:
99
//!
10-
//! ```
10+
//! ```no_run
1111
//! #[macro_use]
1212
//! extern crate ndarray;
1313
//! extern crate ndarray_linalg;
@@ -32,7 +32,7 @@
3232
//! Hermitian or real symmetric coefficient matrix `A`, it's faster to compute
3333
//! the factorization once at the beginning than solving directly using `A`:
3434
//!
35-
//! ```
35+
//! ```no_run
3636
//! # extern crate ndarray;
3737
//! # extern crate ndarray_linalg;
3838
//! use ndarray::prelude::*;

0 commit comments

Comments
 (0)