Skip to content

Commit 36d59d3

Browse files
committed
Merge branch 'master' into static-srcs
2 parents dacb84f + 34f7b99 commit 36d59d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+3649
-2480
lines changed

.github/workflows/intel-mkl.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
with:
2222
command: test
2323
args: >
24+
--manifest-path=ndarray-linalg/Cargo.toml
2425
--no-default-features
2526
--features=${{ matrix.feature }}
2627
@@ -38,6 +39,7 @@ jobs:
3839
with:
3940
command: test
4041
args: >
42+
--manifest-path=ndarray-linalg/Cargo.toml
4143
--no-default-features
4244
--features=${{ matrix.feature }}
4345
@@ -57,5 +59,6 @@ jobs:
5759
with:
5860
command: test
5961
args: >
62+
--manifest-path=ndarray-linalg/Cargo.toml
6063
--no-default-features
6164
--features=${{ matrix.feature }}

.github/workflows/netlib.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
with:
3131
command: test
3232
args: >
33+
--manifest-path=ndarray-linalg/Cargo.toml
3334
--no-default-features
3435
--features=netlib-${{ matrix.feature }}
3536
@@ -51,5 +52,6 @@ jobs:
5152
with:
5253
command: test
5354
args: >
55+
--manifest-path=ndarray-linalg/Cargo.toml
5456
--no-default-features
5557
--features=netlib-${{ matrix.feature }}

.github/workflows/openblas.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
with:
3131
command: test
3232
args: >
33+
--manifest-path=ndarray-linalg/Cargo.toml
3334
--no-default-features
3435
--features=openblas-${{ matrix.feature }}
3536
@@ -51,5 +52,6 @@ jobs:
5152
with:
5253
command: test
5354
args: >
55+
--manifest-path=ndarray-linalg/Cargo.toml
5456
--no-default-features
5557
--features=openblas-${{ matrix.feature }}

.github/workflows/rust.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,11 @@ jobs:
1515
with:
1616
command: fmt
1717
args: -- --check
18+
19+
clippy:
20+
runs-on: ubuntu-18.04
21+
steps:
22+
- uses: actions/checkout@v1
23+
- uses: actions-rs/cargo@v1
24+
with:
25+
command: clippy

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Generated by Cargo
22
# will have compiled files and executables
3-
/target/
3+
target/
44
*.rustfmt
55
rusty-tags.*
66

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
Unreleased
22
-----------
33

4+
Added
5+
------
6+
- lax sub-crate from `ndarray_linalg::lapack` https://github.com/rust-ndarray/ndarray-linalg/pull/207
7+
- cargo-workspace https://github.com/rust-ndarray/ndarray-linalg/pull/209
8+
9+
Changed
10+
--------
11+
- Named struct for `MatrixLayout` https://github.com/rust-ndarray/ndarray-linalg/pull/211
12+
- Split LAPACK error into computational failure and invalid values https://github.com/rust-ndarray/ndarray-linalg/pull/210
13+
- Use thiserror crate https://github.com/rust-ndarray/ndarray-linalg/pull/208
14+
- Fix for clippy, and add CI check https://github.com/rust-ndarray/ndarray-linalg/pull/205
15+
416
0.12.1 - 28 June 2020
517
----------------------
618

Cargo.toml

Lines changed: 5 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,5 @@
1-
[package]
2-
name = "ndarray-linalg"
3-
version = "0.13.0-alpha.0"
4-
authors = ["Toshiki Teramura <[email protected]>"]
5-
edition = "2018"
6-
7-
description = "Linear algebra package for rust-ndarray using LAPACK"
8-
documentation = "https://docs.rs/ndarray-linalg/"
9-
repository = "https://github.com/rust-ndarray/ndarray-linalg"
10-
keywords = ["ndarray", "lapack", "matrix"]
11-
license = "MIT"
12-
readme = "README.md"
13-
categories = ["algorithms", "science"]
14-
15-
[features]
16-
default = []
17-
18-
netlib = ["netlib-static"]
19-
openblas = ["openblas-static"]
20-
intel-mkl = ["mkl-static-lp64-seq"]
21-
22-
netlib-static = ["netlib-src/static"]
23-
netlib-system = ["netlib-src/system"]
24-
openblas-static = ["openblas-src/static"]
25-
openblas-system = ["openblas-src/system"]
26-
27-
mkl-static-lp64-iomp = ["intel-mkl-src/mkl-static-lp64-iomp"]
28-
mkl-static-lp64-seq = ["intel-mkl-src/mkl-static-lp64-seq"]
29-
mkl-dynamic-lp64-iomp = ["intel-mkl-src/mkl-dynamic-lp64-iomp"]
30-
mkl-dynamic-lp64-seq = ["intel-mkl-src/mkl-dynamic-lp64-seq"]
31-
32-
[dependencies]
33-
cauchy = "0.2.2"
34-
lapacke = "0.2.0"
35-
ndarray = { version = "0.13", features = ["blas", "approx", "serde-1"], default-features = false }
36-
num-complex = { version = "0.2", features = ["serde"] }
37-
num-traits = "0.2.11"
38-
rand = "0.5"
39-
40-
openblas-src = { version = "0.9.0", optional = true }
41-
netlib-src = { version = "0.8.0", optional = true }
42-
intel-mkl-src = { version = "0.6.0", default-features = false, features = ["download"], optional = true }
43-
44-
[dev-dependencies]
45-
paste = "0.1.9"
46-
criterion = "0.3.1"
47-
approx = { version = "0.3.2", features = ["num-complex"] }
48-
49-
[[bench]]
50-
name = "truncated_eig"
51-
harness = false
52-
53-
[[bench]]
54-
name = "eigh"
55-
harness = false
56-
57-
[package.metadata.docs.rs]
58-
rustdoc-args = ["--html-in-header", "katex-header.html"]
1+
[workspace]
2+
members = [
3+
"ndarray-linalg",
4+
"lax",
5+
]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ ndarray-linalg = { version = "0.12", features = ["openblas"] }
4545

