
    bi                         d Z ddlmZmZ ddlZddlmc mZ	 ddl
mc mZ ddlmZ ddlmZ ddlmZ dedeed	f   fd
Z G d de      Zy)a,  
Copyright 2013 Steven Diamond

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)AffAtom)
Constraint)
Expressionexprshape.c                     t        j                  |       } | j                  |k7  r'| j                         st	        d      t        | |      S | S )a   Promote a scalar expression to a vector/matrix.

    Parameters
    ----------
    expr : Expression
        The expression to promote.
    shape : tuple
        The shape to promote to.

    Raises
    ------
    ValueError
        If ``expr`` is not a scalar.
    z0Only 0-d arrays (i.e., scalars) may be promoted.)r   cast_to_constr	   	is_scalar
ValueErrorPromote)r   r	   s     U/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/affine/promote.pypromoter      sH      ##D)DzzU~~OPPtU##    c                        e Zd ZdZdeedf   ddf fdZej                  d        Z	de
fdZde
fd	Zde
fd
Zdeedf   fdZd Z	 ddeedf   deej"                  ee   f   fdZ xZS )r   zPromote a scalar expression to a vector/matrix.

    Attributes
    ----------
    expr : Expression
        The expression to promote.
    shape : tuple
        The shape to promote to.
    r	   .returnNc                 :    || _         t        t        |   |       y N)promoted_shapesuperr   __init__)selfr   r	   	__class__s      r   r   zPromote.__init__?   s    #gt%d+r   c                 L    t        j                  | j                        |d   z  S )zPromotes the value.
        r   )nponesr   )r   valuess     r   numericzPromote.numericC   s"     wwt**+fQi77r   c                 b    | j                   dk(  xr | j                  d   | j                  d   k(  S )z%Is the expression symmetric?
           r      )ndimr	   r   s    r   is_symmetriczPromote.is_symmetricI   s,     yyA~@$**Q-4::a="@@r   c                      y)zIs the atom log-log convex?T r$   s    r   is_atom_log_log_convexzPromote.is_atom_log_log_convexN       r   c                      y)zIs the atom log-log concave?Tr'   r$   s    r   is_atom_log_log_concavezPromote.is_atom_log_log_concaveR   r)   r   c                     | j                   S )z8Returns the (row, col) shape of the expression.
        r   r$   s    r   shape_from_argszPromote.shape_from_argsV   s     """r   c                     | j                   gS )zLReturns info needed to reconstruct the expression besides the args.
        r-   r$   s    r   get_datazPromote.get_data[   s     ##$$r   c                 8    t        j                  |d   |      g fS )a~  Promote scalar to vector/matrix

        Parameters
        ----------
        arg_objs : list
            LinExpr for each argument.
        shape : tuple
            The shape of the resulting expression.
        data :
            Additional data required by the atom.

        Returns
        -------
        tuple
            (LinOp for objective, list of constraints)
        r   )lur   )r   arg_objsr	   datas       r   graph_implementationzPromote.graph_implementation`   s    & 

8A;.33r   r   )__name__
__module____qualname____doc__r   intr   r   numpy_numericr   boolr%   r(   r+   r.   r0   loLinOpr   r   r5   __classcell__)r   s   @r   r   r   4   s    ,E#s(O , , 8 8
Ad A
  #sCx #
% 6:4$S#X4	rxxj))	*4r   r   )r9   typingr   r   numpyr   cvxpy.lin_ops.lin_oplin_opslin_opr=   cvxpy.lin_ops.lin_utils	lin_utilsr2   cvxpy.atoms.affine.affine_atomr   cvxpy.constraints.constraintr   cvxpy.expressions.expressionr   r:   r   r   r'   r   r   <module>rJ      sN      ! ! $ $ 2 3 3* U38_ 2?4g ?4r   