Example #1
0
def _inverse_linear_operator(linop):
  return linear_operator_inversion.LinearOperatorInversion(
      linop,
      is_non_singular=linop.is_non_singular,
      is_self_adjoint=linop.is_self_adjoint,
      is_positive_definite=linop.is_positive_definite,
      is_square=linop.is_square)
def _solve_linear_operator(linop_a, linop_b):
    """Generic solve of two `LinearOperator`s."""
    is_square = registrations_util.is_square(linop_a, linop_b)
    is_non_singular = None
    is_self_adjoint = None
    is_positive_definite = None

    if is_square:
        is_non_singular = registrations_util.combined_non_singular_hint(
            linop_a, linop_b)
    elif is_square is False:  # pylint:disable=g-bool-id-comparison
        is_non_singular = False
        is_self_adjoint = False
        is_positive_definite = False

    return linear_operator_composition.LinearOperatorComposition(
        operators=[
            linear_operator_inversion.LinearOperatorInversion(linop_a), linop_b
        ],
        is_non_singular=is_non_singular,
        is_self_adjoint=is_self_adjoint,
        is_positive_definite=is_positive_definite,
        is_square=is_square,
    )