
    bi0                     Z    d Z ddlmZmZ ddlZddlmZ ddlm	Z	 ddl
m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.
    )OptionalTupleN)Atom)AxisAtom)cvxtypesc                        e Zd ZdZdZddee   deddf fdZe	j                  d        Zd	 Z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efdZdefdZdefdZ xZS )minz":math:`\min{i,j}\{X_{i,j}\}`.
    a  

    The second argument to "min" was a cvxpy Expression, when it should have
    been an int or None. This is probably a result of calling "cp.min" when you
    should call "cp.minimum". The difference is that cp.min represents the
    minimum entry in a single vector or matrix, while cp.minimum represents
    the entry-wise min of a sequence of arguments that all have the same shape.

    Naxiskeepdimsreturnc                     t        |t        j                               rt        t        j
                        t        t        |   |||       y )Nr
   r   )
isinstancer   
expression
ValueErrorr	   __EXPR_AXIS_ERROR__super__init__)selfxr
   r   	__class__s       J/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/min.pyr   zmin.__init__'   s=    dH//12S4455c4!!$!B    c                 V    |d   j                  | j                  | j                        S )z)Returns the smallest entry in x.
        r   r   )r	   r
   r   r   valuess     r   numericzmin.numeric,   s#     ay}}$))dmm}DDr   c                 $    | j                  |      S )a+  Gives the (sub/super)gradient of the atom w.r.t. each argument.

        Matrix expressions are vectorized, so the gradient is a matrix.

        Args:
            values: A list of numeric values for the arguments.

        Returns:
            A list of SciPy CSC sparse matrices or None.
        )
_axis_gradr   s     r   _gradz	min._grad2   s     v&&r   c                     t        j                  |      j                  d      }t        j                  |      }t        j                  |j
                  df      }d||<   |S )a  Gives the (sub/super)gradient of the atom w.r.t. a column argument.

        Matrix expressions are vectorized, so the gradient is a matrix.

        Args:
            value: A numeric value for a column.

        Returns:
            A NumPy ndarray or None.
        F)order   )nparrayravelargminzerossize)r   valueidxDs       r   _column_gradzmin._column_grad?   sQ     %%C%0iiHHejj!_%#r   c                 v    | j                   d   j                         | j                   d   j                         fS )zCReturns sign (is positive, is negative) of the expression.
        r   )args	is_nonneg	is_nonposr   s    r   sign_from_argszmin.sign_from_argsQ   s1     		!&&($))A,*@*@*BCCr   c                      y)zIs the atom convex?
        F r3   s    r   is_atom_convexzmin.is_atom_convexW        r   c                      y)zIs the atom concave?
        Tr6   r3   s    r   is_atom_concavezmin.is_atom_concave\        r   c                      y)z$Is the atom log-log convex?
        Fr6   r3   s    r   is_atom_log_log_convexzmin.is_atom_log_log_convexa   r8   r   c                      y)z%Is the atom log-log concave?
        Tr6   r3   s    r   is_atom_log_log_concavezmin.is_atom_log_log_concavef   r;   r   c                      y)z;Is the composition non-decreasing in argument idx?
        Tr6   r   r,   s     r   is_incrzmin.is_incrk   r;   r   c                      y)z;Is the composition non-increasing in argument idx?
        Fr6   rA   s     r   is_decrzmin.is_decrp   r8   r   c                 <    | j                   d   j                         S )z&Is the atom piecewise linear?
        r   )r0   is_pwlr3   s    r   rF   z
min.is_pwlu   s     yy|""$$r   )NF)__name__
__module____qualname____doc__r   r   intboolr   r   numpy_numericr   r    r.   r   r4   r7   r:   r=   r?   rB   rD   rF   __classcell__)r   s   @r   r	   r	      s    C C CQU C
 
E E
'$DdDj 1 D 
 
 
 
d 
d 
% %r   r	   )rJ   typingr   r   numpyr%   cvxpy.atoms.atomr   cvxpy.atoms.axis_atomr   cvxpy.expressionsr   r	   r6   r   r   <module>rT      s)    #  ! * &_%( _%r   