use nalgebra::{
allocator::Allocator, base::storage::Owned, DefaultAllocator, Dim, Matrix, OMatrix, OVector,
RealField, Vector,
};
#[derive(Debug, Clone)]
pub struct StateAndCovariance<R, SS>
where
R: RealField,
SS: Dim,
DefaultAllocator: Allocator<SS> + Allocator<SS, SS>,
{
state: Vector<R, SS, Owned<R, SS>>,
covariance: Matrix<R, SS, SS, Owned<R, SS, SS>>,
}
impl<R, SS> StateAndCovariance<R, SS>
where
R: RealField,
SS: Dim,
DefaultAllocator: Allocator<SS> + Allocator<SS, SS>,
{
pub fn new(
state: Vector<R, SS, Owned<R, SS>>,
covariance: Matrix<R, SS, SS, Owned<R, SS, SS>>,
) -> Self {
Self { state, covariance }
}
#[inline]
pub fn state(&self) -> &Vector<R, SS, Owned<R, SS>> {
&self.state
}
#[inline]
pub fn state_mut(&mut self) -> &mut Vector<R, SS, Owned<R, SS>> {
&mut self.state
}
#[inline]
pub fn covariance(&self) -> &Matrix<R, SS, SS, Owned<R, SS, SS>> {
&self.covariance
}
#[inline]
pub fn covariance_mut(&mut self) -> &mut Matrix<R, SS, SS, Owned<R, SS, SS>> {
&mut self.covariance
}
#[inline]
pub fn inner(self) -> (OVector<R, SS>, OMatrix<R, SS, SS>) {
(self.state, self.covariance)
}
}