From e9933e5c91c4fcd9693d2afd80bb0f7c43e4abf8 Mon Sep 17 00:00:00 2001 From: Christopher Rabotin Date: Sat, 26 Sep 2020 18:34:35 -0600 Subject: [PATCH] UDU: Expand to Dim from DimName Signed-off-by: Christopher Rabotin --- src/linalg/udu.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/linalg/udu.rs b/src/linalg/udu.rs index cd2db206..eada8e99 100644 --- a/src/linalg/udu.rs +++ b/src/linalg/udu.rs @@ -3,13 +3,13 @@ use serde::{Deserialize, Serialize}; use crate::allocator::Allocator; use crate::base::{DefaultAllocator, MatrixN}; -use crate::dimension::DimName; +use crate::dimension::Dim; use simba::scalar::ComplexField; /// UDU factorization #[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))] #[derive(Clone, Debug)] -pub struct UDU +pub struct UDU where DefaultAllocator: Allocator, { @@ -19,14 +19,14 @@ where pub d: MatrixN, } -impl Copy for UDU +impl Copy for UDU where DefaultAllocator: Allocator, MatrixN: Copy, { } -impl UDU +impl UDU where DefaultAllocator: Allocator, { @@ -34,10 +34,11 @@ where /// NOTE: The provided matrix MUST be symmetric, and no verification is done in this regard. /// Ref.: "Optimal control and estimation-Dover Publications", Robert F. Stengel, (1994) page 360 pub fn new(p: MatrixN) -> Self { - let mut d = MatrixN::::zeros(); - let mut u = MatrixN::::zeros(); - let n = p.ncols(); + let n_as_dim = D::from_usize(n); + + let mut d = MatrixN::::zeros_generic(n_as_dim, n_as_dim); + let mut u = MatrixN::::zeros_generic(n_as_dim, n_as_dim); d[(n - 1, n - 1)] = p[(n - 1, n - 1)]; u[(n - 1, n - 1)] = N::one();