Skip to content

Commit b729220

Browse files
committed
Format in default settings
1 parent 6379b5b commit b729220

32 files changed

+497
-110
lines changed

examples/truncated_svd.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ fn main() {
88
let a = arr2(&[[3., 2., 2.], [2., 3., -2.]]);
99

1010
// calculate the truncated singular value decomposition for 2 singular values
11-
let result = TruncatedSvd::new(a, TruncatedOrder::Largest).decompose(2).unwrap();
11+
let result = TruncatedSvd::new(a, TruncatedOrder::Largest)
12+
.decompose(2)
13+
.unwrap();
1214

1315
// acquire singular values, left-singular vectors and right-singular vectors
1416
let (u, sigma, v_t) = result.values_vectors();

src/cholesky.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ where
166166
A: Scalar + Lapack,
167167
S: Data<Elem = A>,
168168
{
169-
fn solvec_inplace<'a, Sb>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
169+
fn solvec_inplace<'a, Sb>(
170+
&self,
171+
b: &'a mut ArrayBase<Sb, Ix1>,
172+
) -> Result<&'a mut ArrayBase<Sb, Ix1>>
170173
where
171174
Sb: DataMut<Elem = A>,
172175
{
@@ -327,7 +330,10 @@ pub trait SolveC<A: Scalar> {
327330
/// Solves a system of linear equations `A * x = b` with Hermitian (or real
328331
/// symmetric) positive definite matrix `A`, where `A` is `self`, `b` is
329332
/// the argument, and `x` is the successful result.
330-
fn solvec_into<S: DataMut<Elem = A>>(&self, mut b: ArrayBase<S, Ix1>) -> Result<ArrayBase<S, Ix1>> {
333+
fn solvec_into<S: DataMut<Elem = A>>(
334+
&self,
335+
mut b: ArrayBase<S, Ix1>,
336+
) -> Result<ArrayBase<S, Ix1>> {
331337
self.solvec_inplace(&mut b)?;
332338
Ok(b)
333339
}
@@ -346,7 +352,10 @@ where
346352
A: Scalar + Lapack,
347353
S: Data<Elem = A>,
348354
{
349-
fn solvec_inplace<'a, Sb>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
355+
fn solvec_inplace<'a, Sb>(
356+
&self,
357+
b: &'a mut ArrayBase<Sb, Ix1>,
358+
) -> Result<&'a mut ArrayBase<Sb, Ix1>>
350359
where
351360
Sb: DataMut<Elem = A>,
352361
{

src/convert.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,11 @@ where
9393
} else {
9494
ArrayBase::from_shape_vec(a.dim().f(), a.into_raw_vec()).unwrap()
9595
};
96-
assert_eq!(new.strides(), strides.as_slice(), "Custom stride is not supported");
96+
assert_eq!(
97+
new.strides(),
98+
strides.as_slice(),
99+
"Custom stride is not supported"
100+
);
97101
new
98102
}
99103

src/eig.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ where
2929
let (n, _) = layout.size();
3030
Ok((
3131
ArrayBase::from(s),
32-
ArrayBase::from(t).into_shape((n as usize, n as usize)).unwrap(),
32+
ArrayBase::from(t)
33+
.into_shape((n as usize, n as usize))
34+
.unwrap(),
3335
))
3436
}
3537
}

src/error.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,15 @@ pub enum LinalgError {
2424
impl fmt::Display for LinalgError {
2525
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2626
match self {
27-
LinalgError::NotSquare { rows, cols } => write!(f, "Not square: rows({}) != cols({})", rows, cols),
28-
LinalgError::Lapack { return_code } => write!(f, "LAPACK: return_code = {}", return_code),
29-
LinalgError::InvalidStride { s0, s1 } => write!(f, "invalid stride: s0={}, s1={}", s0, s1),
27+
LinalgError::NotSquare { rows, cols } => {
28+
write!(f, "Not square: rows({}) != cols({})", rows, cols)
29+
}
30+
LinalgError::Lapack { return_code } => {
31+
write!(f, "LAPACK: return_code = {}", return_code)
32+
}
33+
LinalgError::InvalidStride { s0, s1 } => {
34+
write!(f, "invalid stride: s0={}, s1={}", s0, s1)
35+
}
3036
LinalgError::MemoryNotCont => write!(f, "Memory is not contiguous"),
3137
LinalgError::Shape(err) => write!(f, "Shape Error: {}", err),
3238
}

src/inner.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ where
2424
assert_eq!(self.len(), rhs.len());
2525
Zip::from(self)
2626
.and(rhs)
27-
.fold_while(A::zero(), |acc, s, r| FoldWhile::Continue(acc + s.conj() * *r))
27+
.fold_while(A::zero(), |acc, s, r| {
28+
FoldWhile::Continue(acc + s.conj() * *r)
29+
})
2830
.into_inner()
2931
}
3032
}

src/krylov/arnoldi.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ where
9797
}
9898

