Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add symmetric flag to PowerMethod #1470

Merged
merged 21 commits into from
Sep 28, 2023
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions Wrappers/Python/cil/optimisation/operators/Operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@ def adjoint(self,x, out=None):
raise NotImplementedError

@staticmethod
def PowerMethod(operator, max_iteration=10, initial=None, tolerance = 1e-5, return_all=False):
def PowerMethod(operator, max_iteration=10, initial=None, tolerance=1e-5, return_all=False, symmetric=False):

r"""Power method or Power iteration algorithm

The Power method computes the largest (dominant) eigenvalue of a square matrix in magnitude, e.g.,
absolute value in the real case and module in the complex case.
For the non-square case, the power method is applied for the matrix :math: A^{T}*A.
Since we cannot estimate if the operator is diagonisable, the power method is applied on the diagonizable operator
:math:`A^{T}*A`.

If the operator :math:`A` is diagonizable, the user can pass the flag `symmetric=True`.
MargaretDuff marked this conversation as resolved.
Show resolved Hide resolved
MargaretDuff marked this conversation as resolved.
Show resolved Hide resolved

Parameters
----------
Expand All @@ -161,6 +164,8 @@ def PowerMethod(operator, max_iteration=10, initial=None, tolerance = 1e-5, ret
Stopping criterion for the Power method. Check if two consecutive eigenvalue evaluations are below the tolerance.
return_all: boolean, default = False
Toggles the verbosity of the return
symmetric: boolean, default False
Set this to True if the operator is symmetric


Returns
Expand Down Expand Up @@ -188,16 +193,6 @@ def PowerMethod(operator, max_iteration=10, initial=None, tolerance = 1e-5, ret
2.0005647295658866

"""

# Default case: non-symmetric
symmetric = False
try:
if operator.domain_geometry()==operator.range_geometry():
symmetric = True
except AssertionError:
# catch AssertionError for SIRF objects https://github.com/SyneRBI/SIRF-SuperBuild/runs/5110228626?check_suite_focus=true#step:8:972
pass

if initial is None:
x0 = operator.domain_geometry().allocate('random')
else:
Expand Down