Skip to content

Commit 3d0dfa8

Browse files
authored
Merge pull request #84 from jturner314/rename-mut-inplace
Rename *_mut to *_inplace to match ndarray
2 parents d5898c4 + 7b5410f commit 3d0dfa8

File tree

10 files changed

+85
-83
lines changed

10 files changed

+85
-83
lines changed

src/cholesky.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ where
159159
A: Scalar,
160160
S: Data<Elem = A>,
161161
{
162-
fn solvec_mut<'a, Sb>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
162+
fn solvec_inplace<'a, Sb>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
163163
where
164164
Sb: DataMut<Elem = A>,
165165
{
@@ -205,7 +205,7 @@ pub trait CholeskyInto {
205205
}
206206

207207
/// Cholesky decomposition of Hermitian (or real symmetric) positive definite mutable reference of matrix
208-
pub trait CholeskyMut {
208+
pub trait CholeskyInplace {
209209
/// Computes the Cholesky decomposition of the Hermitian (or real
210210
/// symmetric) positive definite matrix, writing the result (`L` or `U`
211211
/// according to the argument) to `self` and returning it.
@@ -214,7 +214,7 @@ pub trait CholeskyMut {
214214
/// U^H * U` using the upper triangular portion of `A` and writes `U`.
215215
/// Otherwise, if the argument is `UPLO::Lower`, computes the decomposition
216216
/// `A = L * L^H` using the lower triangular portion of `A` and writes `L`.
217-
fn cholesky_mut(&mut self, UPLO) -> Result<&mut Self>;
217+
fn cholesky_inplace(&mut self, UPLO) -> Result<&mut Self>;
218218
}
219219

220220
impl<A, S> Cholesky for ArrayBase<S, Ix2>
@@ -238,17 +238,17 @@ where
238238
type Output = Self;
239239

240240
fn cholesky_into(mut self, uplo: UPLO) -> Result<Self> {
241-
self.cholesky_mut(uplo)?;
241+
self.cholesky_inplace(uplo)?;
242242
Ok(self)
243243
}
244244
}
245245

246-
impl<A, S> CholeskyMut for ArrayBase<S, Ix2>
246+
impl<A, S> CholeskyInplace for ArrayBase<S, Ix2>
247247
where
248248
A: Scalar,
249249
S: DataMut<Elem = A>,
250250
{
251-
fn cholesky_mut(&mut self, uplo: UPLO) -> Result<&mut Self> {
251+
fn cholesky_inplace(&mut self, uplo: UPLO) -> Result<&mut Self> {
252252
unsafe { A::cholesky(self.square_layout()?, uplo, self.as_allocated_mut()?)? };
253253
Ok(self.into_triangular(uplo))
254254
}
@@ -314,33 +314,33 @@ pub trait CholeskySolve<A: Scalar> {
314314
/// the argument, and `x` is the successful result.
315315
fn solvec<S: Data<Elem = A>>(&self, b: &ArrayBase<S, Ix1>) -> Result<Array1<A>> {
316316
let mut b = replicate(b);
317-
self.solvec_mut(&mut b)?;
317+
self.solvec_inplace(&mut b)?;
318318
Ok(b)
319319
}
320320
/// Solves a system of linear equations `A * x = b` with Hermitian (or real
321321
/// symmetric) positive definite matrix `A`, where `A` is `self`, `b` is
322322
/// the argument, and `x` is the successful result.
323323
fn solvec_into<S: DataMut<Elem = A>>(&self, mut b: ArrayBase<S, Ix1>) -> Result<ArrayBase<S, Ix1>> {
324-
self.solvec_mut(&mut b)?;
324+
self.solvec_inplace(&mut b)?;
325325
Ok(b)
326326
}
327327
/// Solves a system of linear equations `A * x = b` with Hermitian (or real
328328
/// symmetric) positive definite matrix `A`, where `A` is `self`, `b` is
329329
/// the argument, and `x` is the successful result. The value of `x` is
330330
/// also assigned to the argument.
331-
fn solvec_mut<'a, S: DataMut<Elem = A>>(&self, &'a mut ArrayBase<S, Ix1>) -> Result<&'a mut ArrayBase<S, Ix1>>;
331+
fn solvec_inplace<'a, S: DataMut<Elem = A>>(&self, &'a mut ArrayBase<S, Ix1>) -> Result<&'a mut ArrayBase<S, Ix1>>;
332332
}
333333

334334
impl<A, S> CholeskySolve<A> for ArrayBase<S, Ix2>
335335
where
336336
A: Scalar,
337337
S: Data<Elem = A>,
338338
{
339-
fn solvec_mut<'a, Sb>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
339+
fn solvec_inplace<'a, Sb>(&self, b: &'a mut ArrayBase<Sb, Ix1>) -> Result<&'a mut ArrayBase<Sb, Ix1>>
340340
where
341341
Sb: DataMut<Elem = A>,
342342
{
343-
self.factorizec(UPLO::Upper)?.solvec_mut(b)
343+
self.factorizec(UPLO::Upper)?.solvec_inplace(b)
344344
}
345345
}
346346

src/diagonal.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ impl<A, S: Data<Elem = A>> AsDiagonal<A> for ArrayBase<S, Ix1> {
3030
}
3131
}
3232

33-
impl<A, S, Sr> OperatorMut<Sr, Ix1> for Diagonal<S>
33+
impl<A, S, Sr> OperatorInplace<Sr, Ix1> for Diagonal<S>
3434
where
3535
A: LinalgScalar,
3636
S: Data<Elem = A>,
3737
Sr: DataMut<Elem = A>,
3838
{
39-
fn op_mut<'a>(&self, mut a: &'a mut ArrayBase<Sr, Ix1>) -> &'a mut ArrayBase<Sr, Ix1> {
39+
fn op_inplace<'a>(&self, mut 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
}
@@ -52,7 +52,7 @@ where
5252
{
5353
fn op(&self, a: &ArrayBase<Sr, Ix1>) -> Array1<A> {
5454
let mut a = replicate(a);
55-
self.op_mut(&mut a);
55+
self.op_inplace(&mut a);
5656
a
5757
}
5858
}
@@ -69,13 +69,13 @@ where
6969
}
7070
}
7171