4646
|Backend | Linux | Windows | macOS |
4747
|:--------|:-----:|:-------:|:-----:|
48-
|OpenBLAS |✔️ |- |✔️ |
49-
|Netlib |✔️ |- |✔️ |
48+
|OpenBLAS |✔️ |- |- |
49+
|Netlib |✔️ |- |- |
5050
|Intel MKL|✔️ |✔️ |✔️ |
5151

5252
### For librarian

lax/Cargo.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[package]
2+
name = "lax"
3+
version = "0.1.0"
4+
authors = ["Toshiki Teramura <[email protected]>"]
5+
edition = "2018"
6+
7+
[features]
8+
default = []
9+
10+
netlib = ["netlib-static"]
11+
openblas = ["openblas-static"]
12+
intel-mkl = ["mkl-static-lp64-seq"]
13+
14+
netlib-static = ["netlib-src/static"]
15+
netlib-system = ["netlib-src/system"]
16+
openblas-static = ["openblas-src/static"]
17+
openblas-system = ["openblas-src/system"]
18+
19+
mkl-static-lp64-iomp = ["intel-mkl-src/mkl-static-lp64-iomp"]
20+
mkl-static-lp64-seq = ["intel-mkl-src/mkl-static-lp64-seq"]
21+
mkl-dynamic-lp64-iomp = ["intel-mkl-src/mkl-dynamic-lp64-iomp"]
22+
mkl-dynamic-lp64-seq = ["intel-mkl-src/mkl-dynamic-lp64-seq"]
23+
24+
[dependencies]
25+
thiserror = "1.0"
26+
cauchy = "0.2.0"
27+
num-traits = "0.2"
28+
lapack = "0.16.0"
29+
30+
openblas-src = { version = "0.9.0", optional = true }
31+
netlib-src = { version = "0.8.0", optional = true }
32+
intel-mkl-src = { version = "0.6.0", default-features = false, features = ["download"], optional = true }

lax/src/cholesky.rs

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
//! Cholesky decomposition
2+
3+
use super::*;
4+
use crate::{error::*, layout::*};
5+
use cauchy::*;
6+
7+
pub trait Cholesky_: Sized {
8+
/// Cholesky: wrapper of `*potrf`
9+
///
10+
/// **Warning: Only the portion of `a` corresponding to `UPLO` is written.**
11+
fn cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()>;
12+
13+
/// Wrapper of `*potri`
14+
///
15+
/// **Warning: Only the portion of `a` corresponding to `UPLO` is written.**
16+
fn inv_cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()>;
17+
18+
/// Wrapper of `*potrs`
19+
fn solve_cholesky(l: MatrixLayout, uplo: UPLO, a: &[Self], b: &mut [Self]) -> Result<()>;
20+
}
21+
22+
macro_rules! impl_cholesky {
23+
($scalar:ty, $trf:path, $tri:path, $trs:path) => {
24+
impl Cholesky_ for $scalar {
25+
fn cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> {
26+
let (n, _) = l.size();
27+
if matches!(l, MatrixLayout::C { .. }) {
28+
square_transpose(l, a);
29+
}
30+
let mut info = 0;
31+
unsafe {
32+
$trf(uplo as u8, n, a, n, &mut info);
33+
}
34+
info.as_lapack_result()?;
35+
if matches!(l, MatrixLayout::C { .. }) {
36+
square_transpose(l, a);
37+
}
38+
Ok(())
39+
}
40+
41+
fn inv_cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> {
42+
let (n, _) = l.size();
43+
if matches!(l, MatrixLayout::C { .. }) {
44+
square_transpose(l, a);
45+
}
46+
let mut info = 0;
47+
unsafe {
48+
$tri(uplo as u8, n, a, l.lda(), &mut info);
49+
}
50+
info.as_lapack_result()?;
51+
if matches!(l, MatrixLayout::C { .. }) {
52+
square_transpose(l, a);
53+
}
54+
Ok(())
55+
}
56+
57+
fn solve_cholesky(
58+
l: MatrixLayout,
59+
mut uplo: UPLO,
60+
a: &[Self],
61+
b: &mut [Self],
62+
) -> Result<()> {
63+
let (n, _) = l.size();
64+
let nrhs = 1;
65+
let mut info = 0;
66+
if matches!(l, MatrixLayout::C { .. }) {
67+
uplo = uplo.t();
68+
for val in b.iter_mut() {
69+
*val = val.conj();
70+
}
71+
}
72+
unsafe {
73+
$trs(uplo as u8, n, nrhs, a, l.lda(), b, n, &mut info);
74+
}
75+
info.as_lapack_result()?;
76+
if matches!(l, MatrixLayout::C { .. }) {
77+
for val in b.iter_mut() {
78+
*val = val.conj();
79+
}
80+
}
81+
Ok(())
82+
}
83+
}
84+
};
85+
} // end macro_rules
86+
87+
impl_cholesky!(f64, lapack::dpotrf, lapack::dpotri, lapack::dpotrs);
88+
impl_cholesky!(f32, lapack::spotrf, lapack::spotri, lapack::spotrs);
89+
impl_cholesky!(c64, lapack::zpotrf, lapack::zpotri, lapack::zpotrs);
90+
impl_cholesky!(c32, lapack::cpotrf, lapack::cpotri, lapack::cpotrs);

0 commit comments

Comments
 (0)