# pymor.operators.block¶

## Module Contents¶

### Classes¶

 BlockOperatorBase Interface for Parameter dependent discrete operators. BlockOperator A matrix of arbitrary Operators. BlockRowOperator A row vector of arbitrary Operators. BlockColumnOperator A column vector of arbitrary Operators. BlockProjectionOperator A row vector of arbitrary Operators. BlockEmbeddingOperator A column vector of arbitrary Operators. BlockDiagonalOperator Block diagonal Operator of arbitrary Operators. SecondOrderModelOperator BlockOperator appearing in SecondOrderModel.to_lti().
class pymor.operators.block.BlockOperatorBase(blocks)[source]

Interface for Parameter dependent discrete operators.

An operator in pyMOR is simply a mapping which for any given parameter values maps vectors from its source VectorSpace to vectors in its range VectorSpace.

Note that there is no special distinction between functionals and operators in pyMOR. A functional is simply an operator with NumpyVectorSpace (1) as its range VectorSpace.

solver_options[source]

If not None, a dict which can contain the following keys:

‘inverse’

solver options used for apply_inverse

‘jacobian’

solver options for the operators returned by jacobian (has no effect for linear operators)

If solver_options is None or a dict entry is missing or None, default options are used. The interpretation of the given solver options is up to the operator at hand. In general, values in solver_options should either be strings (indicating a solver type) or dicts of options, usually with an entry 'type' which specifies the solver type to use and further items which configure this solver.

linear[source]

True if the operator is linear.

source[source]

The source VectorSpace.

range[source]

The range VectorSpace.

H[source]

for all V, mu.

_operators(self)[source]

Iterator over operators.

