
    biw	                     >    d Z ddlmZ ddlZddlmZ  G d de      Zy)a+  
Copyright, 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.
    )TupleN)Atomc                        e Zd ZdZd f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de	fdZde	fdZddZ xZS )
dist_ratiozjnorm(x - a)_2 / norm(x - b)_2, with norm(x - a)_2 <= norm(x - b).

    `a` and `b` must be constants.
    returnc                 H   t         t        |   |||       | j                  d   j	                         st        d      | j                  d   j	                         st        d      | j                  d   j                  | _        | j                  d   j                  | _        y )N   z`a` must be a constant.   z`b` must be a constant.)	superr   __init__argsis_constant
ValueErrorvalueab)selfxr   r   	__class__s       Q/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/dist_ratio.pyr   zdist_ratio.__init__   s    j$(Aq1yy|'')677yy|'')6771##1##    c                     t         j                  j                  |d   | j                  z
        t         j                  j                  |d   | j                  z
        z  S )z$Returns the distance ratio.
        r   )nplinalgnormr   r   r   valuess     r   numericzdist_ratio.numeric%   sM     yy~~1I "$))..TVV1C"DE 	Er   .c                     t               S )z8Returns the (row, col) shape of the expression.
        )tupler   s    r   shape_from_argszdist_ratio.shape_from_args+   s     wr   c                      y)zCReturns sign (is positive, is negative) of the expression.
        )TF r!   s    r   sign_from_argszdist_ratio.sign_from_args0   s     r   c                      y)zIs the atom convex?
        Fr$   r!   s    r   is_atom_convexzdist_ratio.is_atom_convex6        r   c                      y)zIs the atom concave?
        Fr$   r!   s    r   is_atom_concavezdist_ratio.is_atom_concave;   r(   r   c                      y)!Is the atom quasiconvex?
        Tr$   r!   s    r   is_atom_quasiconvexzdist_ratio.is_atom_quasiconvex@   s     r   c                      y)r,   Fr$   r!   s    r   is_atom_quasiconcavezdist_ratio.is_atom_quasiconcaveE   r(   r   c                      y)z;Is the composition non-decreasing in argument idx?
        Fr$   r   idxs     r   is_incrzdist_ratio.is_incrJ   r(   r   c                      y)z;Is the composition non-increasing in argument idx?
        Fr$   r1   s     r   is_decrzdist_ratio.is_decrO   r(   r   c                      y )Nr$   r   s     r   _gradzdist_ratio._gradT   s    r   )r   N)__name__
__module____qualname____doc__r   r   r   intr"   boolr%   r'   r*   r-   r/   r3   r5   r7   __classcell__)r   s   @r   r   r      s    $EsCx 
dDj 1  
 
T 
d 
d 
d 
r   r   )r;   typingr   numpyr   cvxpy.atoms.atomr   r   r$   r   r   <module>rB      s!      !> >r   