
    biV                         d Z ddlmZmZ ddlmc mZ ddlm	Z	 ddl
mZ  G d de	      Z G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d de      Zd Zy)aE  
Copyright 2013 Steven Diamond, 2022 the CVXPY authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
    )ListTupleN)AffAtom)
Constraintc                        e Zd ZdZd fdZdefdZdefdZd ZdefdZ	de
edf   fd	Z	 dd
e
edf   de
ej                  ee   f   fdZ xZS )Wrapz*A no-op wrapper to assert properties.
    returnc                 *    t         t        |   |      S N)superr   __init__)selfarg	__class__s     S/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/affine/wraps.pyr   zWrap.__init__   s    T4)#..    c                      yNT r   s    r   is_atom_log_log_convexzWrap.is_atom_log_log_convex       r   c                      yr   r   r   s    r   is_atom_log_log_concavezWrap.is_atom_log_log_concave    r   r   c                     |d   S )z Returns input.
        r   r   )r   valuess     r   numericzWrap.numeric#   s     ayr   c                 <    | j                   d   j                         S Nr   args
is_complexr   s    r   r"   zWrap.is_complex(   s    yy|&&((r   .c                 4    | j                   d   j                  S )zShape of input.
        r   )r!   shaper   s    r   shape_from_argszWrap.shape_from_args+   s     yy|!!!r   r$   c                     |d   g fS )a  Stack the expressions horizontally.

        Parameters
        ----------
        arg_objs : list
            LinExpr for each argument.
        shape : tuple
            The shape of the resulting expression.
        data :
            Additional data required by the atom.

        Returns
        -------
        tuple
            (LinOp for objective, list of constraints)
        r   r   )r   arg_objsr$   datas       r   graph_implementationzWrap.graph_implementation0   s    & R  r   r	   Nr   )__name__
__module____qualname____doc__r   boolr   r   r   r"   r   intr%   loLinOpr   r   r)   __classcell__)r   s   @r   r   r      s    /  
)D )"sCx " 6:!$S#X!	rxxj))	*!r   r   c                       e Zd ZdZdefdZy)nonneg_wrapz0Asserts that the expression is nonnegative.
    r	   c                      yr   r   r   s    r   	is_nonnegznonneg_wrap.is_nonnegI   r   r   N)r+   r,   r-   r.   r/   r7   r   r   r   r5   r5   F       4 r   r5   c                       e Zd ZdZdefdZy)nonpos_wrapz0Asserts that the expression is nonpositive.
    r	   c                      yr   r   r   s    r   	is_nonposznonpos_wrap.is_nonposP   r   r   N)r+   r,   r-   r.   r/   r<   r   r   r   r:   r:   M   r8   r   r:   c                   H    e Zd ZdZd	dZdefdZdefdZdefdZdefdZ	y)
psd_wrapz)Asserts that a square matrix is PSD.
    r	   Nc                     | j                   d   }t        |j                        dk(  }|st        d      |j                  d   |j                  d   k7  rt        d      y Nr      "The input must be a square matrix.   r!   lenr$   
ValueErrorr   r   	ndim_tests      r   validate_argumentszpsd_wrap.validate_argumentsX   Y    iil		Na'	ABBYYq\SYYq\)ABB *r   c                      yr   r   r   s    r   is_psdzpsd_wrap.is_psd`   r   r   c                      y)NFr   r   s    r   is_nsdzpsd_wrap.is_nsdc   s    r   c                 >    | j                   d   j                          S r   r    r   s    r   is_symmetriczpsd_wrap.is_symmetricf   s    99Q<**,,,r   c                      yr   r   r   s    r   is_hermitianzpsd_wrap.is_hermitiani   r   r   r*   )
r+   r,   r-   r.   rI   r/   rL   rN   rP   rR   r   r   r   r>   r>   T   s=    C  -d -d r   r>   c                   0    e Zd ZdZddZdefdZdefdZy)symmetric_wrapz3Asserts that a real square matrix is symmetric
    r	   Nc                 4    t        | j                  d          y r   validate_real_squarer!   r   s    r   rI   z!symmetric_wrap.validate_argumentsq       TYYq\*r   c                      yr   r   r   s    r   rP   zsymmetric_wrap.is_symmetrict   r   r   c                      yr   r   r   s    r   rR   zsymmetric_wrap.is_hermitianw   r   r   r*   )r+   r,   r-   r.   rI   r/   rP   rR   r   r   r   rT   rT   m   s$    +d d r   rT   c                   $    e Zd ZdZddZdefdZy)hermitian_wrapz/Asserts that a square matrix is Hermitian.
    r	   Nc                     | j                   d   }t        |j                        dk(  }|st        d      |j                  d   |j                  d   k7  rt        d      y r@   rD   rG   s      r   rI   z!hermitian_wrap.validate_arguments   rJ   r   c                      yr   r   r   s    r   rR   zhermitian_wrap.is_hermitian   r   r   r*   )r+   r,   r-   r.   rI   r/   rR   r   r   r   r\   r\   {   s    Cd r   r\   c                   $    e Zd ZdZddZdefdZy)skew_symmetric_wrapzEAsserts that X is a real square matrix, satisfying X + X.T == 0.
    r	   Nc                 4    t        | j                  d          y r   rV   r   s    r   rI   z&skew_symmetric_wrap.validate_arguments   rX   r   c                      yr   r   r   s    r   is_skew_symmetricz%skew_symmetric_wrap.is_skew_symmetric   r   r   r*   )r+   r,   r-   r.   rI   r/   rc   r   r   r   r`   r`      s    +4 r   r`   c                     t        | j                        dk(  }|st        d      | j                  d   | j                  d   k7  rt        d      | j                         st        d      y )NrA   rB   r   rC   z The input must be a real matrix.)rE   r$   rF   is_real)r   rH   s     r   rW   rW      sa    CII!#I=>>	11	%=>>[[];<< r   )r.   typingr   r   cvxpy.lin_ops.lin_oplin_opslin_opr1   cvxpy.atoms.affine.affine_atomr   cvxpy.constraints.constraintr   r   r5   r:   r>   rT   r\   r`   rW   r   r   r   <module>rl      su     ! ! 2 3,!7 ,!^$ $ t 2T T  $ =r   