# Function reference¶

harold is a Python package that provides tools for analyzing feedback control systems and designing controllers.

## System creation¶

 State(a[, b, c, d, dt]) A class for creating State space models. Transfer(num[, den, dt]) A class for creating Transfer functions. random_state_model(n[, p, m, dt, prob_dist, …]) Generates a continuous or discrete State model with random data. transfer_to_state(G[, output]) Converts a Transfer to a State state_to_transfer(state_or_abcd[, output]) Converts a State to a Transfer

## Discretization¶

 discretize(G, dt[, method, prewarp_at, q]) Continuous- to discrete-time model conversion. undiscretize(G[, method, prewarp_at, q]) Discrete- to continuous-time model conversion.

## Controller Design¶

 lqr(G, Q[, R, S, weight_on]) A full-state static feedback control design solver for which the following quadratic cost function is integrated (summed) over all positive time axis . ackermann(G, loc) Pole placement using Ackermann’s polynomial method. place_poles(*args, **kwargs) An error only function for recommending SciPy’s algorithm.

## Model Functions¶

 transmission_zeros(A, B, C, D) Computes the transmission zeros of State data arrays A, B, C, D system_norm(G[, p, hinf_tol, eig_tol]) Computes the system p-norm. cancellation_distance(F, G) Computes the upper and lower bounds of the perturbation needed to render the pencil $$[F-pI | G]$$ rank deficient. controllability_indices(A, B[, tol]) Computes the controllability indices for a controllable pair (A, B)

### Kalman tests¶

 controllability_matrix(G[, compress]) Computes the Kalman controllability and the transformation matrix. observability_matrix(G[, compress]) Computes the Kalman controllability and the transformation matrix. is_kalman_controllable(G) Tests the rank of the Kalman controllability matrix and compares it with the A matrix size, returns a boolean depending on the outcome. is_kalman_observable(G) Tests the rank of the Kalman observability matrix and compares it with the A matrix size, returns a boolean depending on the outcome.

## Time domain simulation¶

 simulate_linear_system(sys, u[, t, x0, …]) Compute the linear model response to an input array sampled at given time instances. simulate_step_response(sys[, t]) Compute the linear model response to an Heaviside function (or all-ones array) sampled at given time instances. simulate_impulse_response(sys[, t]) Compute the linear model response to an Dirac delta pulse (or all-zeros array except the first sample being 1/dt at each channel) sampled at given time instances. impulse_response_plot(sys[, t, style]) Plots the impulse response of a model. step_response_plot(sys[, t, style]) Plots the step response of model(s).

## Frequency domain simulation¶

 frequency_response(G[, w, samples, w_unit, …]) Compute the frequency response of a State() or Transfer() representation. bode_plot(sys[, w, use_db, use_hz, …]) Draw the Bode plot of State, Transfer model(s). nyquist_plot(sys[, w, use_hz, …]) Draw the Nyquist plot of State, Transfer model(s).

## Model simplification tools¶

 feedback(G, H[, negative]) Feedback interconnection of two models in the following configuration . minimal_realization(G[, tol]) Given system realization G, this computes minimal realization such that if a State representation is given then the returned representation is controllable and observable within the given tolerance tol. hessenberg_realization(G[, compute_T, form, …]) A state transformation is applied in order to get the following form where A is a Hessenberg matrix and B (or C if ‘form’ is set to ‘o’ ) is row/col compressed . staircase(A, B, C[, compute_T, form, …]) Given a state model data A, B, C, Returns the so-called staircase form State realization to assess the controllability/observability properties. kalman_decomposition(G[, compute_T, output, …]) By performing a sequence of similarity transformations the State representation is transformed into a special structure such that if the system has uncontrollable/unobservable modes, the corresponding rows/columns of the B/C matrices have zero blocks and the modes are isolated in the A matrix.

## Polynomial Operations¶

 haroldgcd(*args) Takes 1D numpy arrays and computes the numerical greatest common divisor polynomial. haroldlcm(*args[, compute_multipliers, …]) Takes n-many 1D numpy arrays and computes the numerical least common multiple polynomial. haroldpolyadd(*args[, trim_zeros]) A wrapper around NumPy’s numpy.polyadd() but allows for multiple args and offers a trimming option. haroldpolymul(*args[, trim_zeros]) Simple wrapper around the numpy.convolve() function for polynomial multiplication with multiple args. haroldpolydiv(dividend, divisor) Polynomial division wrapped around scipy.signal.deconvolve() function. haroldcompanion(somearray) Takes a 1D numpy array or list and returns the companion matrix of the monic polynomial of somearray. haroldker(N[, side]) This function is a straightforward basis computation for the right/left nullspace for rank deficient or fat/tall matrices.

## Auxillary Functions¶

 matrix_slice(M, corner_shape[, corner]) Takes a two dimensional array M and slices into four parts dictated by the corner_shape and the corner string corner. e_i(width[, nth, output]) Returns the nth column(s) of the identity matrix with shape (width,width). concatenate_state_matrices(G) Takes a State() model as input and returns the A, B, C, D matrices combined into a full matrix. haroldsvd(A[, also_rank, rank_tol]) This is a wrapper/container function of both the SVD decomposition and the rank computation.