class sharpy.linear.src.libss.ss_block(A, B, C, D, S_states, S_inputs, S_outputs, dt=None)[source]

State-space model in block form. This class has the same purpose as “ss”, but the A, B, C, D are allocated in the form of nested lists. The format is similar to the one used in numpy.block but:

  1. Block matrices can contain both dense and sparse matrices

  2. Empty blocks are defined through None type

Methods: - remove_block: drop one of the blocks from the s-s model - addGain: project inputs/outputs - project: project state

addGain(K, where)[source]

Projects input u or output y the state-space system through the gain block matrix K. The input ‘where’ determines whether inputs or outputs are projected as:

  • where=’in’: inputs are projected such that:

    u_new -> u=K*u_new -> SS -> y => u_new -> SSnew -> y

  • where=’out’: outputs are projected such that:

    u -> SS -> y -> y_new=K*y => u -> SSnew -> ynew

Input: K must be a list of list of matrices. The size of K must be compatible with either B or C for block matrix product.


Get the size of each block in M.

project(WT, V, by_arrays=True, overwrite=False)[source]

Given 2 transformation matrices, (W,V) of shape (Nk,self.states), this routine projects the state space model states according to:

Anew = W^T A V Bnew = W^T B Cnew = C V Dnew = D

The projected model has the same number of inputs/outputs as the original one, but Nk states.

Inputs: - WT = W^T - V = V - by_arrays: if True, W, V are either numpy.array or sparse matrices. If

False, they are block matrices.

  • overwrite: if True, overwrites the A, B, C matrices

remove_block(where, index)[source]

Remove a block from either inputs or outputs.

Inputs: - where = {‘in’, ‘out’}: determined whether to remove inputs or outputs - index: index of block to remove