Utils
Warning
This page of the documentation is unfinished, and may significantly change in future versions.
Constraints and templates
- class popcor.utils.constraint.Constraint(index=0, polyrow_a=None, polyrow_b=None, A_poly=None, A_sparse=None, b=None, a=None, a_full=None, b_full=None, mat_var_dict=None, mat_param_dict=None, known=False, template_idx=0)[source]
This class serves the main purpose of not recomputing representations of constraints more than once.
Helpers for matrix and vector operations
- popcor.utils.common.create_symmetric(vec, eps_sparse, correct=False, sparse=False)[source]
Create a symmetric matrix from the vectorized elements of the upper half
- popcor.utils.common.diag_indices(n)[source]
Given the half kronecker product, return diagonal elements
- popcor.utils.common.get_vec(mat, correct=True, sparse=False) ndarray | csr_matrix | None [source]
Convert NxN Symmetric matrix to (N+1)N/2 vectorized version that preserves inner product.
- Parameters:
mat – (spmatrix or ndarray) symmetric matrix
- Returns:
ndarray
- popcor.utils.common.ravel_multi_index_triu(index_tuple, shape)[source]
Equivalent of np.multi_index_triu, but using only the upper-triangular part of matrix.