Skip to content

Commit

Permalink
fix: rank starts at 1 for svd reconstruction tolerance
Browse files Browse the repository at this point in the history
  • Loading branch information
eckelsjd committed Dec 11, 2024
1 parent afa5385 commit 445e927
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/amisc/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,8 @@ def compute_map(self, data_matrix: np.ndarray | dict, rank: int = None, energy_t
energy_tol = energy_frac[rank - 1]
reconstruction_tol = relative_error(u[:, :rank] @ u[:, :rank].T @ data_matrix, data_matrix)
elif reconstruction_tol := (reconstruction_tol or self.reconstruction_tol):
for r in range(u.shape[1]):
rank = u.shape[1]
for r in range(1, u.shape[1] + 1):
if relative_error(u[:, :r] @ u[:, :r].T @ data_matrix, data_matrix) <= reconstruction_tol:
rank = r
break
Expand Down

0 comments on commit 445e927

Please sign in to comment.