Skip to content

Commit

Permalink
ENH: reduce annihilator matrix memory usage (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffgortmaker committed Jun 12, 2024
1 parent d1a7361 commit 96b1452
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pyblp/utilities/statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ def estimate(
parameters_list = np.split(parameters, [x.shape[1] for x in X_list[:-1]], axis=0)
residuals_list = np.split(residuals, len(X_list), axis=0)

# optionally convert Jacobians
# optionally convert Jacobians (making sure to never create a full square matrix)
if convert_jacobians:
jacobian = (np.eye(y.size) - X @ self.covariances @ XZ @ W @ Z.T) @ np.vstack(jacobian_list)
jacobian = np.vstack(jacobian_list)
jacobian -= X @ (self.covariances @ (XZ @ (W @ (Z.T @ jacobian))))
jacobian_list = np.split(jacobian, len(jacobian_list), axis=0)

return parameters_list, residuals_list, jacobian_list
Expand Down

0 comments on commit 96b1452

Please sign in to comment.