apply(self, U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The parameter values for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

For any given linear Operator op, parameter values mu and VectorArrays U, V in the source resp. range we have:

Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The parameter values for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

assemble(self, mu=None)[source]

Assemble the operator for given parameter values.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The parameter values for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

as_range_array(self, mu=None)[source]

Return a VectorArray representation of the operator in its range space.

In the case of a linear operator with NumpyVectorSpace as source, this method returns for given parameter values mu a VectorArray V in the operator’s range, such that

V.lincomb(U.to_numpy()) == self.apply(U, mu)

for all VectorArrays U.

Parameters

mu

The parameter values for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

as_source_array(self, mu=None)[source]

Return a VectorArray representation of the operator in its source space.

In the case of a linear operator with NumpyVectorSpace as range, this method returns for given parameter values mu a VectorArray V in the operator’s source, such that

self.range.make_array(V.inner(U).T) == self.apply(U, mu)

for all VectorArrays U.

Parameters

mu

The parameter values for which to return the VectorArray representation.

Returns

V

The VectorArray defined above.

d_mu(self, parameter, index=0)[source]

Return the operator’s derivative with respect to a given parameter.

Parameters

parameter

The parameter w.r.t. which to return the derivative.

index

Index of the parameter’s component w.r.t which to return the derivative.

Returns

New Operator representing the partial derivative.

class pymor.operators.block.BlockOperator(blocks)[source]

Bases: BlockOperatorBase

A matrix of arbitrary Operators.

This operator can be applied to a compatible BlockVectorArrays.

Parameters

blocks

Two-dimensional array-like where each entry is an Operator or None.

blocked_source = True[source]
blocked_range = True[source]
class pymor.operators.block.BlockRowOperator(blocks)[source]

Bases: BlockOperatorBase

A row vector of arbitrary Operators.

blocked_source = True[source]
blocked_range = False[source]
class pymor.operators.block.BlockColumnOperator(blocks)[source]

Bases: BlockOperatorBase

A column vector of arbitrary Operators.

blocked_source = False[source]
blocked_range = True[source]
class pymor.operators.block.BlockProjectionOperator(block_space, component)[source]

Bases: BlockRowOperator

A row vector of arbitrary Operators.

class pymor.operators.block.BlockEmbeddingOperator(block_space, component)[source]

Bases: BlockColumnOperator

A column vector of arbitrary Operators.

class pymor.operators.block.BlockDiagonalOperator(blocks)[source]

Bases: BlockOperator

Block diagonal Operator of arbitrary Operators.

This is a specialization of BlockOperator for the block diagonal case.

apply(self, U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The parameter values for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

For any given linear Operator op, parameter values mu and VectorArrays U, V in the source resp. range we have:

Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The parameter values for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(self, V, mu=None, initial_guess=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The parameter values for which to evaluate the inverse operator.

initial_guess

VectorArray with the same length as V containing initial guesses for the solution. Some implementations of apply_inverse may ignore this parameter. If None a solver-dependent default is used.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.

Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The parameter values for which to evaluate the inverse adjoint operator.

initial_guess

VectorArray with the same length as U containing initial guesses for the solution. Some implementations of apply_inverse_adjoint may ignore this parameter. If None a solver-dependent default is used.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.

Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

assemble(self, mu=None)[source]

Assemble the operator for given parameter values.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The parameter values for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.

class pymor.operators.block.SecondOrderModelOperator(alpha, beta, A, B)[source]

Bases: BlockOperator

BlockOperator appearing in SecondOrderModel.to_lti().

This represents a block operator

$\begin{split}\mathcal{A} = \begin{bmatrix} \alpha I & \beta I \\ B & A \end{bmatrix},\end{split}$

which satisfies

$\begin{split}\mathcal{A}^H &= \begin{bmatrix} \overline{\alpha} I & B^H \\ \overline{\beta} I & A^H \end{bmatrix}, \\ \mathcal{A}^{-1} &= \begin{bmatrix} (\alpha A - \beta B)^{-1} A & -\beta (\alpha A - \beta B)^{-1} \\ -(\alpha A - \beta B)^{-1} B & \alpha (\alpha A - \beta B)^{-1} \end{bmatrix}, \\ \mathcal{A}^{-H} &= \begin{bmatrix} A^H (\alpha A - \beta B)^{-H} & -B^H (\alpha A - \beta B)^{-H} \\ -\overline{\beta} (\alpha A - \beta B)^{-H} & \overline{\alpha} (\alpha A - \beta B)^{-H} \end{bmatrix}.\end{split}$

Parameters

alpha

Scalar.

beta

Scalar.

A
B
apply(self, U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U

VectorArray of vectors to which the operator is applied.

mu

The parameter values for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

For any given linear Operator op, parameter values mu and VectorArrays U, V in the source resp. range we have:

Thus, when op is represented by a matrix M, apply_adjoint is given by left-multplication of (the complex conjugate of) M with V.

Parameters

V

VectorArray of vectors to which the adjoint operator is applied.

mu

The parameter values for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

apply_inverse(self, V, mu=None, initial_guess=None, least_squares=False)[source]

Apply the inverse operator.

Parameters

V

VectorArray of vectors to which the inverse operator is applied.

mu

The parameter values for which to evaluate the inverse operator.

initial_guess

VectorArray with the same length as V containing initial guesses for the solution. Some implementations of apply_inverse may ignore this parameter. If None a solver-dependent default is used.

least_squares

If True, solve the least squares problem:

u = argmin ||op(u) - v||_2.

Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError

The operator could not be inverted.

Parameters

U

VectorArray of vectors to which the inverse adjoint operator is applied.

mu

The parameter values for which to evaluate the inverse adjoint operator.

initial_guess

VectorArray with the same length as U containing initial guesses for the solution. Some implementations of apply_inverse_adjoint may ignore this parameter. If None a solver-dependent default is used.

least_squares

If True, solve the least squares problem:

v = argmin ||op^*(v) - u||_2.

Since for an invertible operator the least squares solution agrees with the result of the application of the inverse operator, setting this option should, in general, have no effect on the result for those operators. However, note that when no appropriate solver_options are set for the operator, most operator implementations will choose a least squares solver by default which may be undesirable.

Returns

VectorArray of the inverse adjoint operator evaluations.

Raises

InversionError

The operator could not be inverted.

assemble(self, mu=None)[source]

Assemble the operator for given parameter values.

The result of the method strongly depends on the given operator. For instance, a matrix-based operator will assemble its matrix, a LincombOperator will try to form the linear combination of its operators, whereas an arbitrary operator might simply return a FixedParameterOperator. The only assured property of the assembled operator is that it no longer depends on a Parameter.

Parameters

mu

The parameter values for which to assemble the operator.

Returns

Parameter-independent, assembled Operator.