class

CrySpace::StateSpace

Inherits Reference < Object

Constructors

eye(n : Int32, dt : Float64 | Nil = nil) : StateSpace
Source
new(a : Float64Tensor, b : Float64Tensor, c : Float64Tensor, d : Float64Tensor, dt : Float64 | Nil = nil)
Source
static_gain(d_matrix : Float64Tensor, dt : Float64 | Nil = nil) : StateSpace
Source

Class methods

logm(matrix : Float64Tensor) : Tensor(Complex, CPU(Complex))
Source
sylvester(a : Float64Tensor, b : Float64Tensor, c : Float64Tensor) : Float64Tensor

Solves Sylvester equation: AX + XB = C. Returns X.

Source

Instance methods

*(other : StateSpace)
Source
+(other : StateSpace)
Source
a=(a : Float64Tensor)
Source
acker(poles : Array(Float64) | Array(Complex))
Source
acker_obs(poles : Array(Float64) | Array(Complex))
Source
augment_integrator
Source
b=(b : Float64Tensor)
Source
balreal

Computes a balanced realization of the system. Returns: {balanced_system, t_matrix, t_inv}

Source
balred(orders : Int32)
Source
bandwidth

Computes the system bandwidth (the frequency at which magnitude drops by 3dB from DC gain).

Source
bode_data(omega : Float64Tensor)
Source
bode_plot(filename : String, omega : Float64Tensor | Nil = nil)

Generates an interactive HTML dashboard containing a Bode Plot (Magnitude & Phase) using Chart.js.

Source
c=(c : Float64Tensor)
Source
care(q : Float64Tensor, r : Float64Tensor)

Solves the Continuous Algebraic Riccati Equation: A^T * P + P * A - P * B * R^-1 * B^T * P + Q = 0 Returns P.

Source
complementary_sensitivity(k : StateSpace) : StateSpace

Computes the Complementary Sensitivity function T = GK * (I + GK)^-1

Source
controllable_decomposition
Source
coprime_factorization

Computes normalized coprime factorization G = N * M^-1

Source
ctrb
Source
current_observer(x_est : Float64Tensor, y : Float64Tensor, u : Float64Tensor, l_gain : Float64Tensor)

Simulates discrete current observer state-update step.

Source
d=(d : Float64Tensor)
Source
dare(q : Float64Tensor, r : Float64Tensor)

Solves the Discrete-Time Algebraic Riccati Equation (DARE) using Schur method: A^T * P * A - P - A^T * P * B * (R + B^T * P * B)^-1 * B^T * P * A + Q = 0 Returns P.

Source
dcgain
Source
decouple_gain

Computes static decouple gain matrix W (where G(0)*W is decoupled/diagonal)

Source
dlqe(q_noise : Float64Tensor, r_noise : Float64Tensor) : Float64Tensor
Source
dlqr(q : Float64Tensor, r : Float64Tensor, n_cross : Float64Tensor | Nil = nil)

Solves discrete-time Linear Quadratic Regulator (DLQR) controller: u = -Kx Optionally handles cross-coupling matrix N_cross Returns: {K (matrix), P (matrix), closed_loop_poles (Array(Complex))}

Source
dlyap(q : Float64Tensor)

Solves discrete-time Lyapunov equation: APA^T - P + Q = 0 Returns P.

Source
dt=(dt : Float64 | Nil)
Source
feedback(other : StateSpace, sign = -1)
Source
feedback(k : Float64Tensor, sign = -1)
Source
freqresp(omega : Float64Tensor)

Evaluates system response G(jw) at a set of frequency points. Returns a Tensor of Complex numbers of shape [n_outputs, n_inputs, omega.size].

Source
fw_balred(orders : Int32) : StateSpace

Performs Frequency-Weighted Balanced Truncation model order reduction.

Source
gram(type : Symbol)
Source
h2norm

Computes the H2 norm of a continuous-time LTI system. Raises an error if D is non-zero (infinite H2 norm) or if system is discrete.

Source
h2syn(c_z : Float64Tensor, d_zu : Float64Tensor) : Tuple(Float64Tensor, Float64Tensor)

Synthesizes an optimal H2 state-feedback control gain K.

Source
hankel_reduction(orders : Int32) : StateSpace

Performs Hankel Norm Approximation model order reduction.

Source
hinfnorm_exact(tol = 1e-5) : Float64

Computes the exact peak gain (H-infinity norm) of a continuous-time system.

Source
hinfsyn(c_z : Float64Tensor, d_zu : Float64Tensor, gamma : Float64) : Tuple(Float64Tensor, Float64Tensor)

Synthesizes a robust suboptimal H-infinity state-feedback control gain K for attenuation level gamma.

Source
hsvd
Source
impulse_response(n_steps = 100)

Simulates impulse response of discrete or continuous (sampled) system.

Source
initial_response(x0 : Float64Tensor, n_steps = 100)

Simulates unforced free response with non-zero initial state x0.

Source
is_controllable?
Source
is_observable?
Source
is_stable?
Source
loop_margins

Computes the multi-loop/disk margin (or classical loop margins using Nyquist analysis).

Source
lqe(q_noise : Float64Tensor, r_noise : Float64Tensor) : Float64Tensor
Source
lqg(k_gain : Float64Tensor, l_gain : Float64Tensor) : StateSpace
Source
lqr(q : Float64Tensor, r : Float64Tensor, n_cross : Float64Tensor | Nil = nil)

