
    bi4                     0    d Z ddlZddlmZ d Zddef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.

THIS FILE IS DEPRECATED AND MAY BE REMOVED WITHOUT WARNING!
DO NOT CALL THESE FUNCTIONS IN YOUR CODE!
    Nc                 F    | j                   |dz      | j                   |   z
  S )z*Return the number of nonzeros in row.
       )indptr)matrows     `/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/cvxpy/reductions/solvers/compr_matrix.pyget_row_nnzr	      s$     ::c!eszz#..    	equil_epsc                    g }g }g }g }i }| j                   d   }t        | j                  d         D ]  }	d}
| j                   |	dz      }t        | j                  ||       }||z
  }|dk(  s/t
        j                  j                  | j                  ||       |k  r6d}
|j                  d       |j                  |	       |j                  d       n||v r|t        | ||   d         k(  r||   }|D ]  }| j                  || }| j                   |   }| j                   |dz      }| j                  || }||z  }t        j                  |      |k  s`t        |d   ||	   ||   z  z
        |k  s~d}
|j                  |d          |j                  |	       |j                  |        |
r||   j                  |	       n|	g||<   |
s|j                  |	       |j                  d       |j                  |	       |j                  t        |      dz
          t        t        |      d      }t        j                   |||ff| j                  d   |f      }| |ddf   }||   }|||fS )a5  Compresses A and b by eliminating redundant rows.

    Identifies rows that are multiples of another row.
    Reduces A and b to C = PA, d = Pb, where P has one
    nonzero per row.

    Parameters
    ----------
    A : SciPy CSR matrix
        The constraints matrix to compress.
    b : NumPy 1D array
        The vector associated with the constraints matrix.
    equil_eps : float, optional
        Standard for considering two numbers equivalent.

    Returns
    -------
    tuple
        The tuple (A, b, P) where A and b are compressed according to P.
    r   Tr   Fg        g      ?N)r   rangeshapetupleindicesnplinalgnormdataappendr	   ptpabslenmaxsp
coo_matrix)Abr   P_VP_IP_Jrow_to_keepsparsity_to_rowprev_ptrrow_numkeep_rowptrpatternnnzrow_matches	row_matchcur_valsprev_match_ptr	match_ptr
match_valsratiocolsPA_comprb_comprs                            r   compress_matrixr4      su   , C
C
CKOxx{H$ (+hhwqy!		(3/0Hn!8ryy~~affXc&:;iGHJJrNJJwJJqM 'CAw7:;-< *'2K( *	66(3/!")!4HHYq[1	VVN9=
 +66%=9,uQx!G*Qy\"99:YF$HJJuQx(JJw'JJy)* (//8 )0yOG$w'JJrNJJwJJs;')*Q(+V s;#D
sS#J'!''!*d);<AQGnGWa  r
   )g|=)	__doc__numpyr   scipy.sparsesparser   r	   floatr4    r
   r   <module>r;      s%   $  /M!U M!r
   