Skip to content

clippy fix #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lax/src/tridiagonal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use std::ops::{Index, IndexMut};
/// ... ..., u{n-1},
/// 0, ..., l{n-1}, d{n-1},]
/// ```
#[derive(Clone, PartialEq)]
#[derive(Clone, PartialEq, Eq)]
pub struct Tridiagonal<A: Scalar> {
/// layout of raw matrix
pub l: MatrixLayout,
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/examples/eig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use ndarray_linalg::*;

fn main() {
let a = arr2(&[[2.0, 1.0, 2.0], [-2.0, 2.0, 1.0], [1.0, 2.0, -2.0]]);
let (e, vecs) = a.clone().eig().unwrap();
let (e, vecs) = a.eig().unwrap();
println!("eigenvalues = \n{:?}", e);
println!("V = \n{:?}", vecs);
let a_c: Array2<c64> = a.map(|f| c64::new(*f, 0.0));
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/examples/eigh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use ndarray_linalg::*;

fn main() {
let a = arr2(&[[3.0, 1.0, 1.0], [1.0, 3.0, 1.0], [1.0, 1.0, 3.0]]);
let (e, vecs) = a.clone().eigh(UPLO::Upper).unwrap();
let (e, vecs) = a.eigh(UPLO::Upper).unwrap();
println!("eigenvalues = \n{:?}", e);
println!("V = \n{:?}", vecs);
let av = a.dot(&vecs);
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/krylov/householder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ where
{
assert_eq!(w.len(), a.len());
let n = a.len();
let c = A::from(2.0).unwrap() * w.inner(&a);
let c = A::from(2.0).unwrap() * w.inner(a);
for l in 0..n {
a[l] -= c * w[l];
}
Expand Down
6 changes: 3 additions & 3 deletions ndarray-linalg/src/krylov/mgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl<A: Scalar + Lapack> Orthogonalizer for MGS<A> {
let mut coef = Array1::zeros(self.len() + 1);
for i in 0..self.len() {
let q = &self.q[i];
let c = q.inner(&a);
let c = q.inner(a);
azip!((a in &mut *a, &q in q) *a -= c * q);
coef[i] = c;
}
Expand All @@ -77,12 +77,12 @@ impl<A: Scalar + Lapack> Orthogonalizer for MGS<A> {
self.div_append(&mut a)
}

fn div_append<S>(&mut self, mut a: &mut ArrayBase<S, Ix1>) -> AppendResult<A>
fn div_append<S>(&mut self, a: &mut ArrayBase<S, Ix1>) -> AppendResult<A>
where
A: Lapack,
S: DataMut<Elem = A>,
{
let coef = self.decompose(&mut a);
let coef = self.decompose(a);
let nrm = coef[coef.len() - 1].re();
if nrm < self.tol {
// Linearly dependent
Expand Down
10 changes: 4 additions & 6 deletions ndarray-linalg/src/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,8 @@ where
}

fn as_allocated(&self) -> Result<&[A]> {
Ok(self
.as_slice_memory_order()
.ok_or_else(|| LinalgError::MemoryNotCont)?)
self.as_slice_memory_order()
.ok_or(LinalgError::MemoryNotCont)
}
}

Expand All @@ -78,8 +77,7 @@ where
S: DataMut<Elem = A>,
{
fn as_allocated_mut(&mut self) -> Result<&mut [A]> {
Ok(self
.as_slice_memory_order_mut()
.ok_or_else(|| LinalgError::MemoryNotCont)?)
self.as_slice_memory_order_mut()
.ok_or(LinalgError::MemoryNotCont)
}
}
6 changes: 3 additions & 3 deletions ndarray-linalg/src/least_squares.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,12 +304,12 @@ where
a.layout()?,
a.as_allocated_mut()?,
rhs.as_slice_memory_order_mut()
.ok_or_else(|| LinalgError::MemoryNotCont)?,
.ok_or(LinalgError::MemoryNotCont)?,
)?;

let (m, n) = (a.shape()[0], a.shape()[1]);
let solution = rhs.slice(s![0..n]).to_owned();
let residual_sum_of_squares = compute_residual_scalar(m, n, rank, &rhs);
let residual_sum_of_squares = compute_residual_scalar(m, n, rank, rhs);
Ok(LeastSquaresResult {
solution,
singular_values: Array::from_shape_vec((singular_values.len(),), singular_values)?,
Expand Down Expand Up @@ -399,7 +399,7 @@ where
let solution: Array2<E> = rhs.slice(s![..a.shape()[1], ..]).to_owned();
let singular_values = Array::from_shape_vec((singular_values.len(),), singular_values)?;
let (m, n) = (a.shape()[0], a.shape()[1]);
let residual_sum_of_squares = compute_residual_array1(m, n, rank, &rhs);
let residual_sum_of_squares = compute_residual_array1(m, n, rank, rhs);
Ok(LeastSquaresResult {
solution,
singular_values,
Expand Down
3 changes: 1 addition & 2 deletions ndarray-linalg/src/lobpcg/lobpcg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,11 @@ fn apply_constraints<A: Scalar + Lapack>(
let u = gram_yv
.columns()
.into_iter()
.map(|x| {
.flat_map(|x| {
let res = cholesky_yy.solvec(&x).unwrap();

res.to_vec()
})
.flatten()
.collect::<Vec<A>>();

let rows = gram_yv.len_of(Axis(0));
Expand Down
2 changes: 1 addition & 1 deletion ndarray-linalg/src/lobpcg/svd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl<A: Float + PartialOrd + DivAssign<A> + 'static + MagnitudeCorrection> Trunc
let mut a = self.eigvals.iter().enumerate().collect::<Vec<_>>();

// sort by magnitude
a.sort_by(|(_, x), (_, y)| x.partial_cmp(&y).unwrap().reverse());
a.sort_by(|(_, x), (_, y)| x.partial_cmp(y).unwrap().reverse());

// calculate cut-off magnitude (borrowed from scipy)
let cutoff = A::epsilon() * // float precision
Expand Down
10 changes: 5 additions & 5 deletions ndarray-linalg/src/tridiagonal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ where
Sb: DataMut<Elem = A>,
{
A::solve_tridiagonal(
&self,
self,
rhs.layout()?,
Transpose::No,
rhs.as_slice_mut().unwrap(),
Expand All @@ -287,7 +287,7 @@ where
Sb: DataMut<Elem = A>,
{
A::solve_tridiagonal(
&self,
self,
rhs.layout()?,
Transpose::Transpose,
rhs.as_slice_mut().unwrap(),
Expand All @@ -302,7 +302,7 @@ where
Sb: DataMut<Elem = A>,
{
A::solve_tridiagonal(
&self,
self,
rhs.layout()?,
Transpose::Hermite,
rhs.as_slice_mut().unwrap(),
Expand Down Expand Up @@ -622,7 +622,7 @@ where
{
fn det_tridiagonal(&self) -> Result<A> {
let n = self.d.len();
Ok(rec_rel(&self)[n])
Ok(rec_rel(self)[n])
}
}

Expand Down Expand Up @@ -671,7 +671,7 @@ where
A: Scalar + Lapack,
{
fn rcond_tridiagonal(&self) -> Result<A::Real> {
Ok(A::rcond_tridiagonal(&self)?)
Ok(A::rcond_tridiagonal(self)?)
}
}

Expand Down