r"""Initialize the `LinearOperator`. **This is a private method for subclass use.** **Subclasses should copy-paste this `__init__` documentation.** Args: dtype: The type of the this `LinearOperator`. Arguments to `matmul` and `solve` will have to be this type. grap
(self,
dtype,
graph_parents=None,
is_non_singular=None,
is_self_adjoint=None,
is_positive_definite=None,
is_square=None,
name=None)
| 148 | """ |
| 149 | |
| 150 | def __init__(self, |
| 151 | dtype, |
| 152 | graph_parents=None, |
| 153 | is_non_singular=None, |
| 154 | is_self_adjoint=None, |
| 155 | is_positive_definite=None, |
| 156 | is_square=None, |
| 157 | name=None): |
| 158 | r"""Initialize the `LinearOperator`. |
| 159 | |
| 160 | **This is a private method for subclass use.** |
| 161 | **Subclasses should copy-paste this `__init__` documentation.** |
| 162 | |
| 163 | Args: |
| 164 | dtype: The type of the this `LinearOperator`. Arguments to `matmul` and |
| 165 | `solve` will have to be this type. |
| 166 | graph_parents: Python list of graph prerequisites of this `LinearOperator` |
| 167 | Typically tensors that are passed during initialization. |
| 168 | is_non_singular: Expect that this operator is non-singular. |
| 169 | is_self_adjoint: Expect that this operator is equal to its hermitian |
| 170 | transpose. If `dtype` is real, this is equivalent to being symmetric. |
| 171 | is_positive_definite: Expect that this operator is positive definite, |
| 172 | meaning the quadratic form `x^H A x` has positive real part for all |
| 173 | nonzero `x`. Note that we do not require the operator to be |
| 174 | self-adjoint to be positive-definite. See: |
| 175 | https://en.wikipedia.org/wiki/Positive-definite_matrix#Extension_for_non-symmetric_matrices |
| 176 | is_square: Expect that this operator acts like square [batch] matrices. |
| 177 | name: A name for this `LinearOperator`. |
| 178 | |
| 179 | Raises: |
| 180 | ValueError: If any member of graph_parents is `None` or not a `Tensor`. |
| 181 | ValueError: If hints are set incorrectly. |
| 182 | """ |
| 183 | # Check and auto-set flags. |
| 184 | if is_positive_definite: |
| 185 | if is_non_singular is False: |
| 186 | raise ValueError("A positive definite matrix is always non-singular.") |
| 187 | is_non_singular = True |
| 188 | |
| 189 | if is_non_singular: |
| 190 | if is_square is False: |
| 191 | raise ValueError("A non-singular matrix is always square.") |
| 192 | is_square = True |
| 193 | |
| 194 | if is_self_adjoint: |
| 195 | if is_square is False: |
| 196 | raise ValueError("A self-adjoint matrix is always square.") |
| 197 | is_square = True |
| 198 | |
| 199 | self._is_square_set_or_implied_by_hints = is_square |
| 200 | |
| 201 | graph_parents = [] if graph_parents is None else graph_parents |
| 202 | for i, t in enumerate(graph_parents): |
| 203 | if t is None or not (linear_operator_util.is_ref(t) or |
| 204 | tensor_util.is_tensor(t)): |
| 205 | raise ValueError("Graph parent item %d is not a Tensor; %s." % (i, t)) |
| 206 | self._dtype = dtypes.as_dtype(dtype).base_dtype if dtype else dtype |
| 207 | self._graph_parents = graph_parents |