Skip to content

Commit

Permalink
Squash warnings for Nalgebra 0.26.x (#118)
Browse files Browse the repository at this point in the history
* Replace deprecated Nalgebra mat type

- Squashes warnings after upgrading to Nalgebra 0.26.x
- Fixes #117

* Bump nalgebra to latest
  • Loading branch information
CattleProdigy authored Jun 1, 2021
1 parent 4cc67c6 commit efa681f
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 46 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ctrlc = { version = "3.1.2", optional = true }
instant = {version = "0.1", features = ["now"] }
gnuplot = { version = "0.0.37", optional = true}
paste = "1.0.0"
nalgebra = { version = "0.26.1", optional = true, features = ["serde-serialize"] }
nalgebra = { version = "0.26.2", optional = true, features = ["serde-serialize"] }
ndarray = { version = "0.14", optional = true, features = ["serde-1"] }
ndarray-linalg = { version = "0.13", optional = true }
ndarray-rand = {version = "0.13.0", optional = true }
Expand Down
10 changes: 5 additions & 5 deletions src/core/math/add_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use nalgebra::{
storage::Storage,
Scalar,
},
ClosedAdd, DefaultAllocator, Matrix, MatrixMN, MatrixSum,
ClosedAdd, DefaultAllocator, Matrix, MatrixSum, OMatrix,
};

impl<N, R, C, S> ArgminAdd<N, MatrixMN<N, R, C>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminAdd<N, OMatrix<N, R, C>> for Matrix<N, R, C, S>
where
N: Scalar + ClosedAdd + Copy,
R: Dim,
Expand All @@ -27,12 +27,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn add(&self, other: &N) -> MatrixMN<N, R, C> {
fn add(&self, other: &N) -> OMatrix<N, R, C> {
self.add_scalar(*other)
}
}

