403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/scipy/signal/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/scipy/signal/__pycache__/_lti_conversion.cpython-311.pyc
�

d�c?���dZddlZddlZddlmZmZmZmZmZmZm	Z	m
Z
mZmZddl
mZddlmZmZmZgd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zdd�Zdd�Zd�Zdd�Zdd�ZdS)zr
ltisys -- a collection of functions to convert linear time invariant systems
from one representation to another.
�N)
�r_�eye�
atleast_2d�poly�dot�asarray�prod�zeros�array�outer)�linalg�)�tf2zpk�zpk2tf�	normalize)�tf2ss�abcd_normalize�ss2tf�zpk2ss�ss2zpk�
cont2discretec���t||��\}}t|j��}|dkrt|g|j��}|jd}t|��}||krd}t|���|dks|dkrRt
gt��t
gt��t
gt��t
gt��fStdt|jd||z
f|j��|f}|jddkrt|dd�df��}nt
dggt��}|dkra|�|j��}td��td|jdf��t|jddf��|fSt
|dd�g��}t|t|dz
|dz
��f}t|dz
d��}	|dd�dd�ft|dd�df|dd���z
}
|�|
jd|	jdf��}||	|
|fS)	a�Transfer function to state-space representation.

    Parameters
    ----------
    num, den : array_like
        Sequences representing the coefficients of the numerator and
        denominator polynomials, in order of descending degree. The
        denominator needs to be at least as long as the numerator.

    Returns
    -------
    A, B, C, D : ndarray
        State space representation of the system, in controller canonical
        form.

    Examples
    --------
    Convert the transfer function:

    .. math:: H(s) = \frac{s^2 + 3s + 3}{s^2 + 2s + 1}

    >>> num = [1, 3, 3]
    >>> den = [1, 2, 1]

    to the state-space representation:

    .. math::

        \dot{\textbf{x}}(t) =
        \begin{bmatrix} -2 & -1 \\ 1 & 0 \end{bmatrix} \textbf{x}(t) +
        \begin{bmatrix} 1 \\ 0 \end{bmatrix} \textbf{u}(t) \\

        \textbf{y}(t) = \begin{bmatrix} 1 & 2 \end{bmatrix} \textbf{x}(t) +
        \begin{bmatrix} 1 \end{bmatrix} \textbf{u}(t)

    >>> from scipy.signal import tf2ss
    >>> A, B, C, D = tf2ss(num, den)
    >>> A
    array([[-2., -1.],
           [ 1.,  0.]])
    >>> B
    array([[ 1.],
           [ 0.]])
    >>> C
    array([[ 1.,  2.]])
    >>> D
    array([[ 1.]])
    rz7Improper transfer function. `num` is longer than `den`.rz-1���N)rr�)r�len�shaper�dtype�
ValueErrorr�floatrr
r�reshaperr)�num�den�nn�M�K�msg�D�frow�A�B�Cs           �>/usr/lib/python3/dist-packages/scipy/signal/_lti_conversion.pyrrs=��p��c�"�"�H�C��	�S�Y���B�	�Q�w�w��s�e�S�Y�'�'���	�!��A��C���A��1�u�u�G����o�o���A�v�v��a����b�%� � �%��E�"2�"2�E�"�e�4D�4D��b�%� � �"�	"�
�T�5�#�)�A�,��A��.��	�:�:�C�
?�
@�C�
�y��}�q����s�1�1�1�a�4�y�!�!���
�A�3�%������A�v�v�
�I�I�c�i� � ���f�
�
�u�a�����_�5�5��q�w�q�z�1�o�&�&��+�	+�
�3�q�r�r�7�)����D�
�4��Q��U�A��E�"�"�"�#�A��A��E�1�
�
�A��A�A�A�q�r�r�E�
�U�3�q�q�q�!�t�9�c�!�"�"�g�.�.�.�A�	�	�	�1�7�1�:�q�w�q�z�*�+�+�A��a��A�:��c�(�|�td��S|S)N�rr)r
��args r,�_none_to_empty_2dr2ss��
�{��V�}�}���
r-c�(�|�t|��SdS�N)rr0s r,�_atleast_2d_or_noner5zs��
���#�����r-c��|�|jSdS)N)NN)r)r$s r,�_shape_or_noner7s���}��w���{r-c��|D]}|�|cS�	dSr4�)�argsr1s  r,�_choice_not_noner;�s.�������?��J�J�J���r-c�n�|jdkrt|��S|j|krtd���|S)Nr/z*The input arrays have incompatible shapes.)rr
r)r$rs  r,�_restorer=�s<���w�&����U�|�|���7�e����I�J�J�J��r-c�2�tt||||f��\}}}}t|��\}}t|��\}}t|��\}}	t|��\}
}t|||	��}t||��}
t||
��}|�|
�|�t	d���tt
||||f��\}}}}t
|||f��}t
|||
f��}t
|||f��}t
|||
f��}||||fS)a�Check state-space matrices and ensure they are 2-D.

    If enough information on the system is provided, that is, enough
    properly-shaped arrays are passed to the function, the missing ones
    are built from this information, ensuring the correct number of
    rows and columns. Otherwise a ValueError is raised.

    Parameters
    ----------
    A, B, C, D : array_like, optional
        State-space matrices. All of them are None (missing) by default.
        See `ss2tf` for format.

    Returns
    -------
    A, B, C, D : array
        Properly shaped state-space matrices.

    Raises
    ------
    ValueError
        If not enough information on the system was provided.

    Nz%Not enough information on the system.)�mapr5r7r;rr2r=)r)r*r+r'�MA�NA�MB�NB�MC�NC�MD�ND�p�q�rs               r,rr�s-��2�(�1�a��A�,�7�7�J�A�q�!�Q�
