Skip to content

Commit 33d4b1a

Browse files
committed
Merge branch 'master' into lapack
2 parents f4e5e81 + cb4f764 commit 33d4b1a

Some content is hidden

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

91 files changed

+836
-759
lines changed

.github/workflows/ndarray-linalg.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: ndarray-linalg
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request: {}
8+
9+
jobs:
10+
windows:
11+
runs-on: windows-2019
12+
steps:
13+
- uses: actions/checkout@v1
14+
- uses: actions-rs/cargo@v1
15+
with:
16+
command: test
17+
args: --manifest-path=ndarray-linalg/Cargo.toml --features=intel-mkl --no-default-features
18+
19+
macos:
20+
runs-on: macos-10.15
21+
env:
22+
CC: gcc-9
23+
FC: gfortran-9
24+
LIBRARY_PATH: /usr/local/opt/gcc/lib/gcc/9
25+
strategy:
26+
fail-fast: false
27+
matrix:
28+
feature:
29+
- netlib
30+
- openblas
31+
- intel-mkl
32+
steps:
33+
- uses: actions/checkout@v1
34+
- uses: actions-rs/cargo@v1
35+
with:
36+
command: test
37+
args: --manifest-path=ndarray-linalg/Cargo.toml --features=${{ matrix.feature }} --no-default-features
38+
39+
linux:
40+
runs-on: ubuntu-18.04
41+
strategy:
42+
fail-fast: false
43+
matrix:
44+
feature:
45+
- netlib
46+
- openblas
47+
- intel-mkl
48+
steps:
49+
- uses: actions/checkout@v1
50+
- name: apt-install gfortran
51+
run: |
52+
sudo apt update
53+
sudo apt install -y gfortran
54+
if: ${{ matrix.feature != 'intel-mkl' }}
55+
- uses: actions-rs/cargo@v1
56+
with:
57+
command: test
58+
args: --manifest-path=ndarray-linalg/Cargo.toml --features=${{ matrix.feature }} --no-default-features

.github/workflows/rust.yml

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,6 @@ on:
77
pull_request: {}
88

99
jobs:
10-
windows:
11-
runs-on: windows-2019
12-
steps:
13-
- uses: actions/checkout@v1
14-
- uses: actions-rs/cargo@v1
15-
with:
16-
command: test
17-
args: --features=intel-mkl --no-default-features
18-
19-
macos:
20-
runs-on: macos-10.15
21-
env:
22-
CC: gcc-9
23-
FC: gfortran-9
24-
LIBRARY_PATH: /usr/local/opt/gcc/lib/gcc/9
25-
strategy:
26-
fail-fast: false
27-
matrix:
28-
feature:
29-
- netlib
30-
- openblas
31-
- intel-mkl
32-
steps:
33-
- uses: actions/checkout@v1
34-
- uses: actions-rs/cargo@v1
35-
with:
36-
command: test
37-
args: --features=${{ matrix.feature }} --no-default-features
38-
39-
linux:
40-
runs-on: ubuntu-18.04
41-
strategy:
42-
fail-fast: false
43-
matrix:
44-
feature:
45-
- netlib
46-
- openblas
47-
- intel-mkl
48-
steps:
49-
- uses: actions/checkout@v1
50-
- name: apt-install gfortran
51-
run: |
52-
sudo apt update
53-
sudo apt install -y gfortran
54-
if: ${{ matrix.feature != 'intel-mkl' }}
55-
- uses: actions-rs/cargo@v1
56-
with:
57-
command: test
58-
args: --features=${{ matrix.feature }} --no-default-features
59-
6010
check-format:
6111
runs-on: ubuntu-18.04
6212
steps:

.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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Unreleased
33

44
Changed
55
--------
6+
- Use thiserror crate https://github.com/rust-ndarray/ndarray-linalg/pull/208
67
- Fix for clippy, and add CI check https://github.com/rust-ndarray/ndarray-linalg/pull/205
78

89
0.12.1 - 28 June 2020

Cargo.toml

