
    bi                         d Z ddlZddlmZmZ ddlmc 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y)
a,  
Copyright 2013 Steven Diamond

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.
    N)ListTuple)AffAtom)
Constraintc                   0     e Zd ZdZd fdZd Zd Z xZS )UnaryOperatorz?
    Base class for expressions involving unary operators.
    c                 ,    t         t        |   |       y N)superr   __init__)selfexpr	__class__s     ]/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/affine/unary_operators.pyr   zUnaryOperator.__init__   s    mT+D1    c                 V    | j                   | j                  d   j                         z   S Nr   )OP_NAMEargsnamer   s    r   r   zUnaryOperator.name!   s"    ||diil//111r   c                 *    | j                  |d         S r   )OP_FUNC)r   valuess     r   numericzUnaryOperator.numeric%   s    ||F1I&&r   )returnN)__name__
__module____qualname____doc__r   r   r   __classcell__)r   s   @r   r   r      s    22'r   r   c                       e Zd ZdZdZej                  Zd Zde	e
df   fdZde	eef   fdZdefdZdefd	Zdefd
ZdefdZ	 dde	e
df   de	ej&                  ee   f   fdZy)NegExpressionzNegation of an expression.
    -c                     | j                   d   j                   r2| j                  dz   | j                   d   j                         z   dz   }|S | j                  | j                   d   j                         z   }|S )Nr   ())r   r   r   )r   retvals     r   r   zNegExpression.name/   si    IIaL\\C'$))A,*;*;*==CF  \\DIIaL$5$5$77Fr   r   .c                 4    | j                   d   j                  S )z8Returns the (row, col) shape of the expression.
        r   )r   shaper   s    r   shape_from_argszNegExpression.shape_from_args7   s     yy|!!!r   c                 v    | j                   d   j                         | j                   d   j                         fS )zCReturns sign (is positive, is negative) of the expression.
        r   )r   	is_nonpos	is_nonnegr   s    r   sign_from_argszNegExpression.sign_from_args<   s1     		!&&($))A,*@*@*BCCr   c                      y)z;Is the composition non-decreasing in argument idx?
        F r   idxs     r   is_incrzNegExpression.is_incrA   s     r   c                      y)z;Is the composition non-increasing in argument idx?
        Tr1   r2   s     r   is_decrzNegExpression.is_decrF   s     r   c                 <    | j                   d   j                         S )z%Is the expression symmetric?
        r   )r   is_symmetricr   s    r   r8   zNegExpression.is_symmetricK        yy|((**r   c                 <    | j                   d   j                         S )z%Is the expression Hermitian?
        r   )r   is_hermitianr   s    r   r;   zNegExpression.is_hermitianP   r9   r   Nr*   c                 6    t        j                  |d         g fS )a{  Negate the affine objective.

        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   )luneg_expr)r   arg_objsr*   datas       r   graph_implementationz"NegExpression.graph_implementationU   s    & HQK("--r   r
   )r   r   r   r    r   opnegr   r   r   intr+   boolr/   r4   r6   r8   r;   loLinOpr   r   rA   r1   r   r   r#   r#   )   s    GffG"sCx "
DdDj 1 D
d 
d 
+d +
+d + 6:.$S#X.	rxxj))	*.r   r#   )r    operatorrB   typingr   r   cvxpy.lin_ops.lin_oplin_opslin_oprF   cvxpy.lin_ops.lin_utils	lin_utilsr=   cvxpy.atoms.affine.affine_atomr   cvxpy.constraints.constraintr   r   r#   r1   r   r   <module>rQ      s<      ! ! $ $ 2 3'G ' ?.M ?.r   