�A�
�
�F�B��
�A�
�
�F�B��
�A�
�
�F�B��
�A�
�
�F�B����R��$�$�A���R� � �A���R� � �A��y�A�I����@�A�A�A��&��A�q�!��5�5�J�A�q�!�Q���Q��F���A���Q��F���A���Q��F���A���Q��F���A��a��A�:�r-c�n�t||||��\}}}}|j\}}||krtd���|dd�||dz�f}|dd�||dz�f}	t|��}n#t$rd}YnwxYwt	|jd���dkrht	|jd���dkrNtj|��}t	|jd���dkrt	|jd���dkrg}||fS|jd}	|dd�df|dd�dfz|ddd�fz|zdz}
tj||	dzf|
j��}t|��D]M}t||dd�f��}t|t||��z
��||dz
|zz||<�N||fS)aState-space to transfer function.

    A, B, C, D defines a linear state-space system with `p` inputs,
    `q` outputs, and `n` state variables.

    Parameters
    ----------
    A : array_like
        State (or system) matrix of shape ``(n, n)``
    B : array_like
        Input matrix of shape ``(n, p)``
    C : array_like
        Output matrix of shape ``(q, n)``
    D : array_like
        Feedthrough (or feedforward) matrix of shape ``(q, p)``
    input : int, optional
        For multiple-input systems, the index of the input to use.

    Returns
    -------
    num : 2-D ndarray
        Numerator(s) of the resulting transfer function(s). `num` has one row
        for each of the system's outputs. Each row is a sequence representation
        of the numerator polynomial.
    den : 1-D ndarray
        Denominator of the resulting transfer function(s). `den` is a sequence
        representation of the denominator polynomial.

    Examples
    --------
    Convert the state-space representation:

    .. math::

        \dot{\textbf{x}}(t) =
        \begin{bmatrix} -2 & -1 \\ 1 & 0 \end{bmatrix} \textbf{x}(t) +
        \begin{bmatrix} 1 \\ 0 \end{bmatrix} \textbf{u}(t) \\

        \textbf{y}(t) = \begin{bmatrix} 1 & 2 \end{bmatrix} \textbf{x}(t) +
        \begin{bmatrix} 1 \end{bmatrix} \textbf{u}(t)

    >>> A = [[-2, -1], [1, 0]]
    >>> B = [[1], [0]]  # 2-D column vector
    >>> C = [[1, 2]]    # 2-D row vector
    >>> D = 1

    to the transfer function:

    .. math:: H(s) = \frac{s^2 + 3s + 3}{s^2 + 2s + 1}

    >>> from scipy.signal import ss2tf
    >>> ss2tf(A, B, C, D)
    (array([[1., 3., 3.]]), array([ 1.,  2.,  1.]))
    z)System does not have the input specified.Nrr)�axis�)rrrrr	�numpy�ravel�emptyr�rangerr)
r)r*r+r'�input�nout�ninr"r!�
num_states�	type_test�k�Cks
             r,rr�s��t ��1�a��+�+�J�A�q�!�Q���I�D�#���|�|��D�E�E�E�	
