Skip to main content

StateSpace

Struct StateSpace 

Source
pub struct StateSpace {
    pub a: C2D,
    pub b: C2D,
    pub c: C2D,
    pub d: C2D,
    pub x: C1D,
    /* private fields */
}
Expand description

Discrete-time state-space model using complex-valued matrices and vectors.

The state evolves as x[k+1] = A x[k] + B u[k]. The output follows one of two conventions (see OutputConvention):

  • new_standard: y[k] = C x[k] + D u[k], the textbook and SciPy model;
  • new: y[k] = C x[k+1] + D u[k], the state updated before the output is read, which matches the C++ implementation that this type mirrors.

All matrices use C2D and all vectors use C1D, so real-valued models can be represented as purely real complex matrices while still allowing complex-valued systems when needed.

Fields§

§a: C2D

State-transition matrix.

§b: C2D

Input-to-state matrix.

§c: C2D

State-to-output matrix.

§d: C2D

Input-to-output feedthrough matrix.

§x: C1D

Current state vector.

Implementations§

Source§

impl StateSpace

Source

pub fn new(a: C2D, b: C2D, c: C2D, d: C2D, x: C1D) -> Result<Self, ErrorsJSL>

Construct a model that reads its output after updating the state, y[k] = C x[k+1] + D u[k] (OutputConvention::Updated). For the textbook and SciPy convention use new_standard.

The dimensions must satisfy:

  • A is n x n
  • B is n x p
  • C is m x n
  • D is m x p
  • x has length n
Source

pub fn new_standard( a: C2D, b: C2D, c: C2D, d: C2D, x: C1D, ) -> Result<Self, ErrorsJSL>

Construct a model in the textbook and SciPy convention, x[k+1] = A x[k] + B u[k], y[k] = C x[k] + D u[k]: each step reads the output from the current state and then updates it. A model given to scipy.signal.dlsim as (A, B, C, D) is entered here unchanged.

Source

pub fn with_convention( a: C2D, b: C2D, c: C2D, d: C2D, x: C1D, convention: OutputConvention, ) -> Result<Self, ErrorsJSL>

Construct a model with an explicit OutputConvention; the dimensions are as for new.

Source

pub fn convention(&self) -> OutputConvention

The output convention of this model.

Source

pub fn to_standard(&self) -> StateSpace

The same system in the standard convention: for an Updated model, (A, B, C A, C B + D), which produces identical outputs; a Standard model is returned unchanged. The current and initial states are kept.

Source

pub fn step(&mut self, u: C1D) -> Result<C1D, ErrorsJSL>

Advance the system by one discrete input sample and return the output.

In the standard convention, y <- C x + D u and then x <- A x + B u; in the updated convention (the C++ ordering), x <- A x + B u first and then y <- C x + D u.

Source

pub fn is_observable(&self) -> Result<bool, ErrorsJSL>

Check whether the discrete-time model is observable.

The observability matrix is formed by vertically stacking C, C A, C A^2, ..., C A^(n-1).

Source

pub fn is_controllable(&self) -> Result<bool, ErrorsJSL>

Check whether the discrete-time model is controllable.

The controllability matrix is formed by horizontally stacking B, A B, A^2 B, ..., A^(n-1) B.

Source

pub fn get_poles(&self) -> Result<C1D, ErrorsJSL>

Return the poles of the discrete-time system, which are the eigenvalues of the state-transition matrix A.

Source

pub fn is_stable(&self) -> Result<bool, ErrorsJSL>

Check whether the discrete-time state matrix is stable.

For a discrete-time model this means every pole lies strictly inside the unit circle.

Trait Implementations§

Source§

impl StreamOperator<ArrayBase<OwnedRepr<Complex<f64>>, Dim<[usize; 1]>>, ArrayBase<OwnedRepr<Complex<f64>>, Dim<[usize; 1]>>> for StateSpace

Source§

fn process(&mut self, data_in: &[C1D]) -> Result<Option<Vec<C1D>>, ErrorsJSL>

Processes a chunk of input data and produces a corresponding chunk of output data. The input and output types can be defined based on the specific requirements of the application, such as audio samples, video frames, or other types of data. This method is called repeatedly as new data becomes available in the stream.
Source§

fn flush(&mut self) -> Result<Option<Vec<C1D>>, ErrorsJSL>

Flushes any remaining data in the operator’s internal buffers and produces any final output data. This method is typically called at the end of a stream or when the operator needs to be shut down, allowing it to perform any necessary cleanup or final computations before the stream is terminated.
Source§

impl StreamOperatorManagement for StateSpace

Source§

fn reset(&mut self) -> Result<(), ErrorsJSL>

Resets the internal state of the operator, preparing it for a new stream of data. This method is typically called at the beginning of a new stream or when the operator needs to be reinitialized.
Source§

fn finalize(&mut self) -> Result<(), ErrorsJSL>

Finalizes the processing of the stream, performing any necessary cleanup or final computations. This method is typically called at the end of a stream or when the operator needs to be shut down.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.