
    bi                     R    d Z ddlmZm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.
    )ListTuple)linalg)Atom)
Constraintc                        e Zd ZdZd fdZd Zdee   fdZd Z	d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efdZdefdZ xZS )gen_lambda_maxzBMaximum generalized eigenvalue; :math:`\lambda_{\max}(A, B)`.
    returnc                 .    t         t        |   ||       y )N)superr	   __init__)selfAB	__class__s      U/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/gen_lambda_max.pyr   zgen_lambda_max.__init__   s    nd,Q2    c                     | j                   d   j                  d   dz
  x}}t        j                  |d   |d   d||f      d   S )zReturns the largest generalized eigenvalue corresponding to A and B.

        Requires that A is symmetric, B is positive semidefinite.
        r      T)abeigvals_onlysubset_by_index)argsshapeLAeigh)r   valueslohis       r   numericzgen_lambda_max.numeric   sX    
 ))A,$$Q'))Rww$((*Bx1 234 	4r   c                     | j                   d   j                  | j                   d   k(  | j                   d   j                  | j                   d   k(  | j                   d   dz	  gS )z?Returns constraints describing the domain of the node.
        r   r   )r   Hr   s    r   _domainzgen_lambda_max._domain*   sU     		!$))A,.		!$))A,0N		!!# 	#r   c                     t               )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.
        )NotImplementedError)r   r   s     r   _gradzgen_lambda_max._grad0   s     "##r   c                    | j                   d   j                  dk(  r| j                   d   j                  d   | j                   d   j                  d   k7  sl| j                   d   j                  d   | j                   d   j                  d   k7  s3| j                   d   j                  | j                   d   j                  k7  rHt        d| j                   d   j	                         d| j                   d   j	                         d      y)zLVerify that the argument A, B are square and of the same dimension.
        r      r   zThe arguments 'z' and 'z@' to gen_lambda_max must be square and have the same dimensions.N)r   ndimr   
ValueErrornamer$   s    r   validate_argumentsz!gen_lambda_max.validate_arguments=   s     		!!!Q&		!""1%1););A)>>		!""1%1););A)>>		!""diil&8&88 1""$diil&7&7&9;< < 9r   .c                     t               S )z8Returns the (row, col) shape of the expression.
        )tupler$   s    r   shape_from_argszgen_lambda_max.shape_from_argsI   s     wr   c                      y)zCReturns sign (is positive, is negative) of the expression.
        )FF r$   s    r   sign_from_argszgen_lambda_max.sign_from_argsN   s     r   c                      y)zIs the atom convex?
        Fr3   r$   s    r   is_atom_convexzgen_lambda_max.is_atom_convexS        r   c                      y)zIs the atom concave?
        Fr3   r$   s    r   is_atom_concavezgen_lambda_max.is_atom_concaveX   r7   r   c                      y)z!Is the atom quasiconvex?
        Tr3   r$   s    r   is_atom_quasiconvexz"gen_lambda_max.is_atom_quasiconvex]   s     r   c                      y)z"Is the atom quasiconcave?
        Fr3   r$   s    r   is_atom_quasiconcavez#gen_lambda_max.is_atom_quasiconcaveb   r7   r   c                      y)z;Is the composition non-decreasing in argument idx?
        Fr3   r   idxs     r   is_incrzgen_lambda_max.is_incrg   r7   r   c                      y)z;Is the composition non-increasing in argument idx?
        Fr3   r?   s     r   is_decrzgen_lambda_max.is_decrl   r7   r   )r
   N)__name__
__module____qualname____doc__r   r!   r   r   r%   r(   r.   r   intr1   boolr4   r6   r9   r;   r=   rA   rC   __classcell__)r   s   @r   r	   r	      s    3	4#j) #$
<sCx 
dDj 1 
 
 
T 
d 
d 
d r   r	   N)rG   typingr   r   scipyr   r   cvxpy.atoms.atomr   cvxpy.constraints.constraintr   r	   r3   r   r   <module>rO      s&      ! 3WT Wr   