72-
impl<A, S, Sr> OperatorMut<Sr, Ix2> for Diagonal<S>
72+
impl<A, S, Sr> OperatorInplace<Sr, Ix2> for Diagonal<S>
7373
where
7474
A: LinalgScalar,
7575
S: Data<Elem = A>,
7676
Sr: DataMut<Elem = A>,
7777
{
78-
fn op_mut<'a>(&self, mut a: &'a mut ArrayBase<Sr, Ix2>) -> &'a mut ArrayBase<Sr, Ix2> {
78+
fn op_inplace<'a>(&self, mut a: &'a mut ArrayBase<Sr, Ix2>) -> &'a mut ArrayBase<Sr, Ix2> {
7979
let ref d = self.diag;
8080
for ((i, _), val) in a.indexed_iter_mut() {
8181
*val = *val * d[i];
@@ -92,7 +92,7 @@ where
9292
{
9393
fn op(&self, a: &ArrayBase<Sr, Ix2>) -> Array2<A> {
9494
let mut a = replicate(a);
95-
self.op_mut(&mut a);
95+
self.op_inplace(&mut a);
9696
a
9797
}
9898
}

src/eigh.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ pub trait Eigh {
1717
}
1818

1919
/// Eigenvalue decomposition of mutable reference of Hermite matrix
20-
pub trait EighMut {
20+
pub trait EighInplace {
2121
type EigVal;
22-
fn eigh_mut(&mut self, UPLO) -> Result<(Self::EigVal, &mut Self)>;
22+
fn eigh_inplace(&mut self, UPLO) -> Result<(Self::EigVal, &mut Self)>;
2323
}
2424

2525
/// Eigenvalue decomposition of Hermite matrix
@@ -36,7 +36,7 @@ where
3636
type EigVal = Array1<A::Real>;
3737

3838
fn eigh_into(mut self, uplo: UPLO) -> Result<(Self::EigVal, Self)> {
39-
let (val, _) = self.eigh_mut(uplo)?;
39+
let (val, _) = self.eigh_inplace(uplo)?;
4040
Ok((val, self))
4141
}
4242
}
@@ -55,14 +55,14 @@ where
5555
}
5656
}
5757

58-
impl<A, S> EighMut for ArrayBase<S, Ix2>
58+
impl<A, S> EighInplace for ArrayBase<S, Ix2>
5959
where
6060
A: Scalar,
6161
S: DataMut<Elem = A>,
6262
{
6363
type EigVal = Array1<A::Real>;
6464

65-
fn eigh_mut(&mut self, uplo: UPLO) -> Result<(Self::EigVal, &mut Self)> {
65+
fn eigh_inplace(&mut self, uplo: UPLO) -> Result<(Self::EigVal, &mut Self)> {
6666
let s = unsafe { A::eigh(true, self.square_layout()?, uplo, self.as_allocated_mut()?)? };
6767
Ok((ArrayBase::from_vec(s), self))
6868
}
@@ -81,9 +81,9 @@ pub trait EigValshInto {
8181
}
8282

8383
/// Calculate eigenvalues without eigenvectors
84-
pub trait EigValshMut {
84+
pub trait EigValshInplace {
8585
type EigVal;
86-
fn eigvalsh_mut(&mut self, UPLO) -> Result<Self::EigVal>;
86+
fn eigvalsh_inplace(&mut self, UPLO) -> Result<Self::EigVal>;
8787
}
8888

8989
impl<A, S> EigValshInto for ArrayBase<S, Ix2>
@@ -94,7 +94,7 @@ where
9494
type EigVal = Array1<A::Real>;
9595

9696
fn eigvalsh_into(mut self, uplo: UPLO) -> Result<Self::EigVal> {
97-
self.eigvalsh_mut(uplo)
97+
self.eigvalsh_inplace(uplo)
9898
}
9999
}
100100

@@ -111,14 +111,14 @@ where
111111
}
112112
}
113113

