Skip to content

Commit e6dd39d

Browse files
committed
Fix compiler warnings and most clippy warnings
1 parent d8a8585 commit e6dd39d

File tree

18 files changed

+84
-85
lines changed

18 files changed

+84
-85
lines changed

src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ where
2828
S: Data,
2929
{
3030
let n = a.len();
31-
a.into_shape((n)).unwrap()
31+
a.into_shape(n).unwrap()
3232
}
3333

3434
pub fn into_matrix<A, S>(l: MatrixLayout, a: Vec<A>) -> Result<ArrayBase<S, Ix2>>

src/diagonal.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub trait IntoDiagonal<S: Data> {
1515
}
1616

1717
pub trait AsDiagonal<A> {
18-
fn as_diagonal<'a>(&'a self) -> Diagonal<ViewRepr<&'a A>>;
18+
fn as_diagonal(&self) -> Diagonal<ViewRepr<&A>>;
1919
}
2020

2121
impl<S: Data> IntoDiagonal<S> for ArrayBase<S, Ix1> {
@@ -25,7 +25,7 @@ impl<S: Data> IntoDiagonal<S> for ArrayBase<S, Ix1> {
2525
}
2626

2727
impl<A, S: Data<Elem = A>> AsDiagonal<A> for ArrayBase<S, Ix1> {
28-
fn as_diagonal<'a>(&'a self) -> Diagonal<ViewRepr<&'a A>> {
28+
fn as_diagonal(&self) -> Diagonal<ViewRepr<&A>> {
2929
Diagonal { diag: self.view() }
3030
}
3131
}
@@ -36,7 +36,7 @@ where
3636
S: Data<Elem = A>,
3737
Sr: DataMut<Elem = A>,
3838
{
39-
fn op_inplace<'a>(&self, mut a: &'a mut ArrayBase<Sr, Ix1>) -> &'a mut ArrayBase<Sr, Ix1> {
39+
fn op_inplace<'a>(&self, a: &'a mut ArrayBase<Sr, Ix1>) -> &'a mut ArrayBase<Sr, Ix1> {
4040
for (val, d) in a.iter_mut().zip(self.diag.iter()) {
4141
*val = *val * *d;
4242
}
@@ -64,7 +64,7 @@ where
6464
Sr: DataOwned<Elem = A> + DataMut,
6565
{
6666
fn op_into(&self, mut a: ArrayBase<Sr, Ix1>) -> ArrayBase<Sr, Ix1> {
67-
self.op(&mut a);
67+
self.op_inplace(&mut a);
6868
a
6969
}
7070
}
@@ -75,8 +75,8 @@ where
7575
S: Data<Elem = A>,
7676
Sr: DataMut<Elem = A>,
7777
{
78-
fn op_inplace<'a>(&self, mut a: &'a mut ArrayBase<Sr, Ix2>) -> &'a mut ArrayBase<Sr, Ix2> {
79-
let ref d = self.diag;
78+
fn op_inplace<'a>(&self, a: &'a mut ArrayBase<Sr, Ix2>) -> &'a mut ArrayBase<Sr, Ix2> {
79+
let d = &self.diag;
8080
for ((i, _), val) in a.indexed_iter_mut() {
8181
*val = *val * d[i];
8282
}
@@ -104,7 +104,7 @@ where
104104
Sr: DataOwned<Elem = A> + DataMut,
105105
{
106106
fn op_into(&self, mut a: ArrayBase<Sr, Ix2>) -> ArrayBase<Sr, Ix2> {
107-
self.op(&mut a);
107+
self.op_inplace(&mut a);
108108
a
109109
}
110110
}

