Ë
    Ýbi	  ã                   óJ   — d Z ddlmZ ddlZddlm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ej                  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 )Úlengthz<Length of a vector (index of last nonzero, ones-based).
    Úreturnc                 ó|   •— t         t        |   |«       | j                  d   j	                  «       st        d«      ‚y )Nr   z(`length` can only be applied to vectors.)Úsuperr   Ú__init__ÚargsÚ	is_vectorÚ
ValueError)ÚselfÚxÚ	__class__s     €úM/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/length.pyr
   zlength.__init__   s;   ø€ ÜŒfdÑ$ QÔ'Øy‰y˜‰|×%Ñ%Ô'ÜØ:ó<ð <ð (ó    c                 óª   — t        j                  |d   «      t        j                  kD  }t        j                  t        j
                  |«      «      dz   S )z!Returns the length of x.
        r   é   )ÚnpÚabsÚsÚATOM_EVAL_TOLÚmaxÚnonzero)r   ÚvaluesÚoutside_tols      r   Únumericzlength.numeric!   s<   € ô —f‘f˜V A™YÓ'¬!¯/©/Ñ9ˆÜv‰v”b—j‘j Ó-Ó.°Ñ2Ð2r   .c                 ó   — t        «       S )z8Returns the (row, col) shape of the expression.
        )Útuple©r   s    r   Úshape_from_argszlength.shape_from_args(   s   € ô ‹wˆr   c                  ó   — y)zCReturns sign (is positive, is negative) of the expression.
        )TF© r    s    r   Úsign_from_argszlength.sign_from_args-   s   € ð r   c                  ó   — y)zIs the atom convex?
        Fr#   r    s    r   Úis_atom_convexzlength.is_atom_convex3   ó   € ð r   c                  ó   — y)zIs the atom concave?
        Fr#   r    s    r   Úis_atom_concavezlength.is_atom_concave8   r'   r   c                  ó   — y)ú!Is the atom quasiconvex?
        Tr#   r    s    r   Úis_atom_quasiconvexzlength.is_atom_quasiconvex=   s   € ð r   c                  ó   — y)r+   Fr#   r    s    r   Úis_atom_quasiconcavezlength.is_atom_quasiconcaveB   r'   r   c                 ó<   — | j                   |   j                  «       S )z;Is the composition non-decreasing in argument idx?
        )r   Ú	is_nonneg©r   Úidxs     r   Úis_incrzlength.is_incrG   ó   € ð y‰y˜‰~×'Ñ'Ó)Ð)r   c                 ó<   — | j                   |   j                  «       S )z;Is the composition non-increasing in argument idx?
        )r   Ú	is_nonposr1   s     r   Úis_decrzlength.is_decrL   r4   r   c                  ó   — y )Nr#   )r   r   s     r   Ú_gradzlength._gradQ   s   € Ør   )r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
   r   Únumpy_numericÚintr   r   r!   Úboolr$   r&   r)   r,   r.   r3   r7   r9   Ú__classcell__)r   s   @r   r   r      s¤   ø„ ñõ<ð 
×Ñð3 ò 3ó ð3ð  s¨C x¡ó ð
  d¨D jÑ 1ó ð ó ð
 ó ð
 Tó ð
 dó ð
*˜dó *ð
*˜dó *÷
r   r   )r=   Útypingr   Únumpyr   Úcvxpy.settingsÚsettingsr   Úcvxpy.atoms.atomr   r   r#   r   r   ú<module>rG      s$   ðñõ ã å Ý !ô:ˆTõ :r   