9999
/// Utility to execute Arnoldi iteration with Householder reflection
100-
pub fn arnoldi_householder<A, S>(a: impl LinearOperator<Elem = A>, v: ArrayBase<S, Ix1>, tol: A::Real) -> (Q<A>, H<A>)
100+
pub fn arnoldi_householder<A, S>(
101+
a: impl LinearOperator<Elem = A>,
102+
v: ArrayBase<S, Ix1>,
103+
tol: A::Real,
104+
) -> (Q<A>, H<A>)
101105
where
102106
A: Scalar + Lapack,
103107
S: DataMut<Elem = A>,
@@ -107,7 +111,11 @@ where
107111
}
108112

109113
/// Utility to execute Arnoldi iteration with modified Gram-Schmit orthogonalizer
110-
pub fn arnoldi_mgs<A, S>(a: impl LinearOperator<Elem = A>, v: ArrayBase<S, Ix1>, tol: A::Real) -> (Q<A>, H<A>)
114+
pub fn arnoldi_mgs<A, S>(
115+
a: impl LinearOperator<Elem = A>,
116+
v: ArrayBase<S, Ix1>,
117+
tol: A::Real,
118+
) -> (Q<A>, H<A>)
111119
where
112120
A: Scalar + Lapack,
113121
S: DataMut<Elem = A>,

src/krylov/householder.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ impl<A: Scalar + Lapack> Householder<A> {
7171
S: DataMut<Elem = A>,
7272
{
7373
assert!(k < self.v.len());
74-
assert_eq!(a.len(), self.dim, "Input array size mismaches to the dimension");
74+
assert_eq!(
75+
a.len(),
76+
self.dim,
77+
"Input array size mismaches to the dimension"
78+
);
7579
reflect(&self.v[k].slice(s![k..]), &mut a.slice_mut(s![k..]));
7680
}
7781

src/lapack/cholesky.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ pub trait Cholesky_: Sized {
1818
/// **Warning: Only the portion of `a` corresponding to `UPLO` is written.**
1919
unsafe fn inv_cholesky(l: MatrixLayout, uplo: UPLO, a: &mut [Self]) -> Result<()>;
2020
/// Wrapper of `*potrs`
21-
unsafe fn solve_cholesky(l: MatrixLayout, uplo: UPLO, a: &[Self], b: &mut [Self]) -> Result<()>;
21+
unsafe fn solve_cholesky(l: MatrixLayout, uplo: UPLO, a: &[Self], b: &mut [Self])
22+
-> Result<()>;
2223
}
2324

2425
macro_rules! impl_cholesky {
@@ -36,7 +37,12 @@ macro_rules! impl_cholesky {
3637
into_result(info, ())
3738
}
3839

39-
unsafe fn solve_cholesky(l: MatrixLayout, uplo: UPLO, a: &[Self], b: &mut [Self]) -> Result<()> {
40+
unsafe fn solve_cholesky(
41+
l: MatrixLayout,
42+
uplo: UPLO,
43+
a: &[Self],
44+
b: &mut [Self],
45+
) -> Result<()> {
4046
let (n, _) = l.size();
4147
let nrhs = 1;
4248
let ldb = 1;

src/lapack/eig.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ use super::into_result;
1111

1212
/// Wraps `*geev` for real/complex
1313
pub trait Eig_: Scalar {
14-
unsafe fn eig(calc_v: bool, l: MatrixLayout, a: &mut [Self]) -> Result<(Vec<Self::Complex>, Vec<Self::Complex>)>;
14+
unsafe fn eig(
15+
calc_v: bool,
16+
l: MatrixLayout,
17+
a: &mut [Self],
18+
) -> Result<(Vec<Self::Complex>, Vec<Self::Complex>)>;
1519
}
1620

1721
macro_rules! impl_eig_complex {

0 commit comments

Comments
 (0)