
    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 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.
    )TupleN)NDArrayInterfacec                   v    e Zd ZdZej
                  Zej                  d
de	fd       Z
d Zdeedf   fdZd Zy	)MatrixInterfacezL
    An interface to convert constant values to the numpy matrix class.
    convert_scalarsc                 0   t        |t              s)t        |t        j                        r1|j                  dk(  r"t        j
                  |d      j                  }n%t        j                  |      r|j                         }t        j
                  |d      S )a  Convert an arbitrary value into a matrix of type self.target_matrix.

        Args:
            value: The constant to be converted.
            convert_scalars: Should scalars be converted?

        Returns:
            A matrix of type self.target_matrix or a scalar.
           float64dtype)

isinstancelistnpndarrayndimasmatrixTspissparsetodense)selfvaluer   s      k/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/interface/numpy_interface/matrix_interface.pyconst_to_matrixzMatrixInterface.const_to_matrix   sd     eT"5"**-%**/KKY799E[[MMOE{{5	22    c                 R    t        j                  t        j                  |            S )N)r   r   eye)r   sizes     r   identityzMatrixInterface.identity3   s    {{266$<((r   shape.c                 `    t        j                  |d      |z   }t        j                  |      S )Nr
   r   )r   zerosr   )r   r   r    mats       r   scalar_matrixzMatrixInterface.scalar_matrix7   s&    hhuI.6{{3r   c                 2    t        j                  ||d      S )NF)order)r   reshape)r   matrixr   s      r   r(   zMatrixInterface.reshape;   s    zz&$c22r   N)F)__name__
__module____qualname____doc__r   r)   TARGET_MATRIXr   scalar_constboolr   r   r   intr$   r(    r   r   r   r      sO     IIM""3d 3 #3() %S/  3r   r   )r-   typingr   numpyr   scipy.sparsesparser   1cvxpy.interface.numpy_interface.ndarray_interfacer   r   r2   r   r   <module>r8      s%       N$3& $3r   