
    bi                     d    d Z ddlZddlmZmZ ddlmZ d Zd Z	d Z
d Zd	 Zd
 ZddefdZd 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.
    Nskew_symmetric_wrapsymmetric_wrap)Constantc                    t        d |D              r| j                  |      df}|S t        d |D              rd| j                  |      f}|S t        |      D ]j  \  }}|/t        t	        j
                  ||   j                              ||<   7||   =t        t	        j
                  ||   j                              ||<   l | j                  |      | j                  |      f}|S )zYCanonicalize linear functions that are separable
       in real and imaginary parts.
    c              3   $   K   | ]  }|d u  
 y wN .0vals     q/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/reductions/complex2real/canonicalizers/aff_canon.py	<genexpr>z"separable_canon.<locals>.<genexpr>   s     
,33$;
,   Nc              3   $   K   | ]  }|d u  
 y wr	   r
   r   s     r   r   z"separable_canon.<locals>.<genexpr>   s     .SSD[.r   )allcopy	enumerater   npzerosshape)expr	real_args	imag_args	real2imagoutputsidxreal_vals          r   separable_canonr      s     
,)
,,99Y'. N 
.I.	.9-. N 'y1 	JMC!)"((9S>3G3G*H!I	#3'!)"((9S>3G3G*H!I	#		J
 99Y'9)=>N    c                 .    |d   
d|d   z  d fS |d   d fS Nr   r
   r   r   r   r   s       r   
real_canonr$   )   .    |1~t##|T!!r    c                 .    |d   
d|d   z  d fS |d   d fS r"   r
   r#   s       r   
imag_canonr'   1   r%   r    c                 R    |d   t        |d         }nd }t        |d         }||fS r"   r   )r   r   r   r   imag_argreal_args         r   hermitian_wrap_canonr+   9   s:    |&y|4 il+HXr    c                 ,    |d   d }n|d    }|d   |fS r"   r
   )r   r   r   r   r)   s        r   
conj_canonr-   C   s+    |aL=Q<!!r    c                 2    ||y| j                  ||g      S )z*Helper function to combine arguments.
    N)r   )r   lh_argrh_args      r   joinr1   K   s$     ~yy&&)**r    negc                 4    ||r| }| |y| |S || S | |z   S )zLHelper function to sum arguments.
       Negates rh_arg if neg is True.
    Nr
   )r/   r0   r2   s      r   addr4   T   s=     c~&.		r    c                     t        | |d   |d         }t        | |d   |d         }t        | |d   |d         }t        | |d   |d         }t        ||d      }t        ||d      }	||	fS )z0Canonicalize functions like multiplication.
    r      T)r2   F)r1   r4   )
r   r   r   r   real_by_realimag_by_imagreal_by_imagimag_by_realreal_outputimag_outputs
             r   binary_canonr=   e   s     ilIaL9LilIaL9LilIaL9LilIaL9LlLd;KlLe<K##r    )F)__doc__numpyr   cvxpy.atoms.affine.wrapsr   r   cvxpy.expressions.constantsr   r   r$   r'   r+   r-   r1   boolr4   r=   r
   r    r   <module>rC      sD      H 0$"""+T "	$r    