114-
impl<A, S> EigValshMut for ArrayBase<S, Ix2>
114+
impl<A, S> EigValshInplace for ArrayBase<S, Ix2>
115115
where
116116
A: Scalar,
117117
S: DataMut<Elem = A>,
118118
{
119119
type EigVal = Array1<A::Real>;
120120

121-
fn eigvalsh_mut(&mut self, uplo: UPLO) -> Result<Self::EigVal> {
121+
fn eigvalsh_inplace(&mut self, uplo: UPLO) -> Result<Self::EigVal> {
122122
let s = unsafe { A::eigh(true, self.square_layout()?, uplo, self.as_allocated_mut()?)? };
123123
Ok(ArrayBase::from_vec(s))
124124
}

src/operator.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ where
2020
fn op_into(&self, ArrayBase<S, D>) -> ArrayBase<S, D>;
2121
}
2222

23-
pub trait OperatorMut<S, D>
23+
pub trait OperatorInplace<S, D>
2424
where
2525
S: DataMut,
2626
D: Dimension,
2727
{
28-
fn op_mut<'a>(&self, &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D>;
28+
fn op_inplace<'a>(&self, &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D>;
2929
}
3030

3131
impl<T, A, S, D> Operator<A, S, D> for T
@@ -53,7 +53,7 @@ where
5353
A: Scalar,
5454
S: DataMut<Elem = A>,
5555
D: Dimension + RemoveAxis,
56-
for<'a> T: OperatorMut<ViewRepr<&'a mut A>, D::Smaller>,
56+
for<'a> T: OperatorInplace<ViewRepr<&'a mut A>, D::Smaller>,
5757
{
5858
fn op_multi(&self, a: &ArrayBase<S, D>) -> Array<A, D> {
5959
let a = a.to_owned();
@@ -73,32 +73,32 @@ impl<T, A, S, D> OperatorMultiInto<S, D> for T
7373
where
7474
S: DataMut<Elem = A>,
7575
D: Dimension + RemoveAxis,
76-
for<'a> T: OperatorMut<ViewRepr<&'a mut A>, D::Smaller>,
76+
for<'a> T: OperatorInplace<ViewRepr<&'a mut A>, D::Smaller>,
7777
{
7878
fn op_multi_into(&self, mut a: ArrayBase<S, D>) -> ArrayBase<S, D> {
79-
self.op_multi_mut(&mut a);
79+
self.op_multi_inplace(&mut a);
8080
a
8181
}
8282
}
8383

84-
pub trait OperatorMultiMut<S, D>
84+
pub trait OperatorMultiInplace<S, D>
8585
where
8686
S: DataMut,
8787
D: Dimension,
8888
{
89-
fn op_multi_mut<'a>(&self, &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D>;
89+
fn op_multi_inplace<'a>(&self, &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D>;
9090
}
9191

92-
impl<T, A, S, D> OperatorMultiMut<S, D> for T
92+
impl<T, A, S, D> OperatorMultiInplace<S, D> for T
9393
where
9494
S: DataMut<Elem = A>,
9595
D: Dimension + RemoveAxis,
96-
for<'a> T: OperatorMut<ViewRepr<&'a mut A>, D::Smaller>,
96+
for<'a> T: OperatorInplace<ViewRepr<&'a mut A>, D::Smaller>,
9797
{
98-
fn op_multi_mut<'a>(&self, mut a: &'a mut ArrayBase<S, D>) -> &'a mut ArrayBase<S, D> {
98+
fn op_multi_inplace<'a>(&self, mut 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)) {
101-
self.op_mut(&mut col);
101+
self.op_inplace(&mut col);
102102
}
103103
a
104104
}

src/qr.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ pub trait QRSquareInto: Sized {
4747
}
4848

4949
/// QR decomposition for mutable reference of square matrix
50-
pub trait QRSquareMut: Sized {
50+
pub trait QRSquareInplace: Sized {
5151
type R;
52-
fn qr_square_mut<'a>(&'a mut self) -> Result<(&'a mut Self, Self::R)>;
52+
fn qr_square_inplace<'a>(&'a mut self) -> Result<(&'a mut Self, Self::R)>;
5353
}
5454

55-
impl<A, S> QRSquareMut for ArrayBase<S, Ix2>
55+
impl<A, S> QRSquareInplace for ArrayBase<S, Ix2>
5656
where
5757
A: Scalar,
5858
S: DataMut<Elem = A>,
5959
{
6060
type R = Array2<A>;
6161

62-
fn qr_square_mut<'a>(&'a mut self) -> Result<(&'a mut Self, Self::R)> {
62+
fn qr_square_inplace<'a>(&'a mut self) -> Result<(&'a 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)?;
@@ -75,7 +75,7 @@ where
7575
type R = Array2<A>;
7676

7777
fn qr_square_into(mut self) -> Result<(Self, Self::R)> {
78-
let (_, r) = self.qr_square_mut()?;
78+
let (_, r) = self.qr_square_inplace()?;
7979
Ok((self, r))
8080
}
8181
}

0 commit comments

Comments
 (0)