### Get Covariance Matrix Reference Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Provides immutable access to the covariance matrix within StateAndCovariance. ```rust pub fn covariance(&self) -> &Matrix> ``` -------------------------------- ### Get State Vector Reference Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Provides immutable access to the state vector within StateAndCovariance. ```rust pub fn state(&self) -> &Vector> ``` -------------------------------- ### Get Mutable Covariance Matrix Reference Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Provides mutable access to the covariance matrix within StateAndCovariance. ```rust pub fn covariance_mut(&mut self) -> &mut Matrix> ``` -------------------------------- ### Get Mutable State Vector Reference Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Provides mutable access to the state vector within StateAndCovariance. ```rust pub fn state_mut(&mut self) -> &mut Vector> ``` -------------------------------- ### Core Components Overview Source: https://docs.rs/adskalman/latest/adskalman/all.html Overview of the primary structs, enums, and traits available in the adskalman crate. ```APIDOC ## Core Components ### Structs - **KalmanFilterNoControl**: Implementation of a Kalman filter without control inputs. - **StateAndCovariance**: Represents the state vector and its associated covariance matrix. ### Enums - **CovarianceUpdateMethod**: Defines the method used for updating the covariance matrix. - **Error**: Represents potential errors encountered during filter operations. ### Traits - **ObservationModel**: Trait defining the observation model for the Kalman filter. - **TransitionModelLinearNoControl**: Trait defining a linear transition model without control inputs. ``` -------------------------------- ### KalmanFilterNoControl::new Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Initializes a new KalmanFilterNoControl struct with the provided transition and observation models. ```APIDOC ## `new` ### Description Initialize a new `KalmanFilterNoControl` struct. The first parameter, `transition_model`, specifies the state transition model, including the function `F` and the process covariance `Q`. The second parameter, `observation_matrix`, specifies the observation model, including the measurement function `H` and the measurement covariance `R`. ### Method `pub fn new` ### Parameters - **transition_model** (`&'a dyn TransitionModelLinearNoControl`) - Required - The state transition model. - **observation_matrix** (`&'a dyn ObservationModel`) - Required - The observation model. ### Returns - `Self` - A new `KalmanFilterNoControl` instance. ``` -------------------------------- ### Q Method for Process Covariance Source: https://docs.rs/adskalman/latest/adskalman/trait.TransitionModelLinearNoControl.html Returns the process covariance matrix, Q. This is a required method for the TransitionModelLinearNoControl trait. ```rust fn Q(&self) -> &Matrix>; ``` -------------------------------- ### CloneToUninit Trait Implementation (Nightly) Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Nightly-only experimental API for cloning to uninitialized memory. Requires T to be Clone. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Create StateAndCovariance Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Creates a new StateAndCovariance instance. Assumes the provided covariance matrix is symmetric and positive semi-definite. ```rust pub fn new( state: Vector>, covariance: Matrix>, ) -> Self ``` -------------------------------- ### F Method for State Transition Matrix Source: https://docs.rs/adskalman/latest/adskalman/trait.TransitionModelLinearNoControl.html Returns the state transition model matrix, F. This is a required method for the TransitionModelLinearNoControl trait. ```rust fn F(&self) -> &Matrix>; ``` -------------------------------- ### FT Method for Transpose of State Transition Matrix Source: https://docs.rs/adskalman/latest/adskalman/trait.TransitionModelLinearNoControl.html Returns the transpose of the state transition model matrix, FT. This is a required method for the TransitionModelLinearNoControl trait. ```rust fn FT(&self) -> &Matrix>; ``` -------------------------------- ### Any Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the Any trait, providing runtime type information. This is a blanket implementation. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### KalmanFilterNoControl::step_with_options Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Performs a single step of the Kalman filter with customizable covariance update method. ```APIDOC ## `step_with_options` ### Description Perform Kalman prediction and update steps with specified options. If any component of the observation is NaN (not a number), the observation will not be used, and the prior will be returned as the posterior without performing the update step. This method calls the prediction step of the transition model and then, if there is a (non-`nan`) observation, calls the update step of the observation model using the specified covariance update method. ### Method `pub fn step_with_options` ### Parameters - **previous_estimate** (`&StateAndCovariance`) - Required - The previous state estimate and its covariance. - **observation** (`&Vector>`) - Required - The current observation. - **covariance_update_method** (`CovarianceUpdateMethod`) - Required - The method to use for updating the covariance. ### Returns - `Result, Error>` - The updated state estimate and its covariance, or an error if the operation fails. ``` -------------------------------- ### TransitionModelLinearNoControl Trait Source: https://docs.rs/adskalman/latest/adskalman/trait.TransitionModelLinearNoControl.html Documentation for the TransitionModelLinearNoControl trait, including its required and provided methods. ```APIDOC ## Trait TransitionModelLinearNoControl A linear model of process dynamics with no control inputs. ### Required Methods #### fn F(&self) -> &Matrix> Get the state transition model, `F`. #### fn FT(&self) -> &Matrix> Get the transpose of the state transition model, `FT`. #### fn Q(&self) -> &Matrix> Get the process covariance, `Q`. ### Provided Methods #### fn predict( &self, previous_estimate: &StateAndCovariance, ) -> StateAndCovariance Predict new state from previous estimate. ``` -------------------------------- ### StateAndCovariance Trait Implementations Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Details on trait implementations for the StateAndCovariance struct. ```APIDOC ## Trait Implementations for StateAndCovariance ### `Clone` Allows creating a copy of `StateAndCovariance`. #### `clone(&self) -> StateAndCovariance` Returns a duplicate of the value. #### `clone_from(&mut self, source: &Self)` Performs copy-assignment from `source`. ### `Debug` Allows formatting `StateAndCovariance` for debugging. #### `fmt(&self, f: &mut Formatter<'_>) -> Result` Formats the value using the given formatter. ``` -------------------------------- ### ObservationModel Trait Methods Source: https://docs.rs/adskalman/latest/adskalman/trait.ObservationModel.html Defines the required and provided methods for implementing an observation model in the adskalman crate. ```APIDOC ## Trait: ObservationModel ### Description Defines the interface for an observation model, which can be linear or non-linear. Non-linear models should be linearized at each timestep. ### Required Methods - **H()**: Returns the observation matrix `H`. - **HT()**: Returns the transpose of the observation matrix `HT`. - **R()**: Returns the observation noise covariance matrix `R`. ### Provided Methods - **predict_observation(state)**: Predicts the observation for a given state. Defaults to `y = Hx` for linear models. - **update(prior, observation, covariance_method)**: Performs the Kalman filter update step to estimate the posterior state given a prior and an observation. ``` -------------------------------- ### Debug Implementation for StateAndCovariance Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the Debug trait for StateAndCovariance, enabling formatted output for debugging. Requires R and SS to be Debug. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### KalmanFilterNoControl::step Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Performs a single step of the Kalman filter, including prediction and update, using default options. ```APIDOC ## `step` ### Description Perform Kalman prediction and update steps with default values. If any component of the observation is NaN (not a number), the observation will not be used, and the prior will be returned as the posterior without performing the update step. This method calls the prediction step of the transition model and then, if there is a (non-`nan`) observation, calls the update step of the observation model using the `CovarianceUpdateMethod::JosephForm` covariance update method. This is a convenience method that calls `step_with_options`. ### Method `pub fn step` ### Parameters - **previous_estimate** (`&StateAndCovariance`) - Required - The previous state estimate and its covariance. - **observation** (`&Vector>`) - Required - The current observation. ### Returns - `Result, Error>` - The updated state estimate and its covariance, or an error if the operation fails. ``` -------------------------------- ### From Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the From trait, allowing conversion from T to T. This is a standard identity conversion. ```rust fn from(t: T) -> T ``` -------------------------------- ### Into Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the Into trait, allowing conversion from T to U if U implements From. This is a blanket implementation. ```rust fn into(self) -> U ``` -------------------------------- ### Extract State and Covariance Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Consumes the StateAndCovariance instance and returns the inner state vector and covariance matrix. ```rust pub fn inner(self) -> (OVector, OMatrix) ``` -------------------------------- ### Clone Implementation for StateAndCovariance Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the Clone trait for StateAndCovariance, allowing duplication of the struct. Requires R and SS to be Clone. ```rust fn clone(&self) -> StateAndCovariance ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### KalmanFilterNoControl::smooth_from_filtered Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Applies the Rauch-Tung-Striebel (RTS) smoother using pre-computed Kalman filtered estimates. ```APIDOC ## `smooth_from_filtered` ### Description Rauch-Tung-Striebel (RTS) smoother using already Kalman filtered estimates. Operates on an entire time series in one shot and returns a vector of state estimates. To be mathematically correct, the interval between observations must be the `dt` specified in the motion model. If any observation has a NaN component, it is treated as missing. ### Method `pub fn smooth_from_filtered` ### Parameters - **forward_results** (`Vec>`) - Required - A vector of state estimates obtained from a forward Kalman filter pass. ### Returns - `Result>, Error>` - A vector of smoothed state estimates, or an error if the smoothing fails. ``` -------------------------------- ### predict Method for State Prediction Source: https://docs.rs/adskalman/latest/adskalman/trait.TransitionModelLinearNoControl.html Predicts the new state from the previous estimate using the transition model. This is a provided method with a default implementation in the TransitionModelLinearNoControl trait. ```rust fn predict( &self, previous_estimate: &StateAndCovariance, ) -> StateAndCovariance { ... } ``` -------------------------------- ### KalmanFilterNoControl Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Represents a Kalman filter with no control inputs, a linear process model, and a linear observation model. It is efficient as it only stores references to the models. ```APIDOC ## Struct KalmanFilterNoControl ### Description A Kalman filter with no control inputs, a linear process model and linear observation model. Note that the structure is cheap to create, storing only references to the state transition model and the observation model. The system state is passed as an argument to methods like Self::step. Given the lifetime bound of this struct, a useful strategy to avoid requiring lifetime annotations is to construct it just before Self::step and then dropping it immediately afterward. ### Fields (Private fields, not exposed for direct manipulation) ``` -------------------------------- ### SupersetOf Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements SupersetOf for SP, enabling conversions between superset and subset types. Requires SS to be a SubsetOf SP. ```rust fn to_subset(&self) -> Option ``` ```rust fn is_in_subset(&self) -> bool ``` ```rust fn to_subset_unchecked(&self) -> SS ``` ```rust fn from_subset(element: &SS) -> SP ``` -------------------------------- ### StateAndCovariance Struct Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Represents a pair of state and covariance for a given estimate in the adskalman library. ```APIDOC ## Struct StateAndCovariance ### Description State and covariance pair for a given estimate. ### Fields This struct has private fields and does not expose them directly. ### Methods #### `new(state: Vector>, covariance: Matrix>) -> Self` Create a new `StateAndCovariance`. It is assumed that the covariance matrix is symmetric and positive semi-definite. #### `state(&self) -> &Vector>` Get a reference to the state vector. #### `state_mut(&mut self) -> &mut Vector>` Get a mut reference to the state vector. #### `covariance(&self) -> &Matrix>` Get a reference to the covariance matrix. #### `covariance_mut(&mut self) -> &mut Matrix>` Get a mutable reference to the covariance matrix. #### `inner(self) -> (OVector, OMatrix)` Get the state vector and covariance matrix. ``` -------------------------------- ### TransitionModelLinearNoControl Trait Definition Source: https://docs.rs/adskalman/latest/adskalman/trait.TransitionModelLinearNoControl.html Defines the interface for linear process dynamics without control inputs. Implementors must provide F, FT, and Q matrices. ```rust pub trait TransitionModelLinearNoControl where R: RealField, SS: Dim, DefaultAllocator: Allocator + Allocator, { // Required methods fn F(&self) -> &Matrix>; fn FT(&self) -> &Matrix>; fn Q(&self) -> &Matrix>; // Provided method fn predict( &self, previous_estimate: &StateAndCovariance, ) -> StateAndCovariance { ... } } ``` -------------------------------- ### CovarianceUpdateMethod Enum Source: https://docs.rs/adskalman/latest/adskalman/enum.CovarianceUpdateMethod.html Defines the available methods for updating the covariance matrix during Kalman filter calculations. ```APIDOC ## CovarianceUpdateMethod ### Description Specifies the approach used for updating the covariance matrix in the Kalman filter. ### Variants - **OptimalKalman**: Assumes optimal Kalman gain. Note that due to numerical errors, the covariance matrix may not remain symmetric. - **OptimalKalmanForcedSymmetric**: Assumes optimal Kalman gain and forces the covariance matrix to be symmetric by returning (P + P.T)/2. - **JosephForm**: Uses the Joseph form of the covariance update to maintain symmetry in the covariance matrix. ``` -------------------------------- ### Struct StateAndCovariance Definition Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Defines the StateAndCovariance struct which pairs a state vector with its covariance matrix. Requires R to implement RealField and SS to implement Dim. ```rust pub struct StateAndCovariance where R: RealField, SS: Dim, DefaultAllocator: Allocator + Allocator, { /* private fields */ } ``` -------------------------------- ### TryFrom Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the TryFrom trait for fallible conversions from U to T. Requires U to implement Into. The error type is Infallible. ```rust type Error = Infallible ``` ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### TryInto Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the TryInto trait for fallible conversions from T to U. Requires U to implement TryFrom. ```rust type Error = >::Error ``` ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Error Trait Implementations Source: https://docs.rs/adskalman/latest/adskalman/enum.Error.html This section details the various trait implementations for the `Error` enum, providing insights into its behavior and capabilities. ```APIDOC ### impl Debug for Error #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### impl Display for Error Available on **crate feature`std`** only. #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. ### impl Error for Error Available on **crate feature`std`** only. #### fn source(&self) -> Option<&(dyn Error + 'static)> Returns the lower-level source of this error, if any. #### fn description(&self) -> &str Deprecated since 1.42.0: use the Display impl or to_string() #### fn cause(&self) -> Option<&dyn Error> Deprecated since 1.33.0: replaced by Error::source, which can support downcasting #### fn provide<'a>(&'a self, request: &mut Request<'a>) This is a nightly-only experimental API. (`error_generic_member_access`) Provides type-based access to context intended for error reports. ``` -------------------------------- ### KalmanFilterNoControl::filter_inplace Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Applies the Kalman filter to a series of observations in-place, without allocating new memory for state estimates. ```APIDOC ## `filter_inplace` ### Description Kalman filter that operates on in-place data without allocating. Operates on an entire time series by repeatedly calling `step` for each observation and returns a vector of state estimates. To be mathematically correct, the interval between observations must be the `dt` specified in the motion model. If any observation has a NaN component, it is treated as missing. ### Method `pub fn filter_inplace` ### Parameters - **initial_estimate** (`&StateAndCovariance`) - Required - The initial state estimate and its covariance. - **observations** (`&[Vector>]`) - Required - A slice of observations. - **state_estimates** (`&mut [StateAndCovariance]`) - Required - A mutable slice to store the resulting state estimates. ### Returns - `Result<(), Error>` - Ok if the filtering is successful, or an error if it fails. ``` -------------------------------- ### Borrow Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the Borrow trait, allowing immutable borrowing. This is a blanket implementation. ```rust fn borrow(&self) -> &T ``` -------------------------------- ### KalmanFilterNoControl::smooth Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Applies the Rauch-Tung-Striebel (RTS) smoother to a series of observations. ```APIDOC ## `smooth` ### Description Rauch-Tung-Striebel (RTS) smoother. Operates on an entire time series by calling `filter` then `smooth_from_filtered` and returns a vector of state estimates. To be mathematically correct, the interval between observations must be the `dt` specified in the motion model. Operates on an entire time series in one shot and returns a vector of state estimates. To be mathematically correct, the interval between observations must be the `dt` specified in the motion model. If any observation has a NaN component, it is treated as missing. ### Method `pub fn smooth` ### Parameters - **initial_estimate** (`&StateAndCovariance`) - Required - The initial state estimate and its covariance. - **observations** (`&[Vector>]`) - Required - A slice of observations. ### Returns - `Result>, Error>` - A vector of smoothed state estimates, or an error if the smoothing fails. ``` -------------------------------- ### BorrowMut Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the BorrowMut trait, allowing mutable borrowing. This is a blanket implementation. ```rust fn borrow_mut(&mut self) -> &mut T ``` -------------------------------- ### ObservationModel Trait Definition Source: https://docs.rs/adskalman/latest/adskalman/trait.ObservationModel.html The core trait definition for observation models, requiring implementations for observation matrices and noise covariance. ```rust pub trait ObservationModel where R: RealField, SS: Dim, OS: Dim + DimMin, DefaultAllocator: Allocator + Allocator + Allocator + Allocator + Allocator + Allocator, Matrix>: One, { // Required methods fn H(&self) -> &Matrix>; fn HT(&self) -> &Matrix>; fn R(&self) -> &Matrix>; // Provided methods fn predict_observation( &self, state: &Vector>, ) -> Vector> { ... } fn update( &self, prior: &StateAndCovariance, observation: &Vector>, covariance_method: CovarianceUpdateMethod, ) -> Result, Error> { ... } } ``` -------------------------------- ### KalmanFilterNoControl::filter Source: https://docs.rs/adskalman/latest/adskalman/struct.KalmanFilterNoControl.html Applies the Kalman filter to a series of observations, returning a vector of state estimates. ```APIDOC ## `filter` ### Description Kalman filter. This is a convenience function that calls `filter_inplace`. It operates on an entire time series and returns a vector of state estimates. To be mathematically correct, the interval between observations must be the `dt` specified in the motion model. If any observation has a NaN component, it is treated as missing. ### Method `pub fn filter` ### Parameters - **initial_estimate** (`&StateAndCovariance`) - Required - The initial state estimate and its covariance. - **observations** (`&[Vector>]`) - Required - A slice of observations. ### Returns - `Result>, Error>` - A vector of state estimates, or an error if the filtering fails. ``` -------------------------------- ### Define CovarianceUpdateMethod Enum Source: https://docs.rs/adskalman/latest/adskalman/enum.CovarianceUpdateMethod.html The enum definition specifying the available strategies for covariance updates. ```rust pub enum CovarianceUpdateMethod { OptimalKalman, OptimalKalmanForcedSymmetric, JosephForm, } ``` -------------------------------- ### ToOwned Trait Implementation Source: https://docs.rs/adskalman/latest/adskalman/struct.StateAndCovariance.html Implements the ToOwned trait, allowing creation of owned data from borrowed data. Requires T to be Clone. ```rust type Owned = T ``` ```rust fn to_owned(&self) -> T ``` ```rust fn clone_into(&self, target: &mut T) ``` -------------------------------- ### Error Enum Source: https://docs.rs/adskalman/latest/adskalman/enum.Error.html The `Error` enum represents potential errors that can occur within the Kalman filter implementation. ```APIDOC ## Enum Error ### Description An Kalman filter error ### Variants #### CovarianceNotPositiveSemiDefinite The covariance matrix is not positive semi-definite (or is not symmetric). ``` -------------------------------- ### Define Error Enum Source: https://docs.rs/adskalman/latest/adskalman/enum.Error.html The Error enum currently contains a single variant for covariance matrix validation failures. ```rust pub enum Error { CovarianceNotPositiveSemiDefinite, } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.