mrpro.operators.LinearOperatorMatrix

class mrpro.operators.LinearOperatorMatrix[source]

Bases: Operator[Unpack[tuple[Tensor, …]], tuple[Tensor, …]]

Matrix of linear operators.

A matrix of linear operators, where each element is a LinearOperator.

This matrix can be applied to a sequence of tensors, where the number of tensors should match the number of columns of the matrix. The output will be a sequence of tensors, where the number of tensors will match the number of rows of the matrix. The i-th output tensor is calculated as \(\sum_j \text{operators}[i][j](x[j])\) where \(\text{operators}[i][j]\) is the linear operator in the i-th row and j-th column and \(x[j]\) is the j-th input tensor.

The matrix can be indexed and sliced like a regular matrix to get submatrices. If indexing returns a single element, it is returned as a LinearOperator.

Basic arithmetic operations are supported with LinearOperator and Tensors.

__init__(operators: Sequence[Sequence[LinearOperator]])[source]

Initialize Linear Operator Matrix.

Create a matrix of LinearOperator from a sequence of rows, where each row is a sequence of LinearOperator that represent the columns of the matrix.

Parameters:

operators (Sequence[Sequence[LinearOperator]]) – A sequence of rows, which are sequences of LinearOperator.

classmethod from_diagonal(*operators: LinearOperator)[source]

Create a diagonal LinearOperatorMatrix.

Construct a square LinearOperatorMatrix with the given linear operators on the diagonal, resulting in a block-diagonal linear operator.

Parameters:

operators (LinearOperator) – Sequence of LinearOperator to be placed on the diagonal.

property H: Self[source]

Adjoints of the operators.

property shape: tuple[int, int][source]

Shape of the Operator Matrix (rows, columns).

__call__(*args: Unpack) Tout[source]

Apply the forward operator.

For more information, see forward.

Note

Prefer using operator_instance(*parameters), i.e. using __call__ over using forward.

adjoint(*x: Tensor) tuple[Tensor, ...][source]

Apply the adjoint of the operator to the input.

Parameters:

x (Tensor) – Input tensors. Requires the same number of tensors as the operator has rows.

Returns:

Output tensors. The same number of tensors as the operator has columns.

forward(*x: Tensor) tuple[Tensor, ...][source]

Apply the operator to the input.

Parameters:

x (Tensor) – Input tensors. Requires the same number of tensors as the operator has columns.

Returns:

Output tensors. The same number of tensors as the operator has rows.

operator_norm(*initial_value: Tensor, dim: Sequence[int] | None = None, max_iterations: int = 20, relative_tolerance: float = 1e-4, absolute_tolerance: float = 1e-5, callback: Callable[[Tensor], None] | None = None) Tensor[source]

Upper bound of operator norm of the Matrix.

Uses the bounds \(||[A, B]^T|||<=sqrt(||A||^2 + ||B||^2)\) and \(||[A, B]|||<=max(||A||,||B||)\) to estimate the operator norm of the matrix. First, operator_norm is called on each element of the matrix. Next, the norm is estimated for each column using the first bound. Finally, the norm of the full matrix of linear operators is calculated using the second bound.

Parameters:
  • initial_value (Tensor) – Initial value(s) for the power iteration, length should match the number of columns of the operator matrix.

  • dim (Sequence[int] | None, default: None) – Dimensions to calculate the operator norm over. Other dimensions are assumed to be batch dimensions. None means all dimensions.

  • max_iterations (int, default: 20) – Maximum number of iterations used in the power iteration.

  • relative_tolerance (float, default: 1e-4) – Relative tolerance for convergence.

  • absolute_tolerance (float, default: 1e-5) – Absolute tolerance for convergence.

  • callback (Callable[[Tensor], None] | None, default: None) – Callback function to be called with the current estimate of the operator norm.

Returns:

Estimated operator norm upper bound.

__add__(other: Self | LinearOperator | Tensor) Self[source]

Addition.

__and__(other: LinearOperator | LinearOperatorMatrix) Self[source]

Horizontal stacking.

__matmul__(other: LinearOperator | Self) Self[source]

Composition of operators.

__mul__(other: Tensor | Sequence[Tensor | complex] | complex) Self[source]

LinearOperatorMatrix*Tensor multiplication.

Example: ([A,B]*c)(x) = [A*c, B*c](x) = A(c*x) + B(c*x)

__or__(other: LinearOperator | LinearOperatorMatrix) Self[source]

Vertical stacking.

__radd__(other: Self | LinearOperator | Tensor) Self[source]

Right addition.

__rand__(other: LinearOperator) Self[source]

Horizontal stacking.

__rmatmul__(other: LinearOperator) Self[source]

Composition of operators.

__rmul__(other: Tensor | Sequence[Tensor] | complex) Self[source]

Tensor*LinearOperatorMatrix multiplication.

Example: (c*[A,B])(x) = [c*A, c*B](x) = c*A(x) + c*B(x)

__ror__(other: LinearOperator) Self[source]

Vertical stacking.