src/lapack_traits/cholesky.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub trait Cholesky_: Sized {
2424
macro_rules! impl_cholesky {
2525
($scalar:ty, $trf:path, $tri:path, $trs:path) => {
2626
impl Cholesky_ for $scalar {
27-
unsafe fn cholesky(l: MatrixLayout, uplo: UPLO, mut a: &mut [Self]) -> Result<()> {
27+
unsafe fn cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()> {
2828
let (n, _) = l.size();
2929
let info = $trf(l.lapacke_layout(), uplo as u8, n, a, n);
3030
into_result(info, ())

src/lapack_traits/qr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl QR_ for $scalar {
3535
into_result(info, ())
3636
}
3737

38-
unsafe fn qr(l: MatrixLayout, mut a: &mut [Self]) -> Result<Vec<Self>> {
38+
unsafe fn qr(l: MatrixLayout, a: &mut [Self]) -> Result<Vec<Self>> {
3939
let tau = Self::householder(l, a)?;
4040
let r = Vec::from(&*a);
4141
Self::q(l, a, &tau)?;

src/layout.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ impl MatrixLayout {
3333

3434
pub fn lda(&self) -> LDA {
3535
match *self {
36-
MatrixLayout::C((_, lda)) => lda,
37-
MatrixLayout::F((_, lda)) => lda,
36+
MatrixLayout::C((_, lda)) | MatrixLayout::F((_, lda)) => lda,
3837
}
3938
}
4039

@@ -123,7 +122,7 @@ where
123122
}
124123

125124
fn as_allocated(&self) -> Result<&[A]> {
126-
Ok(self.as_slice_memory_order().ok_or(MemoryContError::new())?)
125+
Ok(self.as_slice_memory_order().ok_or_else(MemoryContError::new)?)
127126
}
128127
}
129128

@@ -132,8 +131,8 @@ where
132131
S: DataMut<Elem = A>,
133132
{
134133
fn as_allocated_mut(&mut self) -> Result<&mut [A]> {
135-
Ok(self.as_slice_memory_order_mut().ok_or(
136-
MemoryContError::new(),
134+
Ok(self.as_slice_memory_order_mut().ok_or_else(
135+
MemoryContError::new,
137136
)?)
138137
}
139138
}

src/operator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ where
9595
D: Dimension + RemoveAxis,
9696
for<'a> T: OperatorInplace<ViewRepr<&'a mut A>, D::Smaller>,
9797
{
98-
fn op_multi_inplace<'a>(&self, mut a: &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D> {
98+
fn op_multi_inplace<'a>(&self, a: &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D> {
9999
let n = a.ndim();
100100
for mut col in a.axis_iter_mut(Axis(n - 1)) {
101101
self.op_inplace(&mut col);

src/opnorm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pub use lapack_traits::NormType;
1010

1111
/// Operator norm using `*lange` LAPACK routines
1212
///
13-
/// https://en.wikipedia.org/wiki/Operator_norm
13+
/// [Wikipedia article on operator norm](https://en.wikipedia.org/wiki/Operator_norm)
1414
pub trait OperationNorm {
1515
/// the value of norm
1616
type Output: RealScalar;

src/qr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! QR decomposition
22
//!
3-
//! https://en.wikipedia.org/wiki/QR_decomposition
3+
//! [Wikipedia article on QR decomposition](https://en.wikipedia.org/wiki/QR_decomposition)
44
55
use ndarray::*;
66
use num_traits::Zero;
@@ -49,7 +49,7 @@ pub trait QRSquareInto: Sized {
4949
/// QR decomposition for mutable reference of square matrix
5050
pub trait QRSquareInplace: Sized {
5151
type R;
52-
fn qr_square_inplace<'a>(&'a mut self) -> Result<(&'a mut Self, Self::R)>;
52+
fn qr_square_inplace(&mut self) -> Result<(&mut Self, Self::R)>;
5353
}
5454

5555
impl<A, S> QRSquareInplace for ArrayBase<S, Ix2>
@@ -59,7 +59,7 @@ where
5959
{
6060
type R = Array2<A>;
6161

62-
fn qr_square_inplace<'a>(&'a mut self) -> Result<(&'a mut Self, Self::R)> {
62+
fn qr_square_inplace(&mut self) -> Result<(&mut Self, Self::R)> {
6363
let l = self.square_layout()?;
6464
let r = unsafe { A::qr(l, self.as_allocated_mut()?)? };
6565
let r: Array2<_> = into_matrix(l, r)?;

src/solve.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ where
141141
A: Scalar,
142142
S: Data<Elem = A>,
143143
{
144-
fn solve_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
144+
fn solve_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
145145
where
146146
Sb: DataMut<Elem = A>,
147147
{
@@ -156,7 +156,7 @@ where
156156
};
157157
Ok(rhs)
158158
}
159-
fn solve_t_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
159+
fn solve_t_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
160160
where
161161
Sb: DataMut<Elem = A>,
162162
{
@@ -171,7 +171,7 @@ where
171171
};
172172
Ok(rhs)
173173
}
174-
fn solve_h_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
174+
fn solve_h_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
175175
where
176176
Sb: DataMut<Elem = A>,
177177
{
@@ -193,21 +193,21 @@ where
193193
A: Scalar,
194194
S: Data<Elem = A>,
195195
{
196-
fn solve_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
196+
fn solve_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
197197
where
198198
Sb: DataMut<Elem = A>,
199199
{
200200
let f = self.factorize()?;
201201
f.solve_inplace(rhs)
202202
}
203-
fn solve_t_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
203+
fn solve_t_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
204204
where
205205
Sb: DataMut<Elem = A>,
206206
{
207207
let f = self.factorize()?;
208208
f.solve_t_inplace(rhs)
209209
}
210-
fn solve_h_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
210+
fn solve_h_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
211211
where
212212
Sb: DataMut<Elem = A>,
213213
{

src/solveh.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ where
122122
A: Scalar,
123123
S: Data<Elem = A>,
124124
{
125-
fn solveh_inplace<'a, Sb>(&self, mut rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
125+
fn solveh_inplace<'a, Sb>(&self, rhs: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
126126
where
127127
Sb: DataMut<Elem = A>,
128128
{

0 commit comments

Comments
 (0)