impl<N, R, C, S> ArgminAdd<Matrix<N, R, C, S>, MatrixMN<N, R, C>> for N
impl<N, R, C, S> ArgminAdd<Matrix<N, R, C, S>, OMatrix<N, R, C>> for N
where
N: Scalar + ClosedAdd + Copy,
R: Dim,
Expand All @@ -41,7 +41,7 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn add(&self, other: &Matrix<N, R, C, S>) -> MatrixMN<N, R, C> {
fn add(&self, other: &Matrix<N, R, C, S>) -> OMatrix<N, R, C> {
other.add_scalar(*self)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/math/conj_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ use crate::core::math::ArgminConj;

use nalgebra::{
base::{allocator::Allocator, dimension::Dim},
DefaultAllocator, MatrixMN, SimdComplexField,
DefaultAllocator, OMatrix, SimdComplexField,
};

impl<N, R, C> ArgminConj for MatrixMN<N, R, C>
impl<N, R, C> ArgminConj for OMatrix<N, R, C>
where
N: SimdComplexField,
R: Dim,
C: Dim,
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn conj(&self) -> MatrixMN<N, R, C> {
fn conj(&self) -> OMatrix<N, R, C> {
self.conjugate()
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/core/math/div_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use nalgebra::{
storage::Storage,
MatrixSum, Scalar,
},
ClosedDiv, DefaultAllocator, Matrix, MatrixMN,
ClosedDiv, DefaultAllocator, Matrix, OMatrix,
};

impl<N, R, C, S> ArgminDiv<N, MatrixMN<N, R, C>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminDiv<N, OMatrix<N, R, C>> for Matrix<N, R, C, S>
where
N: Scalar + Copy + ClosedDiv,
R: Dim,
Expand All @@ -27,12 +27,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn div(&self, other: &N) -> MatrixMN<N, R, C> {
fn div(&self, other: &N) -> OMatrix<N, R, C> {
self / *other
}
}

impl<N, R, C, S> ArgminDiv<Matrix<N, R, C, S>, MatrixMN<N, R, C>> for N
impl<N, R, C, S> ArgminDiv<Matrix<N, R, C, S>, OMatrix<N, R, C>> for N
where
N: Scalar + Copy + ClosedDiv,
R: Dim,
Expand All @@ -41,7 +41,7 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn div(&self, other: &Matrix<N, R, C, S>) -> MatrixMN<N, R, C> {
fn div(&self, other: &Matrix<N, R, C, S>) -> OMatrix<N, R, C> {
other.map(|entry| *self / entry)
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/math/dot_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use nalgebra::{
storage::Storage,
Scalar,
},
ClosedAdd, ClosedMul, DefaultAllocator, Matrix, MatrixMN,
ClosedAdd, ClosedMul, DefaultAllocator, Matrix, OMatrix,
};

impl<N, R1, R2, C1, C2, SA, SB> ArgminDot<Matrix<N, R2, C2, SB>, N> for Matrix<N, R1, C1, SA>
Expand All @@ -37,7 +37,7 @@ where
}
}

impl<N, R, C, S> ArgminDot<N, MatrixMN<N, R, C>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminDot<N, OMatrix<N, R, C>> for Matrix<N, R, C, S>
where
N: Scalar + Copy + ClosedMul,
R: Dim,
Expand All @@ -46,12 +46,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn dot(&self, other: &N) -> MatrixMN<N, R, C> {
fn dot(&self, other: &N) -> OMatrix<N, R, C> {
self * *other
}
}

impl<N, R, C, S> ArgminDot<Matrix<N, R, C, S>, MatrixMN<N, R, C>> for N
impl<N, R, C, S> ArgminDot<Matrix<N, R, C, S>, OMatrix<N, R, C>> for N
where
N: Scalar + Copy + ClosedMul,
R: Dim,
Expand All @@ -60,12 +60,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn dot(&self, other: &Matrix<N, R, C, S>) -> MatrixMN<N, R, C> {
fn dot(&self, other: &Matrix<N, R, C, S>) -> OMatrix<N, R, C> {
other * *self
}
}

impl<N, R1, R2, C1, C2, SA, SB> ArgminDot<Matrix<N, R2, C2, SB>, MatrixMN<N, R1, C2>>
impl<N, R1, R2, C1, C2, SA, SB> ArgminDot<Matrix<N, R2, C2, SB>, OMatrix<N, R1, C2>>
for Matrix<N, R1, C1, SA>
where
N: Scalar + Zero + One + ClosedAdd + ClosedMul,
Expand All @@ -79,7 +79,7 @@ where
ShapeConstraint: AreMultipliable<R1, C1, R2, C2>,
{
#[inline]
fn dot(&self, other: &Matrix<N, R2, C2, SB>) -> MatrixMN<N, R1, C2> {
fn dot(&self, other: &Matrix<N, R2, C2, SB>) -> OMatrix<N, R1, C2> {
self * other
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/math/eye_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ use num::{One, Zero};

use nalgebra::{
base::{allocator::Allocator, dimension::Dim},
DefaultAllocator, MatrixMN, Scalar,
DefaultAllocator, OMatrix, Scalar,
};

impl<N, R, C> ArgminEye for MatrixMN<N, R, C>
impl<N, R, C> ArgminEye for OMatrix<N, R, C>
where
N: Scalar + Zero + One,
R: Dim,
C: Dim,
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn eye_like(&self) -> MatrixMN<N, R, C> {
fn eye_like(&self) -> OMatrix<N, R, C> {
assert!(self.is_square());
Self::identity_generic(R::from_usize(self.nrows()), C::from_usize(self.ncols()))
}

#[inline]
fn eye(n: usize) -> MatrixMN<N, R, C> {
fn eye(n: usize) -> OMatrix<N, R, C> {
Self::identity_generic(R::from_usize(n), C::from_usize(n))
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/math/inv_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ use crate::core::{errors::ArgminError, math::ArgminInv, Error};

use nalgebra::{
base::{allocator::Allocator, dimension::Dim, storage::Storage},
ComplexField, DefaultAllocator, MatrixN, SquareMatrix,
ComplexField, DefaultAllocator, OMatrix, SquareMatrix,
};

impl<N, D, S> ArgminInv<MatrixN<N, D>> for SquareMatrix<N, D, S>
impl<N, D, S> ArgminInv<OMatrix<N, D, D>> for SquareMatrix<N, D, S>
where
N: ComplexField,
D: Dim,
S: Storage<N, D, D>,
DefaultAllocator: Allocator<N, D, D>,
{
#[inline]
fn inv(&self) -> Result<MatrixN<N, D>, Error> {
fn inv(&self) -> Result<OMatrix<N, D, D>, Error> {
match self.clone_owned().try_inverse() {
Some(m) => Ok(m),
None => Err(ArgminError::InvalidParameter {
Expand Down
10 changes: 5 additions & 5 deletions src/core/math/mul_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use nalgebra::{
storage::Storage,
MatrixSum, Scalar,
},
ClosedMul, DefaultAllocator, Matrix, MatrixMN,
ClosedMul, DefaultAllocator, Matrix, OMatrix,
};

impl<N, R, C, S> ArgminMul<N, MatrixMN<N, R, C>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminMul<N, OMatrix<N, R, C>> for Matrix<N, R, C, S>
where
N: Scalar + Copy + ClosedMul,
R: Dim,
Expand All @@ -27,12 +27,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn mul(&self, other: &N) -> MatrixMN<N, R, C> {
fn mul(&self, other: &N) -> OMatrix<N, R, C> {
self * *other
}
}

impl<N, R, C, S> ArgminMul<Matrix<N, R, C, S>, MatrixMN<N, R, C>> for N
impl<N, R, C, S> ArgminMul<Matrix<N, R, C, S>, OMatrix<N, R, C>> for N
where
N: Scalar + Copy + ClosedMul,
R: Dim,
Expand All @@ -41,7 +41,7 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn mul(&self, other: &Matrix<N, R, C, S>) -> MatrixMN<N, R, C> {
fn mul(&self, other: &Matrix<N, R, C, S>) -> OMatrix<N, R, C> {
other * *self
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/math/sub_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ use crate::core::math::ArgminSub;

use nalgebra::{
base::{allocator::Allocator, dimension::Dim, storage::Storage, Scalar},
ClosedSub, DefaultAllocator, Matrix, MatrixMN,
ClosedSub, DefaultAllocator, Matrix, OMatrix,
};

impl<N, R, C, S> ArgminSub<N, MatrixMN<N, R, C>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminSub<N, OMatrix<N, R, C>> for Matrix<N, R, C, S>
where
N: Scalar + Copy + Sub<Output = N>,
R: Dim,
Expand All @@ -23,12 +23,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn sub(&self, other: &N) -> MatrixMN<N, R, C> {
fn sub(&self, other: &N) -> OMatrix<N, R, C> {
self.map(|entry| entry - *other)
}
}

impl<N, R, C, S> ArgminSub<Matrix<N, R, C, S>, MatrixMN<N, R, C>> for N
impl<N, R, C, S> ArgminSub<Matrix<N, R, C, S>, OMatrix<N, R, C>> for N
where
N: Scalar + Copy + Sub<Output = N>,
R: Dim,
Expand All @@ -37,12 +37,12 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn sub(&self, other: &Matrix<N, R, C, S>) -> MatrixMN<N, R, C> {
fn sub(&self, other: &Matrix<N, R, C, S>) -> OMatrix<N, R, C> {
other.map(|entry| *self - entry)
}
}

impl<N, R, C, S> ArgminSub<Matrix<N, R, C, S>, MatrixMN<N, R, C>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminSub<Matrix<N, R, C, S>, OMatrix<N, R, C>> for Matrix<N, R, C, S>
where
N: Scalar + ClosedSub,
R: Dim,
Expand All @@ -51,7 +51,7 @@ where
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn sub(&self, other: &Matrix<N, R, C, S>) -> MatrixMN<N, R, C> {
fn sub(&self, other: &Matrix<N, R, C, S>) -> OMatrix<N, R, C> {
self - other
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/math/transpose_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ use crate::core::math::ArgminTranspose;

use nalgebra::{
base::{allocator::Allocator, dimension::Dim, storage::Storage, Scalar},
DefaultAllocator, Matrix, MatrixMN,
DefaultAllocator, Matrix, OMatrix,
};

impl<N, R, C, S> ArgminTranspose<MatrixMN<N, C, R>> for Matrix<N, R, C, S>
impl<N, R, C, S> ArgminTranspose<OMatrix<N, C, R>> for Matrix<N, R, C, S>
where
N: Scalar,
R: Dim,
Expand All @@ -24,7 +24,7 @@ where
DefaultAllocator: Allocator<N, C, R>,
{
#[inline]
fn t(self) -> MatrixMN<N, C, R> {
fn t(self) -> OMatrix<N, C, R> {
self.transpose()
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/core/math/zero_nalgebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ use num::Zero;

use nalgebra::{
base::{allocator::Allocator, dimension::Dim},
DefaultAllocator, MatrixMN, Scalar,
DefaultAllocator, OMatrix, Scalar,
};

impl<N, R, C> ArgminZeroLike for MatrixMN<N, R, C>
impl<N, R, C> ArgminZeroLike for OMatrix<N, R, C>
where
N: Scalar + Zero + ArgminZero,
R: Dim,
C: Dim,
DefaultAllocator: Allocator<N, R, C>,
{
#[inline]
fn zero_like(&self) -> MatrixMN<N, R, C> {
fn zero_like(&self) -> OMatrix<N, R, C> {
Self::zeros_generic(R::from_usize(self.nrows()), C::from_usize(self.ncols()))
}
}
Expand Down

0 comments on commit efa681f

Please sign in to comment.