
    bi                     >    d Z ddlmZ ddlZddlmZ  G d de      Zy)a,  
Copyright 2018 Akshay Agrawal

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 fdZd Zd Zdef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ddZ xZS )pf_eigenvaluea  The Perron-Frobenius eigenvalue of a positive matrix.

    For an elementwise positive matrix :math:`X`, this atom represents its
    spectral radius, i.e., the magnitude of its largest eigenvalue. Because
    :math:`X` is positive, the spectral radius equals its largest eigenvalue,
    which is guaranteed to be positive.

    This atom is log-log convex.

    Parameters
    ----------
    X : cvxpy.Expression
        A positive square matrix.
    returnc                 J    t         t        |   |       || j                  d<   y Nr   )superr   __init__args)selfX	__class__s     T/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/pf_eigenvalue.pyr   zpf_eigenvalue.__init__'   s    mT+A.		!    c                     t        j                  t        j                  t         j                  j	                  |d         d               S r	   )npmaxabslinalgeigr   valuess     r   numericzpf_eigenvalue.numeric+   s0    vvbffRYY]]6!95a89::r   c                    | j                   d   j                  dk(  r9| j                   d   j                  d   | j                   d   j                  d   k7  r*t        d| j                   d   j	                          d      y)z,Verify that the argument is a square matrix.r         zThe argument z- to pf_eigenvalue must be a 2-d square array.N)r   ndimshape
ValueErrornamer   s    r   validate_argumentsz pf_eigenvalue.validate_arguments.   sx    yy|  A%1););A)>$))A,BTBTUVBW)W		! 1 1 344ab  *Xr   c                 T    | j                   j                  d| j                  d   dS )N(r   ))r   __name__r   r"   s    r   r!   zpf_eigenvalue.name5   s    >>22DIIaLAAr   .c                     t               S )z8Returns the (row, col) shape of the expression.
        )tupler"   s    r   shape_from_argszpf_eigenvalue.shape_from_args8   s     wr   c                      y)zCReturns sign (is positive, is negative) of the expression.
        )TF r"   s    r   sign_from_argszpf_eigenvalue.sign_from_args=   s     r   c                      y)zIs the atom convex?
        Fr,   r"   s    r   is_atom_convexzpf_eigenvalue.is_atom_convexB        r   c                      y)zIs the atom concave?
        Fr,   r"   s    r   is_atom_concavezpf_eigenvalue.is_atom_concaveG   r0   r   c                      y)z$Is the atom log-log convex?
        Tr,   r"   s    r   is_atom_log_log_convexz$pf_eigenvalue.is_atom_log_log_convexL        r   c                      y)z%Is the atom log-log concave?
        Fr,   r"   s    r   is_atom_log_log_concavez%pf_eigenvalue.is_atom_log_log_concaveQ   r0   r   c                      y)z;Is the composition non-decreasing in argument idx?
        Tr,   r   idxs     r   is_incrzpf_eigenvalue.is_incrV   r5   r   c                      y)z;Is the composition non-increasing in argument idx?
        Fr,   r9   s     r   is_decrzpf_eigenvalue.is_decr[   r0   r   c                      y )Nr,   r   s     r   _gradzpf_eigenvalue._grad`   s    r   )r   N)r'   
__module____qualname____doc__r   r   r#   strr!   r   intr*   boolr-   r/   r2   r4   r7   r;   r=   r?   __classcell__)r   s   @r   r   r      s    ;Bc BsCx 
dDj 1 
 
 
 
 
d 
d 
r   r   )rB   typingr   numpyr   cvxpy.atoms.atomr   r   r,   r   r   <module>rJ      s#       !ID Ir   