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();