
    bi                     z    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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Hstackc                     | D cg c]  }t        j                  |       } }t        |       D ]*  \  }}|j                  dk(  s|j	                  d      | |<   , t        |  S c c}w )zHorizontal concatenation of an arbitrary number of Expressions.

    Parameters
    ----------
    arg_list : list of Expression
        The Expressions to concatenate.
    r   F)order)r   cast_to_const	enumeratendimflattenr   )arg_listargidxs      T/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/atoms/affine/hstack.pyhstackr      sl     7??s%%c*?H?h' 3S88q=KKcK2HSM3 8	 @s   A#c                       e Zd ZdZdefdZdefdZd Zdee	df   fdZ
dd	Z	 dd
ee	df   deej                  ee   f   fdZy)r   z Horizontal concatenation returnc                      yNT selfs    r   is_atom_log_log_convexzHstack.is_atom_log_log_convex+           c                      yr   r   r   s    r   is_atom_log_log_concavezHstack.is_atom_log_log_concave.   r   r   c                 ,    t        j                  |      S N)npr   )r   valuess     r   numericzHstack.numeric2   s    yy  r   .c                 "   | j                   d   j                  dk(  rt        d | j                   D              fS t        d | j                   D              }| j                   d   j                  d   |f| j                   d   j                  dd  z   S )Nr      c              3   4   K   | ]  }|j                     y wr!   )size.0r   s     r   	<genexpr>z)Hstack.shape_from_args.<locals>.<genexpr>8   s     6S6s   c              3   :   K   | ]  }|j                   d      yw)r&   N)shaper)   s     r   r+   z)Hstack.shape_from_args.<locals>.<genexpr>:   s     9syy|9s      )argsr   sumr-   )r   colss     r   shape_from_argszHstack.shape_from_args6   s|    99Q<!6DII66889tyy99DIIaL&&q)40499Q<3E3Eab3IIIr   Nc                 D   | j                   d   j                  }t        d      }| j                   dd  D ]j  }t        |j                        t        |      k7  r|t        |      dkD  s5t	        t        |            D ]  }|dk7  s	|j                  |   ||   k7  s| l y )Nr   z>All the input dimensions except for axis 1 must match exactly.r&   )r/   r-   
ValueErrorlenrange)r   modelerrorr   is        r   validate_argumentszHstack.validate_arguments>   s    		!"" > @99QR= 	$C399~U+Uas5z* $AAv#))A,%(":#$		$r   r-   c                 2    t        j                  ||      g fS )a  Stack the expressions horizontally.

        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)
        )lur   )r   arg_objsr-   datas       r   graph_implementationzHstack.graph_implementationJ   s    & 		(E*B//r   )r   Nr!   )__name__
__module____qualname____doc__boolr   r   r$   r   intr2   r:   loLinOpr   r   r?   r   r   r   r   r   )   sr    $  !JsCx J
$ 6:0$S#X0	rxxj))	*0r   )r   r   )rC   typingr   r   numpyr"   cvxpy.lin_ops.lin_oplin_opslin_oprF   cvxpy.lin_ops.lin_utils	lin_utilsr<   cvxpy.atoms.affine.affine_atomr   cvxpy.constraints.constraintr   r   r   r   r   r   <module>rQ      s5      ! ! $ $ 2 340W 40r   