Skip to content

Commit

Permalink
[REF] Use divmod
Browse files Browse the repository at this point in the history
  • Loading branch information
f-dangel committed Jul 3, 2024
1 parent 84bdc1d commit eafdb08
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions singd/structures/blockdiagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ def from_mat_inner(cls, X: Tensor) -> BlockDiagonalMatrixTemplate:
The structured matrix extracted from `X @ X^T`.
"""
dim = X.shape[0]
num_blocks = dim // cls.BLOCK_DIM
last_dim = dim - num_blocks * cls.BLOCK_DIM
num_blocks, last_dim = divmod(dim, cls.BLOCK_DIM)
dims = {"block": num_blocks, "row": cls.BLOCK_DIM}

X_blocks, X_last = X.split([num_blocks * cls.BLOCK_DIM, last_dim])
Expand Down

0 comments on commit eafdb08

Please sign in to comment.