
    bi                     V    d Z ddlmZmZ ddlZddlZddlmZ ddl	m
Z
  G d de      Zy)a6  
Copyright 2013 Steven Diamond, Eric Chu

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)log)
Constraintc                   v     e Zd ZdZd fdZej                  d        Zdee	e	f   fdZ
d Zdee   fdZ xZS )	log1pz&Elementwise :math:`\log (1 + x)`.
    returnc                 ,    t         t        |   |       y )N)superr   __init__)selfx	__class__s     X/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/elementwise/log1p.pyr   zlog1p.__init__   s    eT#A&    c                 F    t         j                  j                  |d         S )z4Returns the elementwise natural log of x+1.
        r   )scipyspecialr   )r   valuess     r   numericzlog1p.numeric    s     }}""6!9--r   c                 v    | j                   d   j                         | j                   d   j                         fS )z'The same sign as the argument.
        r   )args	is_nonneg	is_nonposr   s    r   sign_from_argszlog1p.sign_from_args&   s1     		!&&($))A,*@*@*BCCr   c                     | j                   d   j                  }| j                  }t        j                  |d         dk  rdgS 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   Ng      ?   )r   sizenpminr   elemwise_grad_to_diag)r   r   rowscols	grad_valss        r   _gradzlog1p._grad+   sf     yy|  yy66&)"6MVAYq[)I//	4FGGr   c                 (    | j                   d   dk\  gS )z?Returns constraints describing the domain of the node.
        r   r   )r   r   s    r   _domainzlog1p._domain@   s     		!"##r   )r	   N)__name__
__module____qualname____doc__r   r   numpy_numericr   r   boolr   r'   r   r   r)   __classcell__)r   s   @r   r   r      sU    ' 	. .
DdDj 1 D
H*$j) $r   r   )r-   typingr   r   numpyr!   r   cvxpy.atoms.elementwise.logr   cvxpy.constraints.constraintr   r    r   r   <module>r6      s'       + 3*$C *$r   