Lines changed: 5 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +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-
intel-mkl = ["lapack-src/intel-mkl", "blas-src/intel-mkl"]
18-
netlib = ["lapack-src/netlib", "blas-src/netlib"]
19-
openblas = ["lapack-src/openblas", "blas-src/openblas"]
20-
serde-1 = ["ndarray/serde-1", "num-complex/serde"]
21-
22-
static = ["openblas-static"]
23-
openblas-static = ["openblas", "openblas-src"]
24-
25-
[dependencies]
26-
lapacke = "0.2.0"
27-
num-traits = "0.2.11"
28-
cauchy = "0.2.2"
29-
num-complex = "0.2.4"
30-
rand = "0.5"
31-
lapack = "0.16.0"
32-
blas = "0.20.0"
33-
34-
[dependencies.ndarray]
35-
version = "0.13.0"
36-
features = ["blas", "approx"]
37-
default-features = false
38-
39-
[dependencies.blas-src]
40-
version = "0.6.1"
41-
default-features = false
42-
43-
[dependencies.lapack-src]
44-
version = "0.6.0"
45-
default-features = false
46-
47-
[dependencies.openblas-src]
48-
version = "0.9.0"
49-
default-features = false
50-
features = ["static"]
51-
optional = true
52-
53-
[dev-dependencies]
54-
paste = "0.1.9"
55-
criterion = "0.3.1"
56-
approx = { version = "0.3.2", features = ["num-complex"] }
57-
58-
[[bench]]
59-
name = "truncated_eig"
60-
harness = false
61-
62-
[[bench]]
63-
name = "eigh"
64-
harness = false
65-
66-
[package.metadata.docs.rs]
67-
rustdoc-args = ["--html-in-header", "katex-header.html"]
1+
[workspace]
2+
members = [
3+
"ndarray-linalg",
4+
"lax",
5+
]

lax/Cargo.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
intel-mkl = ["lapack-src/intel-mkl", "blas-src/intel-mkl"]
10+
netlib = ["lapack-src/netlib", "blas-src/netlib"]
11+
openblas = ["lapack-src/openblas", "blas-src/openblas"]
12+
13+
[dependencies]
14+
thiserror = "1"
15+
cauchy = "0.2"
16+
lapacke = "0.2.0"
17+
num-traits = "0.2"
18+
lapack = "0.16.0"
19+
blas = "0.20.0"
20+
21+
[dependencies.blas-src]
22+
version = "0.6.1"
23+
default-features = false
24+
25+
[dependencies.lapack-src]
26+
version = "0.6.0"
27+
default-features = false
28+
29+
[dependencies.openblas-src]
30+
version = "0.9.0"
31+
default-features = false
32+
features = ["static"]
33+
optional = true

src/lapack/cholesky.rs renamed to lax/src/cholesky.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
//! Cholesky decomposition
22
3-
use crate::error::*;
4-
use crate::layout::MatrixLayout;
5-
use crate::types::*;
6-
7-
use super::{into_result, UPLO};
3+
use super::*;
4+
use crate::{error::*, layout::MatrixLayout};
5+
use cauchy::*;
86

