From 73cc9882b2b88f41948281f19c5f869c2a179e5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crozet=20S=C3=A9bastien?= Date: Mon, 12 Apr 2021 10:34:44 +0200 Subject: [PATCH] Fix compilation of nalgebra-lapack --- nalgebra-lapack/Cargo.toml | 4 ++-- nalgebra-lapack/src/eigen.rs | 12 ++++++------ nalgebra-lapack/src/hessenberg.rs | 6 ++++-- nalgebra-lapack/src/lu.rs | 6 +++--- nalgebra-lapack/src/qr.rs | 7 ++++--- nalgebra-lapack/src/schur.rs | 11 ++++++----- nalgebra-lapack/src/svd.rs | 8 ++++---- nalgebra-lapack/src/symmetric_eigen.rs | 5 +++-- tests/proptest/mod.rs | 2 +- 9 files changed, 33 insertions(+), 28 deletions(-) diff --git a/nalgebra-lapack/Cargo.toml b/nalgebra-lapack/Cargo.toml index c2de1b96..3da66478 100644 --- a/nalgebra-lapack/Cargo.toml +++ b/nalgebra-lapack/Cargo.toml @@ -40,8 +40,8 @@ lapack-src = { version = "0.6", default-features = false } # clippy = "*" [dev-dependencies] -nalgebra = { version = "0.25", features = [ "arbitrary" ], path = ".." } -proptest = { version = "1", default-features = false, features = ["std"] } +nalgebra = { version = "0.25", features = [ "arbitrary", "rand" ], path = ".." } +proptest = { version = "1", default-features = false, features = ["std"] } quickcheck = "1" approx = "0.4" rand = "0.8" diff --git a/nalgebra-lapack/src/eigen.rs b/nalgebra-lapack/src/eigen.rs index 2a01ba54..cbe1555a 100644 --- a/nalgebra-lapack/src/eigen.rs +++ b/nalgebra-lapack/src/eigen.rs @@ -8,7 +8,7 @@ use simba::scalar::RealField; use crate::ComplexHelper; use na::allocator::Allocator; -use na::dimension::{Dim, U1}; +use na::dimension::{Const, Dim}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -78,9 +78,9 @@ where let lda = n as i32; - let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; + let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; // TODO: Tap into the workspace. - let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; + let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; let mut info = 0; let mut placeholder1 = [T::zero()]; @@ -247,8 +247,8 @@ where let lda = n as i32; - let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; - let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; + let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; + let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; let mut info = 0; let mut placeholder1 = [T::zero()]; @@ -291,7 +291,7 @@ where ); lapack_panic!(info); - let mut res = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; + let mut res = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; for i in 0..res.len() { res[i] = Complex::new(wr[i], wi[i]); diff --git a/nalgebra-lapack/src/hessenberg.rs b/nalgebra-lapack/src/hessenberg.rs index 8bb9d69d..b025a8bf 100644 --- a/nalgebra-lapack/src/hessenberg.rs +++ b/nalgebra-lapack/src/hessenberg.rs @@ -3,7 +3,7 @@ use num_complex::Complex; use crate::ComplexHelper; use na::allocator::Allocator; -use na::dimension::{DimDiff, DimSub, U1}; +use na::dimension::{Const, DimDiff, DimSub, U1}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -60,7 +60,9 @@ where "Unable to compute the hessenberg decomposition of an empty matrix." ); - let mut tau = unsafe { Matrix::new_uninitialized_generic(nrows.sub(U1), U1).assume_init() }; + let mut tau = unsafe { + Matrix::new_uninitialized_generic(nrows.sub(Const::<1>), Const::<1>).assume_init() + }; let mut info = 0; let lwork = diff --git a/nalgebra-lapack/src/lu.rs b/nalgebra-lapack/src/lu.rs index 532c8212..5ca5f143 100644 --- a/nalgebra-lapack/src/lu.rs +++ b/nalgebra-lapack/src/lu.rs @@ -3,7 +3,7 @@ use num_complex::Complex; use crate::ComplexHelper; use na::allocator::Allocator; -use na::dimension::{Dim, DimMin, DimMinimum, U1}; +use na::dimension::{Const, Dim, DimMin, DimMinimum}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -66,7 +66,7 @@ where let nrows = nrows.value() as i32; let ncols = ncols.value() as i32; - let mut ipiv: OVector = Matrix::zeros_generic(min_nrows_ncols, U1); + let mut ipiv: OVector = Matrix::zeros_generic(min_nrows_ncols, Const::<1>); let mut info = 0; @@ -111,7 +111,7 @@ where /// Computing the permutation matrix explicitly is costly and usually not necessary. /// To permute rows of a matrix or vector, use the method `self.permute(...)` instead. #[inline] - pub fn p(&self) -> OMatrix { + pub fn p(&self) -> OMatrix { let (dim, _) = self.lu.data.shape(); let mut id = Matrix::identity_generic(dim, dim); self.permute(&mut id); diff --git a/nalgebra-lapack/src/qr.rs b/nalgebra-lapack/src/qr.rs index 050ba24f..b58c3f35 100644 --- a/nalgebra-lapack/src/qr.rs +++ b/nalgebra-lapack/src/qr.rs @@ -6,7 +6,7 @@ use num_complex::Complex; use crate::ComplexHelper; use na::allocator::Allocator; -use na::dimension::{Dim, DimMin, DimMinimum, U1}; +use na::dimension::{Const, Dim, DimMin, DimMinimum}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -57,8 +57,9 @@ where let (nrows, ncols) = m.data.shape(); let mut info = 0; - let mut tau = - unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() }; + let mut tau = unsafe { + Matrix::new_uninitialized_generic(nrows.min(ncols), Const::<1>).assume_init() + }; if nrows.value() == 0 || ncols.value() == 0 { return Self { qr: m, tau: tau }; diff --git a/nalgebra-lapack/src/schur.rs b/nalgebra-lapack/src/schur.rs index 340e7e31..a850f01d 100644 --- a/nalgebra-lapack/src/schur.rs +++ b/nalgebra-lapack/src/schur.rs @@ -8,7 +8,7 @@ use simba::scalar::RealField; use crate::ComplexHelper; use na::allocator::Allocator; -use na::dimension::{Dim, U1}; +use na::dimension::{Const, Dim}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -78,8 +78,8 @@ where let mut info = 0; - let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; - let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; + let mut wr = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; + let mut wi = unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; let mut q = unsafe { Matrix::new_uninitialized_generic(nrows, ncols).assume_init() }; // Placeholders: let mut bwork = [0i32]; @@ -151,8 +151,9 @@ where where DefaultAllocator: Allocator, D>, { - let mut out = - unsafe { OVector::new_uninitialized_generic(self.t.data.shape().0, U1).assume_init() }; + let mut out = unsafe { + OVector::new_uninitialized_generic(self.t.data.shape().0, Const::<1>).assume_init() + }; for i in 0..out.len() { out[i] = Complex::new(self.re[i], self.im[i]) diff --git a/nalgebra-lapack/src/svd.rs b/nalgebra-lapack/src/svd.rs index 95269270..f6b907b6 100644 --- a/nalgebra-lapack/src/svd.rs +++ b/nalgebra-lapack/src/svd.rs @@ -5,7 +5,7 @@ use num::Signed; use std::cmp; use na::allocator::Allocator; -use na::dimension::{Dim, DimMin, DimMinimum, U1}; +use na::dimension::{Const, Dim, DimMin, DimMinimum, U1}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -37,9 +37,9 @@ where DefaultAllocator: Allocator + Allocator> + Allocator, { /// The left-singular vectors `U` of this SVD. - pub u: OMatrix, // TODO: should be OMatrix> + pub u: OMatrix, // TODO: should be OMatrix> /// The right-singular vectors `V^t` of this SVD. - pub vt: OMatrix, // TODO: should be OMatrix, C> + pub vt: OMatrix, // TODO: should be OMatrix, C> /// The singular values of this SVD. pub singular_values: OVector>, } @@ -100,7 +100,7 @@ macro_rules! svd_impl( let lda = nrows.value() as i32; let mut u = unsafe { Matrix::new_uninitialized_generic(nrows, nrows).assume_init() }; - let mut s = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), U1).assume_init() }; + let mut s = unsafe { Matrix::new_uninitialized_generic(nrows.min(ncols), Const::<1>).assume_init() }; let mut vt = unsafe { Matrix::new_uninitialized_generic(ncols, ncols).assume_init() }; let ldu = nrows.value(); diff --git a/nalgebra-lapack/src/symmetric_eigen.rs b/nalgebra-lapack/src/symmetric_eigen.rs index f0cdc950..0cd6bfc1 100644 --- a/nalgebra-lapack/src/symmetric_eigen.rs +++ b/nalgebra-lapack/src/symmetric_eigen.rs @@ -8,7 +8,7 @@ use simba::scalar::RealField; use crate::ComplexHelper; use na::allocator::Allocator; -use na::dimension::{Dim, U1}; +use na::dimension::{Const, Dim}; use na::storage::Storage; use na::{DefaultAllocator, Matrix, OMatrix, OVector, Scalar}; @@ -94,7 +94,8 @@ where let lda = n as i32; - let mut values = unsafe { Matrix::new_uninitialized_generic(nrows, U1).assume_init() }; + let mut values = + unsafe { Matrix::new_uninitialized_generic(nrows, Const::<1>).assume_init() }; let mut info = 0; let lwork = T::xsyev_work_size(jobz, b'L', n as i32, m.as_mut_slice(), lda, &mut info); diff --git a/tests/proptest/mod.rs b/tests/proptest/mod.rs index 9164b95d..ec2e2c7b 100644 --- a/tests/proptest/mod.rs +++ b/tests/proptest/mod.rs @@ -101,7 +101,7 @@ pub fn dvector() -> impl Strategy> { pub fn dmatrix_( scalar_strategy: ScalarStrategy, -) -> impl Strategy> +) -> impl Strategy> where ScalarStrategy: Strategy + Clone + 'static, ScalarStrategy::Value: Scalar,