Skip to main content
`Ctrl`+`K`
scipy.signal.

# abcd_normalize

scipy.signal.abcd_normalize(A=None, B=None, C=None, D=None)

  Check state-space matrices compatibility and ensure they are 2d arrays.

  Converts input matrices into two-dimensional arrays as needed. Then the dimensions n, q, p are determined by investigating the non-zero entries of the array shapes. If a parameter is `None`, or has shape (0, 0), it is set to a zero-array of compatible shape. Finally, it is verified that all parameter shapes are compatible to each other. If that fails, a `ValueError` is raised. Note that the dimensions n, q, p are allowed to be zero.

  Parameters:
    A: array_like, optional

      Two-dimensional array of shape (n, n).

    B: array_like, optional

      Two-dimensional array of shape (n, p).

    C: array_like, optional

      Two-dimensional array of shape (q, n).

    D: array_like, optional

      Two-dimensional array of shape (q, p).

  Returns:
    A, B, C, D array

      State-space matrices as two-dimensional arrays.

  Raises:
    ValueError

      If the dimensions n, q, or p could not be determined or if the shapes are incompatible with each other.

  See also

  `StateSpace`

    Linear Time Invariant system in state-space form.

  `dlti`

    Discrete-time linear time invariant system base class.

  `tf2ss`

    Transfer function to state-space representation.

  `ss2tf`

    State-space to transfer function.

  `ss2zpk`

    State-space representation to zero-pole-gain representation.

  `cont2discrete`

    Transform a continuous to a discrete state-space system.

  Notes

  The State-space system representation section of the SciPy User Guide presents the corresponding definitions of continuous-time and disrcete time state space systems.

  Array API Standard Support

  `abcd_normalize` has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable `SCIPY_ARRAY_API=1` and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

  Library | CPU | GPU
  --- | --- | ---
  NumPy | ✅ | n/a
  CuPy | n/a | ✅
  PyTorch | ✅ | ✅
  JAX | ✅ | ✅
  Dask | ✅ | n/a

  > See Support for the array API standard for more information.

  Examples

  The following example demonstrates that the passed lists are converted into two-dimensional arrays:

      >>> from scipy.signal import abcd_normalize
      >>> AA, BB, CC, DD = abcd_normalize(A=[[1, 2], [3, 4]], B=[[-1], [5]],
      ...                                 C=[[4, 5]], D=2.5)
      >>> AA.shape, BB.shape, CC.shape, DD.shape
      ((2, 2), (2, 1), (1, 2), (1, 1))

  In the following, the missing parameter C is assumed to be an array of zeros with shape (1, 2):

      >>> from scipy.signal import abcd_normalize
      >>> AA, BB, CC, DD = abcd_normalize(A=[[1, 2], [3, 4]], B=[[-1], [5]], D=2.5)
      >>> AA.shape, BB.shape, CC.shape, DD.shape
      ((2, 2), (2, 1), (1, 2), (1, 1))
      >>> CC
      array([[0., 0.]])