97
pub trait Cholesky_: Sized {
108
/// Cholesky: wrapper of `*potrf`
@@ -25,14 +23,14 @@ macro_rules! impl_cholesky {
2523
impl Cholesky_ for $scalar {
2624
unsafe fn cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> {
2725
let (n, _) = l.size();
28-
let info = $trf(l.lapacke_layout(), uplo as u8, n, a, n);
29-
into_result(info, ())
26+
$trf(l.lapacke_layout(), uplo as u8, n, a, n).as_lapack_result()?;
27+
Ok(())
3028
}
3129

3230
unsafe fn inv_cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> {
3331
let (n, _) = l.size();
34-
let info = $tri(l.lapacke_layout(), uplo as u8, n, a, l.lda());
35-
into_result(info, ())
32+
$tri(l.lapacke_layout(), uplo as u8, n, a, l.lda()).as_lapack_result()?;
33+
Ok(())
3634
}
3735

3836
unsafe fn solve_cholesky(
@@ -44,8 +42,9 @@ macro_rules! impl_cholesky {
4442
let (n, _) = l.size();
4543
let nrhs = 1;
4644
let ldb = 1;
47-
let info = $trs(l.lapacke_layout(), uplo as u8, n, nrhs, a, l.lda(), b, ldb);
48-
into_result(info, ())
45+
$trs(l.lapacke_layout(), uplo as u8, n, nrhs, a, l.lda(), b, ldb)
46+
.as_lapack_result()?;
47+
Ok(())
4948
}
5049
}
5150
};

src/lapack/eig.rs renamed to lax/src/eig.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
//! Eigenvalue decomposition for general matrices
22
3+
use crate::{error::*, layout::MatrixLayout};
4+
use cauchy::*;
35
use num_traits::Zero;
46

5-
use crate::error::*;
6-
use crate::layout::MatrixLayout;
7-
use crate::types::*;
8-
9-
use super::into_result;
10-
117
/// Wraps `*geev` for real/complex
128
pub trait Eig_: Scalar {
139
unsafe fn eig(
@@ -30,7 +26,7 @@ macro_rules! impl_eig_complex {
3026
let mut w = vec![Self::Complex::zero(); n as usize];
3127
let mut vl = Vec::new();
3228
let mut vr = vec![Self::Complex::zero(); (n * n) as usize];
33-
let info = $ev(
29+
$ev(
3430
l.lapacke_layout(),
3531
b'N',
3632
jobvr,
@@ -42,8 +38,9 @@ macro_rules! impl_eig_complex {
4238
n,
4339
&mut vr,
4440
n,
45-
);
46-
into_result(info, (w, vr))
41+
)
42+
.as_lapack_result()?;
43+
Ok((w, vr))
4744
}
4845
}
4946
};
@@ -82,6 +79,7 @@ macro_rules! impl_eig_real {
8279
.zip(wi.iter())
8380
.map(|(&r, &i)| Self::Complex::new(r, i))
8481
.collect();
82+
8583
// If the j-th eigenvalue is real, then
8684
// eigenvector = [ vr[j], vr[j+n], vr[j+2*n], ... ].
8785
//
@@ -121,7 +119,8 @@ macro_rules! impl_eig_real {
121119
})
122120
.collect();
123121

124-
into_result(info, (w, v))
122+
info.as_lapack_result()?;
123+
Ok((w, v))
125124
}
126125
}
127126
};

src/lapack/eigh.rs renamed to lax/src/eigh.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Eigenvalue decomposition for Symmetric/Hermite matrices
22
33
use super::*;
4-
use crate::{error::*, layout::MatrixLayout, types::*};
4+
use crate::{error::*, layout::MatrixLayout};
5+
use cauchy::*;
56
use num_traits::Zero;
67

78
pub trait Eigh_: Scalar {
@@ -52,7 +53,7 @@ macro_rules! impl_eigh {
5253
&mut info,
5354
);
5455
}
55-
info.as_lapack_error()?;
56+
info.as_lapack_result()?;
5657
Ok(eigs)
5758
}
5859

@@ -86,7 +87,7 @@ macro_rules! impl_eigh {
8687
&mut info,
8788
);
8889
}
89-
info.as_lapack_error()?;
90+
info.as_lapack_result()?;
9091
Ok(eigs)
9192
}
9293
}
@@ -129,7 +130,7 @@ macro_rules! impl_eighc {
129130
&mut info,
130131
)
131132
};
132-
info.as_lapack_error()?;
133+
info.as_lapack_result()?;
133134
Ok(eigs)
134135
}
135136

@@ -166,7 +167,7 @@ macro_rules! impl_eighc {
166167
&mut info,
167168
)
168169
};
169-
info.as_lapack_error()?;
170+
info.as_lapack_result()?;
170171
Ok(eigs)
171172
}
172173
}

0 commit comments

Comments
 (0)