
    bi                     J    d Z ddlmZ ddl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.
    )TupleN)Atomc                        e Zd ZdZdZd fdZd 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 xZS )normNucz Sum of the singular values.
    Treturnc                 ,    t         t        |   |       y )N)superr   __init__)selfA	__class__s     O/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/norm_nuc.pyr
   znormNuc.__init__   s    gt%a(    c                 H    t         j                  j                  |d   d      S )zMReturns the nuclear norm (i.e. the sum of the singular values) of A.
        r   nuc)nplinalgnorm)r   valuess     r   numericznormNuc.numeric!   s     yy~~fQi//r   c                     t         j                  j                  |d   d      \  }}}|j                  |      }t	        j
                  |j                  d      g      j                  g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.
        r   F)full_matricesF)order)r   r   svddotsp	csc_arrayravelT)r   r   U_VDs         r   _gradznormNuc._grad&   sW     ))--q	-?1aEE!HaggCg0124455r   .c                     t               S )z8Returns the (row, col) shape of the expression.
        )tupler   s    r   shape_from_argsznormNuc.shape_from_args6   s     wr   c                      y)zCReturns sign (is positive, is negative) of the expression.
        )TF r(   s    r   sign_from_argsznormNuc.sign_from_args;   s     r   c                      y)zIs the atom convex?
        Tr+   r(   s    r   is_atom_convexznormNuc.is_atom_convex@   s     r   c                      y)zIs the atom concave?
        Fr+   r(   s    r   is_atom_concaveznormNuc.is_atom_concaveE        r   c                      y)z;Is the composition non-decreasing in argument idx?
        Fr+   r   idxs     r   is_incrznormNuc.is_incrJ   r1   r   c                      y)z;Is the composition non-increasing in argument idx?
        Fr+   r3   s     r   is_decrznormNuc.is_decrO   r1   r   )r   N)__name__
__module____qualname____doc___allow_complexr
   r   r%   r   intr)   boolr,   r.   r0   r5   r7   __classcell__)r   s   @r   r   r      su    N)0
6 sCx 
dDj 1 
 
 
d 
d r   r   )r;   typingr   numpyr   scipy.sparsesparser   cvxpy.atoms.atomr   r   r+   r   r   <module>rE      s$        !9d 9r   