Solves continuous-time Linear Quadratic Regulator (LQR) controller: u = -Kx Optionally handles cross-coupling matrix N_cross: minimizes integral of (x^TQx + u^TRu + 2x^TN_cross*u) Returns: {K (matrix), P (matrix), closed_loop_poles (Array(Complex))}

Source
lqt_finite_horizon(q : Float64Tensor, r : Float64Tensor, steps : Int32) : Array(Float64Tensor)

Solves finite-horizon Linear Quadratic Tracking (LQT) problems, returning backward recursion gains.

Source
lsim(u : Float64Tensor, t : Float64Tensor, x0 : Float64Tensor | Nil = nil, method = :rk4)

Simulates time response with arbitrary input (wrapper for simulate).

Source
lsim_interpolated(u : Float64Tensor, t : Float64Tensor, x0 : Float64Tensor | Nil = nil)

Performs linear simulation with input interpolation (wrapper for lsim).

Source
lyap(q : Float64Tensor)

Solves continuous-time Lyapunov equation: AP + PA^T + Q = 0 Returns P.

Source
margin_frequencies

Extracts crossover frequencies. Returns: {omega_gc (gain crossover), omega_pc (phase crossover)}

Source
mimo_bandwidth

Computes MIMO system bandwidth using singular values frequency response.

Source
mimo_stepinfo(n_steps = 200)

Computes step response performance metrics for MIMO systems.

Source
minimum_variance_controller

Designs a Minimum Variance controller.

Source
minreal
Source
n_inputs
Source
n_outputs
Source
n_states
Source
nbar(k_gain : Float64Tensor) : Float64Tensor

Computes prefilter tracking scaling gain N for zero steady-state tracking error under LQR control u = -Kx + Nr

Source
ncfsyn(w_shape : StateSpace) : Tuple(StateSpace, Float64)

Performs H-infinity loop-shaping controller design.

Source
nichols_data(omega : Float64Tensor)
Source
nyquist_data(omega : Float64Tensor)
Source
observable_decomposition
Source
obsv
Source
peak_gain

Computes the Peak Gain (H-infinity norm) of a SISO system.

Source
phase_portrait(grid_points = 5) : Array(Tuple(Array(Float64), Array(Float64Tensor)))

Generates phase portrait trajectories for 2nd order systems.

Source
place(poles : Array(Float64) | Array(Complex)) : Float64Tensor

Computes robust state-feedback gain matrix K to place closed-loop poles of a SISO or MIMO system.

Source
poles
Source
ramp_response(n_steps = 100)

Simulates ramp response of discrete or continuous (sampled) system.

Source
residual_reduction(n_slow : Int32) : StateSpace

Performs Singular Perturbation Model Reduction (Residualization), preserving the DC gain exactly.

Source
rga(omega : Float64) : Float64Tensor

Computes the Relative Gain Array (RGA) matrix at frequency omega.

Source
root_locus(gains : Float64Tensor)
Source
sample(dt : Float64, method : Symbol = :zoh, alpha : Float64 = 0.5, omega_c : Float64 | Nil = nil)
Source
sensitivity(k : StateSpace) : StateSpace

Computes the Sensitivity function S = (I + G*K)^-1

Source
sigma_data(omega : Float64Tensor)

Computes singular values of the frequency response matrix G(jw) over a range of frequency points. Returns: {omega, singular_values_matrix [omega.size, min(outputs, inputs)]}

Source
similarity_transform(t_matrix : Float64Tensor) : StateSpace
Source
simulate(t_span : Tuple(Float64, Float64), dt : Float64, x0 : Float64Tensor | Nil = nil, u : Float64Tensor | Nil = nil, method = :rk4)
Source
simulate(t : AnyFloat64Tensor, x0 : AnyFloat64Tensor | Nil = nil, u : AnyFloat64Tensor | Nil = nil, method = :rk4)

Vectorized simulation: optimized for StateSpace systems

Source
simulate_observer(t : Float64Tensor, k_gain : Float64Tensor, l_gain : Float64Tensor, x0 : Float64Tensor | Nil = nil, x0_est : Float64Tensor | Nil = nil, u_ref : Float64Tensor | Nil = nil, process_noise_cov : Float64Tensor | Nil = nil, measure_noise_cov : Float64Tensor | Nil = nil)

Simulates coupled state-feedback controller with an observer/estimator. Optionally adds process and measurement Gaussian noises under covariance matrices.

Source
smith_predictor(k_controller : StateSpace, tau_delay : Float64) : StateSpace

Builds a Smith Predictor structure compensating for time delays.

Source
ss2tf
Source
stability_margins

Computes classical gain and phase margins (Bode margins) for a SISO system.

Source
step_plot(filename : String, n_steps = 200)

Generates an interactive HTML dashboard containing a Step Response plot using Chart.js.

Source
step_response(n_steps = 100)
Source
stepinfo(n_steps = 500, settling_threshold = 0.02) : StepInfo

Analyzes the step response of a SISO system and returns step response performance metrics.

Source
to_continuous
Source
to_control_canonical_form

Transforms system to Control Canonical Form.

Source
to_jordan_form
Source
to_kalman_canonical
Source
to_modal_form
Source
to_observability_form
Source
to_observable_canonical_form

Transforms system to Observable Canonical Form.

Source
to_s(io)
Source
to_transferfunction
Source
transmission_zeros
Source

Nested types