Skip to content

Commit c23807a

Browse files
authored
feat: use GAT to remove the scalar type T from the Allocator trait (#1397)
1 parent 28e993a commit c23807a

Some content is hidden

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

92 files changed

+943
-1032
lines changed

examples/dimensional_genericity.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn reflect_wrt_hyperplane_with_dimensional_genericity<T: RealField, D: Dim>(
1212
where
1313
T: RealField,
1414
D: Dim,
15-
DefaultAllocator: Allocator<T, D>,
15+
DefaultAllocator: Allocator<D>,
1616
{
1717
let n = plane_normal.as_ref(); // Get the underlying V.
1818
vector - n * (n.dot(vector) * na::convert(2.0))

nalgebra-lapack/Cargo.toml

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
11
[package]
2-
name = "nalgebra-lapack"
2+
name = "nalgebra-lapack"
33
version = "0.24.0"
4-
authors = [ "Sébastien Crozet <[email protected]>", "Andrew Straw <[email protected]>" ]
4+
authors = ["Sébastien Crozet <[email protected]>", "Andrew Straw <[email protected]>"]
55

6-
description = "Matrix decompositions using nalgebra matrices and Lapack bindings."
6+
description = "Matrix decompositions using nalgebra matrices and Lapack bindings."
77
documentation = "https://www.nalgebra.org/docs"
88
homepage = "https://nalgebra.org"
99
repository = "https://github.com/dimforge/nalgebra"
1010
readme = "../README.md"
11-
categories = [ "science", "mathematics" ]
12-
keywords = [ "linear", "algebra", "matrix", "vector", "lapack" ]
11+
categories = ["science", "mathematics"]
12+
keywords = ["linear", "algebra", "matrix", "vector", "lapack"]
1313
license = "MIT"
1414
edition = "2018"
1515

1616
[badges]
1717
maintenance = { status = "actively-developed" }
1818

1919
[features]
20-
serde-serialize = [ "serde", "nalgebra/serde-serialize" ]
21-
proptest-support = [ "nalgebra/proptest-support" ]
22-
arbitrary = [ "nalgebra/arbitrary" ]
20+
serde-serialize = ["serde", "nalgebra/serde-serialize"]
21+
proptest-support = ["nalgebra/proptest-support"]
22+
arbitrary = ["nalgebra/arbitrary"]
2323

2424
# For BLAS/LAPACK
25-
default = ["netlib"]
26-
openblas = ["lapack-src/openblas"]
27-
netlib = ["lapack-src/netlib"]
25+
default = ["netlib"]
26+
openblas = ["lapack-src/openblas"]
27+
netlib = ["lapack-src/netlib"]
2828
accelerate = ["lapack-src/accelerate"]
29-
intel-mkl = ["lapack-src/intel-mkl"]
29+
intel-mkl = ["lapack-src/intel-mkl"]
3030

3131
[dependencies]
32-
nalgebra = { version = "0.32", path = ".." }
33-
num-traits = "0.2"
34-
num-complex = { version = "0.4", default-features = false }
35-
simba = "0.8"
36-
serde = { version = "1.0", features = [ "derive" ], optional = true }
37-
lapack = { version = "0.19", default-features = false }
38-
lapack-src = { version = "0.8", default-features = false }
32+
nalgebra = { version = "0.32", path = ".." }
33+
num-traits = "0.2"
34+
num-complex = { version = "0.4", default-features = false }
35+
simba = "0.8"
36+
serde = { version = "1.0", features = ["derive"], optional = true }
37+
lapack = { version = "0.19", default-features = false }
38+
lapack-src = { version = "0.8", default-features = false }
3939
# clippy = "*"
4040

4141
[dev-dependencies]
42-
nalgebra = { version = "0.32", features = [ "arbitrary", "rand" ], path = ".." }
43-
proptest = { version = "1", default-features = false, features = ["std"] }
42+
nalgebra = { version = "0.32", features = ["arbitrary", "rand"], path = ".." }
43+
proptest = { version = "1", default-features = false, features = ["std"] }
4444
quickcheck = "1"
45-
approx = "0.5"
46-
rand = "0.8"
45+
approx = "0.5"
46+
rand = "0.8"
4747

nalgebra-lapack/src/cholesky.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ use lapack;
1515
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
1616
#[cfg_attr(
1717
feature = "serde-serialize",
18-
serde(bound(serialize = "DefaultAllocator: Allocator<T, D>,
18+
serde(bound(serialize = "DefaultAllocator: Allocator<D>,
1919
OMatrix<T, D, D>: Serialize"))
2020
)]
2121
#[cfg_attr(
2222
feature = "serde-serialize",
23-
serde(bound(deserialize = "DefaultAllocator: Allocator<T, D>,
23+
serde(bound(deserialize = "DefaultAllocator: Allocator<D>,
2424
OMatrix<T, D, D>: Deserialize<'de>"))
2525
)]
2626
#[derive(Clone, Debug)]
2727
pub struct Cholesky<T: Scalar, D: Dim>
2828
where
29-
DefaultAllocator: Allocator<T, D, D>,
29+
DefaultAllocator: Allocator<D, D>,
3030
{
3131
l: OMatrix<T, D, D>,
3232
}
3333

3434
impl<T: Scalar + Copy, D: Dim> Copy for Cholesky<T, D>
3535
where
36-
DefaultAllocator: Allocator<T, D, D>,
36+
DefaultAllocator: Allocator<D, D>,
3737
OMatrix<T, D, D>: Copy,
3838
{
3939
}
4040

4141
impl<T: CholeskyScalar + Zero, D: Dim> Cholesky<T, D>
4242
where
43-
DefaultAllocator: Allocator<T, D, D>,
43+
DefaultAllocator: Allocator<D, D>,
4444
{
4545
/// Computes the cholesky decomposition of the given symmetric-definite-positive square
4646
/// matrix.
@@ -105,7 +105,7 @@ where
105105
) -> Option<OMatrix<T, R2, C2>>
106106
where
107107
S2: Storage<T, R2, C2>,
108-
DefaultAllocator: Allocator<T, R2, C2>,
108+
DefaultAllocator: Allocator<R2, C2>,
109109
{
110110
let mut res = b.clone_owned();
111111
if self.solve_mut(&mut res) {
@@ -119,7 +119,7 @@ where
119119
/// the unknown to be determined.
120120
pub fn solve_mut<R2: Dim, C2: Dim>(&self, b: &mut OMatrix<T, R2, C2>) -> bool
121121
where
122-
DefaultAllocator: Allocator<T, R2, C2>,
122+
DefaultAllocator: Allocator<R2, C2>,
123123
{
124124
let dim = self.l.nrows();
125125

nalgebra-lapack/src/eigen.rs

+9-13
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@ use lapack;
1616
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
1717
#[cfg_attr(
1818
feature = "serde-serialize",
19-
serde(
20-
bound(serialize = "DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
19+
serde(bound(serialize = "DefaultAllocator: Allocator<D, D> + Allocator<D>,
2120
OVector<T, D>: Serialize,
22-
OMatrix<T, D, D>: Serialize")
23-
)
21+
OMatrix<T, D, D>: Serialize"))
2422
)]
2523
#[cfg_attr(
2624
feature = "serde-serialize",
27-
serde(
28-
bound(deserialize = "DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
25+
serde(bound(deserialize = "DefaultAllocator: Allocator<D, D> + Allocator<D>,
2926
OVector<T, D>: Serialize,
30-
OMatrix<T, D, D>: Deserialize<'de>")
31-
)
27+
OMatrix<T, D, D>: Deserialize<'de>"))
3228
)]
3329
#[derive(Clone, Debug)]
3430
pub struct Eigen<T: Scalar, D: Dim>
3531
where
36-
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
32+
DefaultAllocator: Allocator<D> + Allocator<D, D>,
3733
{
3834
/// The real parts of eigenvalues of the decomposed matrix.
3935
pub eigenvalues_re: OVector<T, D>,
@@ -47,15 +43,15 @@ where
4743

4844
impl<T: Scalar + Copy, D: Dim> Copy for Eigen<T, D>
4945
where
50-
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
46+
DefaultAllocator: Allocator<D> + Allocator<D, D>,
5147
OVector<T, D>: Copy,
5248
OMatrix<T, D, D>: Copy,
5349
{
5450
}
5551

5652
impl<T: EigenScalar + RealField, D: Dim> Eigen<T, D>
5753
where
58-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
54+
DefaultAllocator: Allocator<D, D> + Allocator<D>,
5955
{
6056
/// Computes the eigenvalues and eigenvectors of the square matrix `m`.
6157
///
@@ -177,7 +173,7 @@ where
177173
Option<Vec<OVector<T, D>>>,
178174
)
179175
where
180-
DefaultAllocator: Allocator<T, D>,
176+
DefaultAllocator: Allocator<D>,
181177
{
182178
let (number_of_elements, _) = self.eigenvalues_re.shape_generic();
183179
let number_of_elements_value = number_of_elements.value();
@@ -234,7 +230,7 @@ where
234230
Option<Vec<OVector<Complex<T>, D>>>,
235231
)
236232
where
237-
DefaultAllocator: Allocator<Complex<T>, D>,
233+
DefaultAllocator: Allocator<D>,
238234
{
239235
match self.eigenvalues_are_real() {
240236
true => (None, None, None),

nalgebra-lapack/src/generalized_eigenvalues.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,20 @@ use lapack;
3030
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
3131
#[cfg_attr(
3232
feature = "serde-serialize",
33-
serde(
34-
bound(serialize = "DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
33+
serde(bound(serialize = "DefaultAllocator: Allocator<D, D> + Allocator<D>,
3534
OVector<T, D>: Serialize,
36-
OMatrix<T, D, D>: Serialize")
37-
)
35+
OMatrix<T, D, D>: Serialize"))
3836
)]
3937
#[cfg_attr(
4038
feature = "serde-serialize",
41-
serde(
42-
bound(deserialize = "DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
39+
serde(bound(deserialize = "DefaultAllocator: Allocator<D, D> + Allocator<D>,
4340
OVector<T, D>: Deserialize<'de>,
44-
OMatrix<T, D, D>: Deserialize<'de>")
45-
)
41+
OMatrix<T, D, D>: Deserialize<'de>"))
4642
)]
4743
#[derive(Clone, Debug)]
4844
pub struct GeneralizedEigen<T: Scalar, D: Dim>
4945
where
50-
DefaultAllocator: Allocator<T, D> + Allocator<T, D, D>,
46+
DefaultAllocator: Allocator<D> + Allocator<D, D>,
5147
{
5248
alphar: OVector<T, D>,
5349
alphai: OVector<T, D>,
@@ -58,15 +54,15 @@ where
5854

5955
impl<T: Scalar + Copy, D: Dim> Copy for GeneralizedEigen<T, D>
6056
where
61-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
57+
DefaultAllocator: Allocator<D, D> + Allocator<D>,
6258
OMatrix<T, D, D>: Copy,
6359
OVector<T, D>: Copy,
6460
{
6561
}
6662

6763
impl<T: GeneralizedEigenScalar + RealField + Copy, D: Dim> GeneralizedEigen<T, D>
6864
where
69-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, D>,
65+
DefaultAllocator: Allocator<D, D> + Allocator<D>,
7066
{
7167
/// Attempts to compute the generalized eigenvalues, and left and right associated eigenvectors
7268
/// via the raw returns from LAPACK's dggev and sggev routines
@@ -162,8 +158,7 @@ where
162158
/// as columns.
163159
pub fn eigenvectors(&self) -> (OMatrix<Complex<T>, D, D>, OMatrix<Complex<T>, D, D>)
164160
where
165-
DefaultAllocator:
166-
Allocator<Complex<T>, D, D> + Allocator<Complex<T>, D> + Allocator<(Complex<T>, T), D>,
161+
DefaultAllocator: Allocator<D, D> + Allocator<D>,
167162
{
168163
/*
169164
How the eigenvectors are built up:
@@ -230,7 +225,7 @@ where
230225
#[must_use]
231226
pub fn raw_eigenvalues(&self) -> OVector<(Complex<T>, T), D>
232227
where
233-
DefaultAllocator: Allocator<(Complex<T>, T), D>,
228+
DefaultAllocator: Allocator<D>,
234229
{
235230
let mut out = Matrix::from_element_generic(
236231
self.vsl.shape_generic().0,

nalgebra-lapack/src/hessenberg.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,38 @@ use lapack;
1212
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
1313
#[cfg_attr(
1414
feature = "serde-serialize",
15-
serde(bound(serialize = "DefaultAllocator: Allocator<T, D, D> +
16-
Allocator<T, DimDiff<D, U1>>,
15+
serde(bound(serialize = "DefaultAllocator: Allocator<D, D> +
16+
Allocator<DimDiff<D, U1>>,
1717
OMatrix<T, D, D>: Serialize,
1818
OVector<T, DimDiff<D, U1>>: Serialize"))
1919
)]
2020
#[cfg_attr(
2121
feature = "serde-serialize",
22-
serde(bound(deserialize = "DefaultAllocator: Allocator<T, D, D> +
23-
Allocator<T, DimDiff<D, U1>>,
22+
serde(bound(deserialize = "DefaultAllocator: Allocator<D, D> +
23+
Allocator<DimDiff<D, U1>>,
2424
OMatrix<T, D, D>: Deserialize<'de>,
2525
OVector<T, DimDiff<D, U1>>: Deserialize<'de>"))
2626
)]
2727
#[derive(Clone, Debug)]
2828
pub struct Hessenberg<T: Scalar, D: DimSub<U1>>
2929
where
30-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
30+
DefaultAllocator: Allocator<D, D> + Allocator<DimDiff<D, U1>>,
3131
{
3232
h: OMatrix<T, D, D>,
3333
tau: OVector<T, DimDiff<D, U1>>,
3434
}
3535

3636
impl<T: Scalar + Copy, D: DimSub<U1>> Copy for Hessenberg<T, D>
3737
where
38-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
38+
DefaultAllocator: Allocator<D, D> + Allocator<DimDiff<D, U1>>,
3939
OMatrix<T, D, D>: Copy,
4040
OVector<T, DimDiff<D, U1>>: Copy,
4141
{
4242
}
4343

4444
impl<T: HessenbergScalar + Zero, D: DimSub<U1>> Hessenberg<T, D>
4545
where
46-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
46+
DefaultAllocator: Allocator<D, D> + Allocator<DimDiff<D, U1>>,
4747
{
4848
/// Computes the hessenberg decomposition of the matrix `m`.
4949
pub fn new(mut m: OMatrix<T, D, D>) -> Self {
@@ -97,7 +97,7 @@ where
9797

9898
impl<T: HessenbergReal + Zero, D: DimSub<U1>> Hessenberg<T, D>
9999
where
100-
DefaultAllocator: Allocator<T, D, D> + Allocator<T, DimDiff<D, U1>>,
100+
DefaultAllocator: Allocator<D, D> + Allocator<DimDiff<D, U1>>,
101101
{
102102
/// Computes the matrices `(Q, H)` of this decomposition.
103103
#[inline]

0 commit comments

Comments
 (0)