From efa681fd68e33b5b38f8122b23d9022256e8530f Mon Sep 17 00:00:00 2001 From: CattleProdigy Date: Tue, 1 Jun 2021 12:17:05 -0400 Subject: [PATCH] Squash warnings for Nalgebra 0.26.x (#118) * Replace deprecated Nalgebra mat type - Squashes warnings after upgrading to Nalgebra 0.26.x - Fixes #117 * Bump nalgebra to latest --- Cargo.toml | 2 +- src/core/math/add_nalgebra.rs | 10 +++++----- src/core/math/conj_nalgebra.rs | 6 +++--- src/core/math/div_nalgebra.rs | 10 +++++----- src/core/math/dot_nalgebra.rs | 14 +++++++------- src/core/math/eye_nalgebra.rs | 8 ++++---- src/core/math/inv_nalgebra.rs | 6 +++--- src/core/math/mul_nalgebra.rs | 10 +++++----- src/core/math/sub_nalgebra.rs | 14 +++++++------- src/core/math/transpose_nalgebra.rs | 6 +++--- src/core/math/zero_nalgebra.rs | 6 +++--- 11 files changed, 46 insertions(+), 46 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 33811a1c2..2b53ea241 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 } diff --git a/src/core/math/add_nalgebra.rs b/src/core/math/add_nalgebra.rs index 5c80ac65d..8a6ea6c58 100644 --- a/src/core/math/add_nalgebra.rs +++ b/src/core/math/add_nalgebra.rs @@ -15,10 +15,10 @@ use nalgebra::{ storage::Storage, Scalar, }, - ClosedAdd, DefaultAllocator, Matrix, MatrixMN, MatrixSum, + ClosedAdd, DefaultAllocator, Matrix, MatrixSum, OMatrix, }; -impl ArgminAdd> for Matrix +impl ArgminAdd> for Matrix where N: Scalar + ClosedAdd + Copy, R: Dim, @@ -27,12 +27,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn add(&self, other: &N) -> MatrixMN { + fn add(&self, other: &N) -> OMatrix { self.add_scalar(*other) } } -impl ArgminAdd, MatrixMN> for N +impl ArgminAdd, OMatrix> for N where N: Scalar + ClosedAdd + Copy, R: Dim, @@ -41,7 +41,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn add(&self, other: &Matrix) -> MatrixMN { + fn add(&self, other: &Matrix) -> OMatrix { other.add_scalar(*self) } } diff --git a/src/core/math/conj_nalgebra.rs b/src/core/math/conj_nalgebra.rs index b86137ae6..455532fa2 100644 --- a/src/core/math/conj_nalgebra.rs +++ b/src/core/math/conj_nalgebra.rs @@ -9,10 +9,10 @@ use crate::core::math::ArgminConj; use nalgebra::{ base::{allocator::Allocator, dimension::Dim}, - DefaultAllocator, MatrixMN, SimdComplexField, + DefaultAllocator, OMatrix, SimdComplexField, }; -impl ArgminConj for MatrixMN +impl ArgminConj for OMatrix where N: SimdComplexField, R: Dim, @@ -20,7 +20,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn conj(&self) -> MatrixMN { + fn conj(&self) -> OMatrix { self.conjugate() } } diff --git a/src/core/math/div_nalgebra.rs b/src/core/math/div_nalgebra.rs index 62fe357ef..9dafab279 100644 --- a/src/core/math/div_nalgebra.rs +++ b/src/core/math/div_nalgebra.rs @@ -15,10 +15,10 @@ use nalgebra::{ storage::Storage, MatrixSum, Scalar, }, - ClosedDiv, DefaultAllocator, Matrix, MatrixMN, + ClosedDiv, DefaultAllocator, Matrix, OMatrix, }; -impl ArgminDiv> for Matrix +impl ArgminDiv> for Matrix where N: Scalar + Copy + ClosedDiv, R: Dim, @@ -27,12 +27,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn div(&self, other: &N) -> MatrixMN { + fn div(&self, other: &N) -> OMatrix { self / *other } } -impl ArgminDiv, MatrixMN> for N +impl ArgminDiv, OMatrix> for N where N: Scalar + Copy + ClosedDiv, R: Dim, @@ -41,7 +41,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn div(&self, other: &Matrix) -> MatrixMN { + fn div(&self, other: &Matrix) -> OMatrix { other.map(|entry| *self / entry) } } diff --git a/src/core/math/dot_nalgebra.rs b/src/core/math/dot_nalgebra.rs index 996ab5da3..d058b141e 100644 --- a/src/core/math/dot_nalgebra.rs +++ b/src/core/math/dot_nalgebra.rs @@ -17,7 +17,7 @@ use nalgebra::{ storage::Storage, Scalar, }, - ClosedAdd, ClosedMul, DefaultAllocator, Matrix, MatrixMN, + ClosedAdd, ClosedMul, DefaultAllocator, Matrix, OMatrix, }; impl ArgminDot, N> for Matrix @@ -37,7 +37,7 @@ where } } -impl ArgminDot> for Matrix +impl ArgminDot> for Matrix where N: Scalar + Copy + ClosedMul, R: Dim, @@ -46,12 +46,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn dot(&self, other: &N) -> MatrixMN { + fn dot(&self, other: &N) -> OMatrix { self * *other } } -impl ArgminDot, MatrixMN> for N +impl ArgminDot, OMatrix> for N where N: Scalar + Copy + ClosedMul, R: Dim, @@ -60,12 +60,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn dot(&self, other: &Matrix) -> MatrixMN { + fn dot(&self, other: &Matrix) -> OMatrix { other * *self } } -impl ArgminDot, MatrixMN> +impl ArgminDot, OMatrix> for Matrix where N: Scalar + Zero + One + ClosedAdd + ClosedMul, @@ -79,7 +79,7 @@ where ShapeConstraint: AreMultipliable, { #[inline] - fn dot(&self, other: &Matrix) -> MatrixMN { + fn dot(&self, other: &Matrix) -> OMatrix { self * other } } diff --git a/src/core/math/eye_nalgebra.rs b/src/core/math/eye_nalgebra.rs index b92150ac1..daebc3097 100644 --- a/src/core/math/eye_nalgebra.rs +++ b/src/core/math/eye_nalgebra.rs @@ -11,10 +11,10 @@ use num::{One, Zero}; use nalgebra::{ base::{allocator::Allocator, dimension::Dim}, - DefaultAllocator, MatrixMN, Scalar, + DefaultAllocator, OMatrix, Scalar, }; -impl ArgminEye for MatrixMN +impl ArgminEye for OMatrix where N: Scalar + Zero + One, R: Dim, @@ -22,13 +22,13 @@ where DefaultAllocator: Allocator, { #[inline] - fn eye_like(&self) -> MatrixMN { + fn eye_like(&self) -> OMatrix { assert!(self.is_square()); Self::identity_generic(R::from_usize(self.nrows()), C::from_usize(self.ncols())) } #[inline] - fn eye(n: usize) -> MatrixMN { + fn eye(n: usize) -> OMatrix { Self::identity_generic(R::from_usize(n), C::from_usize(n)) } } diff --git a/src/core/math/inv_nalgebra.rs b/src/core/math/inv_nalgebra.rs index c0672d991..660c5d28a 100644 --- a/src/core/math/inv_nalgebra.rs +++ b/src/core/math/inv_nalgebra.rs @@ -9,10 +9,10 @@ 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 ArgminInv> for SquareMatrix +impl ArgminInv> for SquareMatrix where N: ComplexField, D: Dim, @@ -20,7 +20,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn inv(&self) -> Result, Error> { + fn inv(&self) -> Result, Error> { match self.clone_owned().try_inverse() { Some(m) => Ok(m), None => Err(ArgminError::InvalidParameter { diff --git a/src/core/math/mul_nalgebra.rs b/src/core/math/mul_nalgebra.rs index e638c70e3..102fbe7d0 100644 --- a/src/core/math/mul_nalgebra.rs +++ b/src/core/math/mul_nalgebra.rs @@ -15,10 +15,10 @@ use nalgebra::{ storage::Storage, MatrixSum, Scalar, }, - ClosedMul, DefaultAllocator, Matrix, MatrixMN, + ClosedMul, DefaultAllocator, Matrix, OMatrix, }; -impl ArgminMul> for Matrix +impl ArgminMul> for Matrix where N: Scalar + Copy + ClosedMul, R: Dim, @@ -27,12 +27,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn mul(&self, other: &N) -> MatrixMN { + fn mul(&self, other: &N) -> OMatrix { self * *other } } -impl ArgminMul, MatrixMN> for N +impl ArgminMul, OMatrix> for N where N: Scalar + Copy + ClosedMul, R: Dim, @@ -41,7 +41,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn mul(&self, other: &Matrix) -> MatrixMN { + fn mul(&self, other: &Matrix) -> OMatrix { other * *self } } diff --git a/src/core/math/sub_nalgebra.rs b/src/core/math/sub_nalgebra.rs index b751ae458..d138310eb 100644 --- a/src/core/math/sub_nalgebra.rs +++ b/src/core/math/sub_nalgebra.rs @@ -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 ArgminSub> for Matrix +impl ArgminSub> for Matrix where N: Scalar + Copy + Sub, R: Dim, @@ -23,12 +23,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn sub(&self, other: &N) -> MatrixMN { + fn sub(&self, other: &N) -> OMatrix { self.map(|entry| entry - *other) } } -impl ArgminSub, MatrixMN> for N +impl ArgminSub, OMatrix> for N where N: Scalar + Copy + Sub, R: Dim, @@ -37,12 +37,12 @@ where DefaultAllocator: Allocator, { #[inline] - fn sub(&self, other: &Matrix) -> MatrixMN { + fn sub(&self, other: &Matrix) -> OMatrix { other.map(|entry| *self - entry) } } -impl ArgminSub, MatrixMN> for Matrix +impl ArgminSub, OMatrix> for Matrix where N: Scalar + ClosedSub, R: Dim, @@ -51,7 +51,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn sub(&self, other: &Matrix) -> MatrixMN { + fn sub(&self, other: &Matrix) -> OMatrix { self - other } } diff --git a/src/core/math/transpose_nalgebra.rs b/src/core/math/transpose_nalgebra.rs index 564b21ae3..6a5140adc 100644 --- a/src/core/math/transpose_nalgebra.rs +++ b/src/core/math/transpose_nalgebra.rs @@ -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 ArgminTranspose> for Matrix +impl ArgminTranspose> for Matrix where N: Scalar, R: Dim, @@ -24,7 +24,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn t(self) -> MatrixMN { + fn t(self) -> OMatrix { self.transpose() } } diff --git a/src/core/math/zero_nalgebra.rs b/src/core/math/zero_nalgebra.rs index d6343a4bb..92050af14 100644 --- a/src/core/math/zero_nalgebra.rs +++ b/src/core/math/zero_nalgebra.rs @@ -11,10 +11,10 @@ use num::Zero; use nalgebra::{ base::{allocator::Allocator, dimension::Dim}, - DefaultAllocator, MatrixMN, Scalar, + DefaultAllocator, OMatrix, Scalar, }; -impl ArgminZeroLike for MatrixMN +impl ArgminZeroLike for OMatrix where N: Scalar + Zero + ArgminZero, R: Dim, @@ -22,7 +22,7 @@ where DefaultAllocator: Allocator, { #[inline] - fn zero_like(&self) -> MatrixMN { + fn zero_like(&self) -> OMatrix { Self::zeros_generic(R::from_usize(self.nrows()), C::from_usize(self.ncols())) } }