Skip to content

Commit

Permalink
Make the direct method in BlockOperator clearer with a variable name …
Browse files Browse the repository at this point in the history
…change (#1557)

Changed internal variable name in BlockOperator to aid understanding 

-----------------------
Co-authored-by:  Edoardo Pasca <[email protected]>
Signed-off-by: Margaret Duff <[email protected]>
  • Loading branch information
MargaretDuff authored Nov 16, 2023
1 parent b7d05fa commit 0418ed2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* x.x.x
- Allow reduction methods on the DataContainer class to accept axis argument as string which matches values in dimension_labels
- Added the functions `set_norms` and `get_norms` to the `BlockOperator` class
- Internal variable name change in BlockOperator to aid understanding

* 23.1.0
- Fix bug in IndicatorBox proximal_conjugate
Expand Down
30 changes: 16 additions & 14 deletions Wrappers/Python/cil/optimisation/operators/BlockOperator.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,18 @@ def direct(self, x, out=None):

tmp = self.range_geometry().allocate()
for row in range(self.shape[0]):
for col in range(self.shape[1]):
if col == 0:
self.get_item(row, col).direct(
x_b.get_item(col),
out=out.get_item(row))
for col in range(self.shape[1]):
if col == 0:
self.get_item(row,col).direct(
x_b.get_item(col),
out=out.get_item(row))
else:
a = out.get_item(row)
self.get_item(row, col).direct(
x_b.get_item(col),
out=tmp.get_item(row))
a += tmp.get_item(row)
temp_out_row = out.get_item(row) # temp_out_row points to the element in out that we are adding to
self.get_item(row,col).direct(
x_b.get_item(col),
out=tmp.get_item(row))
temp_out_row += tmp.get_item(row)


def adjoint(self, x, out=None):
'''Adjoint operation for the BlockOperator
Expand Down Expand Up @@ -282,10 +283,11 @@ def adjoint(self, x, out=None):
out += self.get_item(row, col).adjoint(
x_b.get_item(row))
else:
a = out.get_item(col)
a += self.get_item(row, col).adjoint(
x_b.get_item(row),
)

temp_out_col = out.get_item(col) # out_col_operator points to the column in out that we are updating
temp_out_col += self.get_item(row,col).adjoint(
x_b.get_item(row),
)

def is_linear(self):
'''Returns whether all the elements of the BlockOperator are linear'''
Expand Down

0 comments on commit 0418ed2

Please sign in to comment.