-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set off-diagonal blocks to zero in 'out' argument of diagonal()
- Loading branch information
Showing
1 changed file
with
5 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -804,7 +804,11 @@ def diagonal(self, *, inverse = False, out = None): | |
assert isinstance(out, BlockLinearOperator) | ||
assert out.domain is V | ||
assert out.codomain is W | ||
assert all(i==j for i, j in out._blocks.keys()) # is this really needed? | ||
|
||
# Set any off-diagonal blocks to zero | ||
for i, j in out.nonzero_block_indices: | ||
if i != j: | ||
out[i, j] = None | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
yguclu
Author
Member
|
||
else: | ||
out = BlockLinearOperator(V, W) | ||
|
||
|
When doing this, does it also delete the keys
(i,j)
fromout.nonzero_block_indices
?