Skip to content

Commit

Permalink
Citing the scipy algorithms I'm reimplementing in docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
emma58 committed Nov 6, 2024
1 parent 7306e24 commit cfb9701
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion pyomo/repn/plugins/parameterized_standard_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ def __eq__(self, other):

class _CSRMatrix(_SparseMatrixBase):
def tocsc(self):
# Implements the same algorithm as scipy's csr_tocsc function
"""Implements the same algorithm as scipy's csr_tocsc function from
sparsetools.
"""
csr_data = self.data
col_index = self.indices
row_index_ptr = self.indptr
Expand Down Expand Up @@ -141,6 +143,9 @@ def tocsc(self):
return _CSCMatrix((csc_data, row_index, col_index_ptr), self.shape)

def todense(self):
"""Implements the algorithm from scipy's csr_todense function
in sparsetools.
"""
nrows = self.shape[0]
col_index = self.indices
row_index_ptr = self.indptr
Expand All @@ -157,6 +162,9 @@ def todense(self):

class _CSCMatrix(_SparseMatrixBase):
def todense(self):
"""Implements the algorithm from scipy's csr_todense function
in sparsetools.
"""
ncols = self.shape[1]
row_index = self.indices
col_index_ptr = self.indptr
Expand All @@ -171,6 +179,9 @@ def todense(self):
return dense

def sum_duplicates(self):
"""Implements the algorithm from scipy's csr_sum_duplicates function
in sparsetools.
"""
ncols = self.shape[1]
row_index = self.indices
col_index_ptr = self.indptr
Expand All @@ -194,6 +205,9 @@ def sum_duplicates(self):
col_index_ptr[i + 1] = num_non_zeros

def eliminate_zeros(self):
"""Implements the algorithm from scipy's csr_eliminate_zeros function
in sparsetools.
"""
ncols = self.shape[1]
row_index = self.indices
col_index_ptr = self.indptr
Expand Down

0 comments on commit cfb9701

Please sign in to comment.