From 06af362c1bc779672f11b9aeeaa511ab047655bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Cassiers?= Date: Tue, 6 Apr 2021 16:09:38 +0200 Subject: [PATCH 1/5] Support ndarray 0.15 Adding `std` feature is required since ndarray 0.15 made `impl std::error::Error for ShapeError` require std. Bump MSRV to 1.49 in linux-container CI to match the one of ndarray (1.43 was giving errors in ndarray). --- .github/workflows/intel-mkl.yml | 2 +- ndarray-linalg/Cargo.toml | 4 ++-- ndarray-linalg/src/cholesky.rs | 4 ++-- ndarray-linalg/src/solve.rs | 2 +- ndarray-linalg/src/solveh.rs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/intel-mkl.yml b/.github/workflows/intel-mkl.yml index e7e06f2f..fec201c1 100644 --- a/.github/workflows/intel-mkl.yml +++ b/.github/workflows/intel-mkl.yml @@ -34,7 +34,7 @@ jobs: linux-container: runs-on: ubuntu-18.04 - container: rustmath/mkl-rust:1.43.0 + container: rustmath/mkl-rust:1.49.0 steps: - uses: actions/checkout@v1 - uses: actions-rs/cargo@v1 diff --git a/ndarray-linalg/Cargo.toml b/ndarray-linalg/Cargo.toml index 559cec06..a0823da1 100644 --- a/ndarray-linalg/Cargo.toml +++ b/ndarray-linalg/Cargo.toml @@ -36,8 +36,8 @@ rand = "0.7.3" thiserror = "1.0.20" [dependencies.ndarray] -version = "0.14" -features = ["blas", "approx"] +version = ">=0.14,<0.16" +features = ["blas", "approx", "std"] default-features = false [dependencies.lax] diff --git a/ndarray-linalg/src/cholesky.rs b/ndarray-linalg/src/cholesky.rs index 8ce0da84..58cc5cee 100644 --- a/ndarray-linalg/src/cholesky.rs +++ b/ndarray-linalg/src/cholesky.rs @@ -26,7 +26,7 @@ //! //! // Obtain `L` //! let lower = a.cholesky(UPLO::Lower).unwrap(); -//! assert!(lower.all_close(&array![ +//! assert!(lower.abs_diff_eq(&array![ //! [ 2., 0., 0.], //! [ 6., 1., 0.], //! [-8., 5., 3.] @@ -39,7 +39,7 @@ //! // Solve `A * x = b` //! let b = array![4., 13., -11.]; //! let x = a.solvec(&b).unwrap(); -//! assert!(x.all_close(&array![-2., 1., 0.], 1e-9)); +//! assert!(x.abs_diff_eq(&array![-2., 1., 0.], 1e-9)); //! # } //! ``` diff --git a/ndarray-linalg/src/solve.rs b/ndarray-linalg/src/solve.rs index dc71bf66..7e695a8c 100644 --- a/ndarray-linalg/src/solve.rs +++ b/ndarray-linalg/src/solve.rs @@ -16,7 +16,7 @@ //! let a: Array2 = array![[3., 2., -1.], [2., -2., 4.], [-2., 1., -2.]]; //! let b: Array1 = array![1., -2., 0.]; //! let x = a.solve_into(b).unwrap(); -//! assert!(x.all_close(&array![1., -2., -2.], 1e-9)); +//! assert!(x.abs_diff_eq(&array![1., -2., -2.], 1e-9)); //! //! # } //! ``` diff --git a/ndarray-linalg/src/solveh.rs b/ndarray-linalg/src/solveh.rs index fcfc6933..26329509 100644 --- a/ndarray-linalg/src/solveh.rs +++ b/ndarray-linalg/src/solveh.rs @@ -23,7 +23,7 @@ //! ]; //! let b: Array1 = array![11., -12., 1.]; //! let x = a.solveh_into(b).unwrap(); -//! assert!(x.all_close(&array![1., 3., -2.], 1e-9)); +//! assert!(x.abs_diff_eq(&array![1., 3., -2.], 1e-9)); //! //! # } //! ``` From 62a1b3c9767cb37e3e7c11109d16af1f59774230 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Sun, 11 Apr 2021 13:46:38 +0900 Subject: [PATCH 2/5] Update lax dependencies --- lax/Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lax/Cargo.toml b/lax/Cargo.toml index fccf952a..a8e74044 100644 --- a/lax/Cargo.toml +++ b/lax/Cargo.toml @@ -29,10 +29,10 @@ intel-mkl-static = ["intel-mkl-src/mkl-static-lp64-seq", "intel-mkl-src/download intel-mkl-system = ["intel-mkl-src/mkl-dynamic-lp64-seq"] [dependencies] -thiserror = "1.0.23" -cauchy = "0.3.0" +thiserror = "1.0.24" +cauchy = "0.4.0" num-traits = "0.2.14" -lapack = "0.17.0" +lapack = "0.18.0" [dependencies.intel-mkl-src] version = "0.6.0" @@ -46,7 +46,7 @@ features = ["cblas"] default-features = false [dependencies.openblas-src] -version = "0.10.2" +version = "0.10.4" optional = true default-features = false features = ["cblas"] From c91862f5e1ade69e4db58dc7cfdcc44f9ed7c17e Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Sun, 11 Apr 2021 13:49:40 +0900 Subject: [PATCH 3/5] Upgrade ndarray-linalg dependencies --- ndarray-linalg/Cargo.toml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ndarray-linalg/Cargo.toml b/ndarray-linalg/Cargo.toml index a0823da1..1c3ab554 100644 --- a/ndarray-linalg/Cargo.toml +++ b/ndarray-linalg/Cargo.toml @@ -29,14 +29,14 @@ intel-mkl-static = ["lax/intel-mkl-static"] intel-mkl-system = ["lax/intel-mkl-system"] [dependencies] -cauchy = "0.3.0" -num-complex = "0.3.1" -num-traits = "0.2.11" -rand = "0.7.3" -thiserror = "1.0.20" +cauchy = "0.4.0" +num-complex = "0.4.0" +num-traits = "0.2.14" +rand = "0.8.3" +thiserror = "1.0.24" [dependencies.ndarray] -version = ">=0.14,<0.16" +version = "0.15.1" features = ["blas", "approx", "std"] default-features = false @@ -46,10 +46,10 @@ path = "../lax" default-features = false [dev-dependencies] -paste = "1.0" -criterion = "0.3" +paste = "1.0.5" +criterion = "0.3.4" # Keep the same version as ndarray's dependency! -approx = { version = "0.4", features = ["num-complex"] } +approx = { version = "0.4.0", features = ["num-complex"] } [[bench]] name = "truncated_eig" From c760a7eb48a070e70bba849e54077a1a9eb678c4 Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Sun, 11 Apr 2021 13:59:44 +0900 Subject: [PATCH 4/5] Fix renamed deprecated updates --- ndarray-linalg/src/eigh.rs | 1 - ndarray-linalg/src/lobpcg/eig.rs | 4 ++-- ndarray-linalg/src/lobpcg/lobpcg.rs | 4 ++-- ndarray-linalg/src/lobpcg/svd.rs | 4 ++-- ndarray-linalg/tests/cholesky.rs | 2 +- 5 files changed, 7 insertions(+), 8 deletions(-) diff --git a/ndarray-linalg/src/eigh.rs b/ndarray-linalg/src/eigh.rs index 86f1fb46..580c2b7e 100644 --- a/ndarray-linalg/src/eigh.rs +++ b/ndarray-linalg/src/eigh.rs @@ -8,7 +8,6 @@ use crate::layout::*; use crate::operator::LinearOperator; use crate::types::*; use crate::UPLO; -use std::iter::FromIterator; /// Eigenvalue decomposition of Hermite matrix reference pub trait Eigh { diff --git a/ndarray-linalg/src/lobpcg/eig.rs b/ndarray-linalg/src/lobpcg/eig.rs index 0b5a60e8..e60adb04 100644 --- a/ndarray-linalg/src/lobpcg/eig.rs +++ b/ndarray-linalg/src/lobpcg/eig.rs @@ -139,9 +139,9 @@ impl Iterator // add the new eigenvector to the internal constrain matrix let new_constraints = if let Some(ref constraints) = self.eig.constraints { let eigvecs_arr: Vec<_> = constraints - .gencolumns() + .columns() .into_iter() - .chain(vecs.gencolumns().into_iter()) + .chain(vecs.columns().into_iter()) .collect(); stack(Axis(1), &eigvecs_arr).unwrap() diff --git a/ndarray-linalg/src/lobpcg/lobpcg.rs b/ndarray-linalg/src/lobpcg/lobpcg.rs index a10e5961..1bc4f2ad 100644 --- a/ndarray-linalg/src/lobpcg/lobpcg.rs +++ b/ndarray-linalg/src/lobpcg/lobpcg.rs @@ -81,7 +81,7 @@ fn apply_constraints( let gram_yv = y.t().dot(&v); let u = gram_yv - .gencolumns() + .columns() .into_iter() .map(|x| { let res = cholesky_yy.solvec(&x).unwrap(); @@ -222,7 +222,7 @@ pub fn lobpcg< // calculate L2 norm of error for every eigenvalue let residual_norms = r - .gencolumns() + .columns() .into_iter() .map(|x| x.norm()) .collect::>(); diff --git a/ndarray-linalg/src/lobpcg/svd.rs b/ndarray-linalg/src/lobpcg/svd.rs index a796364d..7a326293 100644 --- a/ndarray-linalg/src/lobpcg/svd.rs +++ b/ndarray-linalg/src/lobpcg/svd.rs @@ -64,7 +64,7 @@ impl + 'static + MagnitudeCorrection> Trunc let mut ularge = self.problem.dot(&vlarge); ularge - .gencolumns_mut() + .columns_mut() .into_iter() .zip(values.iter()) .for_each(|(mut a, b)| a.mapv_inplace(|x| x / *b)); @@ -75,7 +75,7 @@ impl + 'static + MagnitudeCorrection> Trunc let mut vlarge = self.problem.t().dot(&ularge); vlarge - .gencolumns_mut() + .columns_mut() .into_iter() .zip(values.iter()) .for_each(|(mut a, b)| a.mapv_inplace(|x| x / *b)); diff --git a/ndarray-linalg/tests/cholesky.rs b/ndarray-linalg/tests/cholesky.rs index b45afb5c..a498afc3 100644 --- a/ndarray-linalg/tests/cholesky.rs +++ b/ndarray-linalg/tests/cholesky.rs @@ -140,7 +140,7 @@ macro_rules! cholesky_det { .eigvalsh(UPLO::Upper) .unwrap() .mapv(|elem| elem.ln()) - .scalar_sum(); + .sum(); let det = ln_det.exp(); assert_aclose!(a.factorizec(UPLO::Upper).unwrap().detc(), det, $atol); assert_aclose!(a.factorizec(UPLO::Upper).unwrap().ln_detc(), ln_det, $atol); From fbac1a9abf31fc6534584f1006126c911e20ffdd Mon Sep 17 00:00:00 2001 From: Toshiki Teramura Date: Sun, 11 Apr 2021 15:37:34 +0900 Subject: [PATCH 5/5] Use ghcr.io container --- .github/workflows/intel-mkl.yml | 2 +- .github/workflows/rust.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/intel-mkl.yml b/.github/workflows/intel-mkl.yml index fec201c1..2144049f 100644 --- a/.github/workflows/intel-mkl.yml +++ b/.github/workflows/intel-mkl.yml @@ -34,7 +34,7 @@ jobs: linux-container: runs-on: ubuntu-18.04 - container: rustmath/mkl-rust:1.49.0 + container: ghcr.io/rust-math/intel-mkl-src/mkl-rust:1.49.0 steps: - uses: actions/checkout@v1 - uses: actions-rs/cargo@v1 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index b1c2bc1f..f4aa30ae 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -27,7 +27,7 @@ jobs: coverage: runs-on: ubuntu-18.04 container: - image: rustmath/mkl-rust:1.43.0 + image: ghcr.io/rust-math/intel-mkl-src/mkl-rust:1.49.0 options: --security-opt seccomp=unconfined steps: - uses: actions/checkout@v2