pymor.playground.operators package

Submodules

numpy module


class pymor.playground.operators.numpy.NumpyListVectorArrayMatrixOperator(matrix, functional=False, vector=False, solver_options=None, name=None)[source]

Bases: pymor.operators.numpy.NumpyMatrixOperator

Variant of NumpyMatrixOperator using ListVectorArray instead of NumpyVectorArray.

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

Apply the operator to a VectorArray.

Parameters

U
VectorArray of vectors to which the operator is applied.
ind
The indices of the vectors in U to which the operator shall be applied (see the VectorArray documentation for further details).
mu
The Parameter for which to evaluate the operator.

Returns

VectorArray of the operator evaluations.

apply_adjoint(U, ind=None, mu=None, source_product=None, range_product=None)[source]

Apply the adjoint operator.

For a linear operator op the adjoint op^* of op is given by:

(op^*(v), u)_s = (v, op(u))_r,

where ( , )_s and ( , )_r denote the inner products on the source and range space of op. If op and the two products are given by the matrices M, P_s and P_r, then:

op^*(v) = P_s^(-1) * M^T * P_r * v,

with M^T denoting the transposed of M. Thus, if ( , )_s and ( , )_r are the Euclidean inner products, op^*v is simply given by multiplication of the matrix of op with v from the left.

Parameters

U
VectorArray of vectors to which the adjoint operator is applied.
ind
The indices of the vectors in U to which the operator shall be applied (see the VectorArray documentation for further details).
mu
The Parameter for which to apply the adjoint operator.
source_product
The inner product Operator on the source space. If None, the Euclidean product is chosen.
range_product
The inner product Operator on the range space. If None, the Euclidean product is chosen.

Returns

VectorArray of the adjoint operator evaluations.

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

Apply the inverse operator.

Parameters

V
VectorArray of vectors to which the inverse operator is applied.
ind
The indices of the vectors in V to which the inverse operator shall be applied (see VectorArray documentation for further details).
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.

Returns

VectorArray of the inverse operator evaluations.

Raises

InversionError
The operator could not be inverted.
as_vector(mu=None)[source]

Return a vector representation of a linear functional or vector operator.

This method may only be called on linear functionals, i.e. linear Operators with NumpyVectorSpace (1) as range, or on operators describing vectors, i.e. linear Operators with NumpyVectorSpace (1) as source.

In the case of a functional, the identity

self.as_vector(mu).dot(U) == self.apply(U, mu)

holds, whereas in the case of a vector-like operator we have

self.as_vector(mu) == self.apply(NumpyVectorArray(1), mu).

Parameters

mu
The Parameter for which to return the vector representation.

Returns

V
VectorArray of length 1 containing the vector representation. V belongs to self.source for functionals and to self.range for vector-like operators.
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 operator. 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.