
    biz
                     N    d Z ddlmZmZ ddlZddlmZ ddlm	Z	  G d de      Z
y)a0  
Copyright 2022, the CVXPY authors

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TupleN)Elementwise)
Constraintc                        e Zd ZdZd fdZej                  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 Zdee   fdZ xZS )xexpz#Elementwise :math:`{x}*e^{x}`.
    returnc                 ,    t         t        |   |       y )N)superr   __init__)selfx	__class__s     W/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/elementwise/xexp.pyr   zxexp.__init__   s    dD"1%    c                 >    |d   t        j                  |d         z  S )Nr   )npexp)r   valuess     r   numericzxexp.numeric!   s    ay266&),,,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xexp.sign_from_args%   s1     		!&&($))A,*@*@*BCCr   c                 <    | j                   d   j                         S )zIs the atom convex?
        r   )r   r   r   s    r   is_atom_convexzxexp.is_atom_convex+   s     yy|%%''r   c                      y)zIs the atom concave?
        F r   s    r   is_atom_concavezxexp.is_atom_concave0        r   c                      y)z$Is the atom log-log convex?
        Tr    r   s    r   is_atom_log_log_convexzxexp.is_atom_log_log_convex5        r   c                      y)z%Is the atom log-log concave?
        Fr    r   s    r   is_atom_log_log_concavezxexp.is_atom_log_log_concave:   r"   r   c                      y)z;Is the composition non-decreasing in argument idx?
        Tr    r   idxs     r   is_incrzxexp.is_incr?   r%   r   c                      y)z;Is the composition non-increasing in argument idx?
        Fr    r)   s     r   is_decrzxexp.is_decrD   r"   r   c                     | j                   d   j                  }| j                  }t        j                  |d         d|d   z   z  }t        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      )r   sizer   r   r   elemwise_grad_to_diag)r   r   rowscols	grad_valss        r   _gradz
xexp._gradI   sW     yy|  yyFF6!9%VAY7	**9dDABBr   c                 (    | j                   d   dk\  gS )z?Returns constraints describing the domain of the node.
        r   )r   r   s    r   _domainzxexp._domainY   s     		!!""r   )r	   N)__name__
__module____qualname____doc__r   r   numpy_numericr   r   boolr   r   r!   r$   r'   r+   r-   r5   r   r   r7   __classcell__)r   s   @r   r   r      s    & - -DdDj 1 D( (
 
 
 
d 
d 
C #j) #r   r   )r;   typingr   r   numpyr   #cvxpy.atoms.elementwise.elementwiser   cvxpy.constraints.constraintr   r   r    r   r   <module>rC      s&       ; 3C#; C#r   