�!�!�!�U�5�1�9�_�
��A�	�!�!�!�U�5�1�9�_�
��A���1�g�g����������������	
�Q�W�1�����"�"��a�g�A�)>�)>�)>�!�)C�)C��k�!�n�n�����q�!�!�!�Q�&�&�T�!�'��-B�-B�-B�a�-G�-G��C��C�x������J��!�!�!�Q�$��!�A�A�A�q�D�'�!�A�a����d�G�+�a�/�#�5�I�
�+�t�Z�!�^�,�i�o�
>�
>�C�
�4�[�[�9�9��
��!�Q�Q�Q�$��
 �
 ���a�#�a��*�*�n�%�%��1����S�(8�8��A�����8�Os�A*�*A9�8A9c�2�tt|||���S)a:Zero-pole-gain representation to state-space representation

    Parameters
    ----------
    z, p : sequence
        Zeros and poles.
    k : float
        System gain.

    Returns
    -------
    A, B, C, D : ndarray
        State space representation of the system, in controller canonical
        form.

    )rr)�zrHrWs   r,rrs��"�&��A�q�/�/�"�"r-c	�8�tt|||||����S)a�State-space representation to zero-pole-gain representation.

    A, B, C, D defines a linear state-space system with `p` inputs,
    `q` outputs, and `n` state variables.

    Parameters
    ----------
    A : array_like
        State (or system) matrix of shape ``(n, n)``
    B : array_like
        Input matrix of shape ``(n, p)``
    C : array_like
        Output matrix of shape ``(q, n)``
    D : array_like
        Feedthrough (or feedforward) matrix of shape ``(q, p)``
    input : int, optional
        For multiple-input systems, the index of the input to use.

    Returns
    -------
    z, p : sequence
        Zeros and poles.
    k : float
        System gain.

    )rR)rr)r)r*r+r'rRs     r,rr1s"��6�5��A�q�!�5�1�1�1�2�2r-�zohc�
�t|��dkr|���St|��dkr[tt|d|d��|||���}t	|d|d|d|d��|fzSt|��dkrbtt|d|d|d��|||���}t
|d|d|d|d��|fzSt|��dkr|\}}}}ntd���|dkr,|�td
���|dks|dkrtd���|dkr�tj	|j
d��||z|zz
}	tj|	tj	|j
d��d|z
|z|zz��}
tj|	||z��}tj|	�
��|�
����}|�
��}||tj||��zz}
�n�|d
ks|dkrt||dd���S|dks|dkrt||dd���S|dkrt||dd���S|dkr�tj||f��}tjtj|j
d|j
df��tj|j
d|j
df��f��}tj||f��}tj||z��}|d	|j
d�d	d	�f}|d	d	�d|j
d�f}
|d	d	�|j
dd	�f}|}|}
�nO|dkr�|j
d}|j
d}tjtj||g��|ztj	|����}t!||d|zzf��}tj|g|gg��}tj|��}|d	|�d|�f}|d	|�|||z�f}|d	|�||zd	�f}|}
||z
||zz}|}|||zz}
nf|dkrNtj|d��std���tj||z��}
|
|z|z}|}||z|z}
ntd|z���|
|||
|fS)a\
    Transform a continuous to a discrete state-space system.

    Parameters
    ----------
    system : a tuple describing the system or an instance of `lti`
        The following gives the number of elements in the tuple and
        the interpretation:

            * 1: (instance of `lti`)
            * 2: (num, den)
            * 3: (zeros, poles, gain)
            * 4: (A, B, C, D)

    dt : float
        The discretization time step.
    method : str, optional
        Which method to use:

            * gbt: generalized bilinear transformation
            * bilinear: Tustin's approximation ("gbt" with alpha=0.5)
            * euler: Euler (or forward differencing) method ("gbt" with alpha=0)
            * backward_diff: Backwards differencing ("gbt" with alpha=1.0)
            * zoh: zero-order hold (default)
            * foh: first-order hold (*versionadded: 1.3.0*)
            * impulse: equivalent impulse response (*versionadded: 1.3.0*)

    alpha : float within [0, 1], optional
        The generalized bilinear transformation weighting parameter, which
        should only be specified with method="gbt", and is ignored otherwise

    Returns
    -------
    sysd : tuple containing the discrete system
        Based on the input type, the output will be of the form

        * (num, den, dt)   for transfer function input
        * (zeros, poles, gain, dt)   for zeros-poles-gain input
        * (A, B, C, D, dt) for state-space system input

    Notes
    -----
    By default, the routine uses a Zero-Order Hold (zoh) method to perform
    the transformation. Alternatively, a generalized bilinear transformation
    may be used, which includes the common Tustin's bilinear approximation,
    an Euler's method technique, or a backwards differencing technique.

    The Zero-Order Hold (zoh) method is based on [1]_, the generalized bilinear
    approximation is based on [2]_ and [3]_, the First-Order Hold (foh) method
    is based on [4]_.

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Discretization#Discretization_of_linear_state_space_models

    .. [2] http://techteach.no/publications/discretetime_signals_systems/discrete.pdf

    .. [3] G. Zhang, X. Chen, and T. Chen, Digital redesign via the generalized
        bilinear transformation, Int. J. Control, vol. 82, no. 4, pp. 741-754,
        2009.
        (https://www.mypolyuweb.hk/~magzhang/Research/ZCC09_IJC.pdf)

    .. [4] G. F. Franklin, J. D. Powell, and M. L. Workman, Digital control
        of dynamic systems, 3rd ed. Menlo Park, Calif: Addison-Wesley,
        pp. 204-206, 1998.

    Examples
    --------
    We can transform a continuous state-space system to a discrete one:

    >>> import numpy as np
    >>> import matplotlib.pyplot as plt
    >>> from scipy.signal import cont2discrete, lti, dlti, dstep

    Define a continuous state-space system.

    >>> A = np.array([[0, 1],[-10., -3]])
    >>> B = np.array([[0],[10.]])
    >>> C = np.array([[1., 0]])
    >>> D = np.array([[0.]])
    >>> l_system = lti(A, B, C, D)
    >>> t, x = l_system.step(T=np.linspace(0, 5, 100))
    >>> fig, ax = plt.subplots()
    >>> ax.plot(t, x, label='Continuous', linewidth=3)

    Transform it to a discrete state-space system using several methods.

    >>> dt = 0.1
    >>> for method in ['zoh', 'bilinear', 'euler', 'backward_diff', 'foh', 'impulse']:
    ...    d_system = cont2discrete((A, B, C, D), dt, method=method)
    ...    s, x_d = dstep(d_system)
    ...    ax.step(s, np.squeeze(x_d), label=method, where='post')
    >>> ax.axis([t[0], t[-1], x[0], 1.4])
    >>> ax.legend(loc='best')
    >>> fig.tight_layout()
    >>> plt.show()

    rrr)�method�alpha��zKFirst argument must either be a tuple of 2 (tf), 3 (zpk), or 4 (ss) arrays.�gbtNzUAlpha parameter must be specified for the generalized bilinear transform (gbt) methodzDAlpha parameter must be within the interval [0,1] for the gbt methodg�?�bilinear�tusting�?�euler�forward_diffrM�
