pymor.playground.operators package

Submodules

numpy module


class pymor.playground.operators.numpy.NumpyListVectorArrayMatrixOperator(matrix, source_id=None, range_id=None, solver_options=None, name=None)[source]

Bases: pymor.operators.numpy.NumpyMatrixOperator

Variant of NumpyMatrixOperator using ListVectorArray instead of NumpyVectorArray.

apply(U, mu=None)[source]

Apply the operator to a VectorArray.

Parameters

U
VectorArray of vectors to which the operator is applied.
mu
The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(V, mu=None)[source]

Apply the adjoint operator.

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

op.apply_adjoint(V, mu).dot(U) == V.dot(op.apply(U, mu))

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 for which to apply the adjoint operator.

Returns

VectorArray of the adjoint operator evaluations.

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

Apply the inverse operator.

Parameters

V
VectorArray of vectors to which the inverse operator is applied.
mu
The Parameter for which to evaluate the inverse operator.
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.

check_finite
Test if solution only contains finite values.
default_sparse_solver_backend
Default sparse solver backend to use (scipy, pyamg, generic).

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError
The operator could not be inverted.

Defaults

check_finite, default_sparse_solver_backend (see pymor.core.defaults)

as_range_array(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 every Parameter 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 for which to return the VectorArray representation.

Returns

V
The VectorArray defined above.
as_source_array(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 every Parameter mu a VectorArray V in the operator’s source, such that

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

for all VectorArrays U.

Parameters

mu
The Parameter for which to return the VectorArray representation.

Returns

V
The VectorArray defined above.
assemble_lincomb(operators, coefficients, solver_options=None, name=None)[source]

Try to assemble a linear combination of the given operators.

This method is called in the assemble method of LincombOperator on the first of its operators. If an assembly of the given linear combination is possible, e.g. the linear combination of the system matrices of the operators can be formed, then the assembled operator is returned. Otherwise, the method returns None to indicate that assembly is not possible.

Parameters

operators
List of Operators whose linear combination is formed.
coefficients
List of the corresponding linear coefficients.
solver_options
solver_options for the assembled operator.
name
Name of the assembled operator.

Returns

The assembled Operator if assembly is possible, otherwise None.