Skip to content

Commit 93fbd00

Browse files
committed
More more clippy
1 parent edf2014 commit 93fbd00

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

src/layout.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ impl MatrixLayout {
4646
}
4747
}
4848

49+
pub fn is_empty(&self) -> bool {
50+
self.len() == 0
51+
}
52+
4953
pub fn lapacke_layout(&self) -> lapacke::Layout {
5054
match *self {
5155
MatrixLayout::C(_) => lapacke::Layout::RowMajor,

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@
4141
#![allow(
4242
clippy::module_inception,
4343
clippy::many_single_char_names,
44-
clippy::type_complexity
44+
clippy::type_complexity,
45+
clippy::ptr_arg
4546
)]
4647

4748
#[macro_use]

src/lobpcg/lobpcg.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,11 @@ fn sorted_eig<S: Data<Elem = A>, A: Scalar + Lapack>(
4646

4747
Ok(match order {
4848
Order::Largest => (
49-
vals.slice_move(s![n-size..; -1])
50-
.mapv(|x| Scalar::from_real(x)),
49+
vals.slice_move(s![n-size..; -1]).mapv(Scalar::from_real),
5150
vecs.slice_move(s![.., n-size..; -1]),
5251
),
5352
Order::Smallest => (
54-
vals.slice_move(s![..size]).mapv(|x| Scalar::from_real(x)),
53+
vals.slice_move(s![..size]).mapv(Scalar::from_real),
5554
vecs.slice_move(s![.., ..size]),
5655
),
5756
})
@@ -62,7 +61,7 @@ fn ndarray_mask<A: Scalar>(matrix: ArrayView2<A>, mask: &[bool]) -> Array2<A> {
6261
assert_eq!(mask.len(), matrix.ncols());
6362

6463
let indices = (0..mask.len())
65-
.zip(mask.into_iter())
64+
.zip(mask.iter())
6665
.filter(|(_, b)| **b)
6766
.map(|(a, _)| a)
6867
.collect::<Vec<usize>>();
@@ -435,7 +434,7 @@ pub fn lobpcg<
435434

436435
// retrieve best result and convert norm into `A`
437436
let (vals, vecs, rnorm) = best_result.unwrap();
438-
let rnorm = rnorm.into_iter().map(|x| Scalar::from_real(x)).collect();
437+
let rnorm = rnorm.into_iter().map(Scalar::from_real).collect();
439438

440439
match final_norm {
441440
Ok(_) => LobpcgResult::Ok(vals, vecs, rnorm),

src/lobpcg/svd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl<A: Float + Scalar + ScalarOperand + Lapack + PartialOrd + Default> Truncate
160160
match res {
161161
LobpcgResult::Ok(vals, vecs, _) | LobpcgResult::Err(vals, vecs, _, _) => {
162162
Ok(TruncatedSvdResult {
163-
problem: self.problem.clone(),
163+
problem: self.problem,
164164
eigvals: vals,
165165
eigvecs: vecs,
166166
ngm: n > m,

src/norm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ where
6565
for mut v in m.axis_iter_mut(Axis(axis as usize)) {
6666
let n = v.norm();
6767
ms.push(n);
68-
v.map_inplace(|x| *x = *x / A::from_real(n))
68+
v.map_inplace(|x| *x /= A::from_real(n))
6969
}
7070
(m, ms)
7171
}

src/solveh.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ where
323323
// 1x1 block at k, must be real.
324324
let elem = unsafe { a.uget((k, k)) }.re();
325325
debug_assert_eq!(elem.im(), Zero::zero());
326-
sign = sign * elem.signum();
327-
ln_det = ln_det + elem.abs().ln();
326+
sign *= elem.signum();
327+
ln_det += elem.abs().ln();
328328
} else {
329329
// 2x2 block at k..k+2.
330330

@@ -344,8 +344,8 @@ where
344344

345345
// Determinant of 2x2 block.
346346
let block_det = upper_diag * lower_diag - off_diag.square();
347-
sign = sign * block_det.signum();
348-
ln_det = ln_det + block_det.abs().ln();
347+
sign *= block_det.signum();
348+
ln_det += block_det.abs().ln();
349349

350350
// Skip the k+1 ipiv value.
351351
ipiv_enum.next();

0 commit comments

Comments
 (0)