backward_diffr\�foh�impulsez;Impulse method is only applicableto strictly proper systemsz"Unknown transformation method '%s')r�to_discreterrrrrr�nprrr
�solve�	transposer�hstackr
�vstack�expm�
block_diag�block�allclose)�system�dtr^r_�sysd�a�b�c�d�ima�ad�bd�cd�dd�em_upper�em_lower�em�ms�n�m�ms11�ms12�ms13s                       r,rrOsX��F�6�{�{�a����!�!�#�#�#�
�6�{�{�a����U�6�!�9�f�Q�i�8�8�"�V�#(�*�*�*���T�!�W�d�1�g�t�A�w��Q��8�8�B�5�@�@�	�V����	�	��V�F�1�I�v�a�y�&��)�D�D�b�$*�%�9�9�9���d�1�g�t�A�w��Q���a��9�9�R�E�A�A�	�V����	�	��
��1�a����6�7�7�	7������=��K�L�L�
L�
�Q�Y�Y�%�!�)�)��8�9�9�
9������f�Q�W�Q�Z� � �5��8�A�:�-��
�\�#�r�v�a�g�a�j�1�1�S��Y��N�1�4D�D�
E�
E��
�\�#�r�!�t�
$�
$���\�#�-�-�/�/�1�;�;�=�=�
9�
9��
�\�\�^�^��
��r�v�a��}�}�$�
$���	�:�	�	��8�!3�!3��V�R��S�A�A�A�A�	�7�	�	�f��6�6��V�R��S�A�A�A�A�	�?�	"�	"��V�R��S�A�A�A�A�	�5����9�a��V�$�$���9�b�h����
�A�G�A�J�'?�@�@� �h����
�A�G�A�J�'?�@�@�B�C�C���Y��(�+�
,�
,��
�[��b��
!�
!���������Q�Q�Q��
��
����1�Q�W�Q�Z�<��
 ��
����1�7�1�:�;�;��
��
��
���	�5���
�G�A�J��
�G�A�J���$�R�X�q�!�f�%5�%5��%:�B�F�1�I�I�F�F���!�Q��Q��Y��(�(��
�X��z�H�:�.�
/�
/��
�[��_�_���"�1�"�a��c�'�{���"�1�"�a��A��g�+����"�1�"�a�!�e�f�f�*�~��
��
�D�[�4�$�;�
&��
��
��T��\���	�9�	�	��{�1�a� � �	;��:�;�;�
;��[��R��
 �
 ��
�!�V�b�[��
��
��U�R�Z����=��F�G�G�G�
�r�2�r�2��r-)NNNN)r)r\N)�__doc__rNrkrrrrrrr	r
rr�scipyr
�_filter_designrrr�__all__rr2r5r7r;r=rrrrrr9r-r,�<module>r�s�����
��������7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�7�������5�5�5�5�5�5�5�5�5�5�����^�^�^�B������
���������,�,�,�,�^V�V�V�V�r#�#�#�(3�3�3�3�<F�F�F�F�F�Fr-

Youez - 2016 - github.com/yon3zu
LinuXploit