pymor.operators.constructions
¶
Module containing some constructions to obtain new operators from old ones.
Module Contents¶
Classes¶
Linear combination of arbitrary 

Generic 

Nonparametric lowrank operator. 





The identity 

A constant 

The 

Wraps a 

Wrap a vector as a vectorlike 

Wrap a vector as a linear 

Forwards all interface calls to given 

Makes an 

Mark the wrapped 

Decompose an affine 

Represents the inverse of a given 

Represents the inverse adjoint of a given 

Represents the adjoint of a given linear 

Instantiated by 

Converts 
Functions¶
Obtain induced norm of an inner product. 
 class pymor.operators.constructions.LincombOperator(operators, coefficients, solver_options=None, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Linear combination of arbitrary
Operators
.This
Operator
represents a (possiblyParameter
dependent) linear combination of a given list ofOperators
.Parameters
 operators
List of
Operators
whose linear combination is formed. coefficients
A list of linear coefficients. A linear coefficient can either be a fixed number or a
ParameterFunctional
. solver_options
The
solver_options
for the operator. name
Name of the operator.
 evaluate_coefficients(self, mu)[source]¶
Compute the linear coefficients for given
parameter values
.Parameters
 mu
Parameter values
for which to compute the linear coefficients.
Returns
List of linear coefficients.
 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.
 apply2(self, V, U, mu=None)[source]¶
Treat the operator as a 2form and apply it to V and U.
This method is usually implemented as
V.inner(self.apply(U))
. In particular, if the operator is a linear operator given by multiplication with a matrix M, thenapply2
is given as:op.apply2(V, U) = V^T*M*U.
In the case of complex numbers, note that
apply2
is antilinear in the first variable by definition ofinner
.Parameters
 V
VectorArray
of the left arguments V. U
VectorArray
of the right arguments U. mu
The
parameter values
for which to evaluate the operator.
Returns
A
NumPy array
with shape(len(V), len(U))
containing the 2form evaluations.
 pairwise_apply2(self, V, U, mu=None)[source]¶
Treat the operator as a 2form and apply it to V and U in pairs.
This method is usually implemented as
V.pairwise_inner(self.apply(U))
. In particular, if the operator is a linear operator given by multiplication with a matrix M, thenapply2
is given as:op.apply2(V, U)[i] = V[i]^T*M*U[i].
In the case of complex numbers, note that
pairwise_apply2
is antilinear in the first variable by definition ofpairwise_inner
.Parameters
 V
VectorArray
of the left arguments V. U
VectorArray
of the right arguments U. mu
The
parameter values
for which to evaluate the operator.
Returns
A
NumPy array
with shape(len(V),) == (len(U),)
containing the 2form evaluations.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 matrixbased operator will assemble its matrix, a
LincombOperator
will try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator
. The only assured property of the assembled operator is that it no longer depends on aParameter
.Parameters
 mu
The
parameter values
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.
 jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 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.
 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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 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
assource
, this method returns for givenparameter values
mu
aVectorArray
V
in the operator’srange
, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArrays
U
.Parameters
 mu
The
parameter values
for which to return theVectorArray
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
asrange
, this method returns for givenparameter values
mu
aVectorArray
V
in the operator’ssource
, such thatself.range.make_array(V.inner(U).T) == self.apply(U, mu)
for all
VectorArrays
U
.Parameters
 mu
The
parameter values
for which to return theVectorArray
representation.
Returns
 V
The
VectorArray
defined above.
 class pymor.operators.constructions.ConcatenationOperator(operators, solver_options=None, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Operator
representing the concatenation of twoOperators
.Parameters
 operators
Tuple of
Operators
to concatenate.operators[1]
is the first applied operator,operators[0]
is the last applied operator. solver_options
The
solver_options
for the operator. name
Name of the operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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.
 jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 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.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 class pymor.operators.constructions.ProjectedOperator(operator, range_basis, source_basis, product=None, solver_options=None)[source]¶
Bases:
pymor.operators.interface.Operator
Generic
Operator
representing the projection of anOperator
to a subspace.This operator is implemented as the concatenation of the linear combination with
source_basis
, application of the originaloperator
and projection ontorange_basis
. As such, this operator can be used to obtain a reduced basis projection of any givenOperator
. However, no offline/online decomposition is performed, so this operator is mainly useful for testing before implementing offline/online decomposition for a specific application.This operator is instantiated in
pymor.algorithms.projection.project
as a default implementation for parametric or nonlinear operators.Parameters
 operator
The
Operator
to project. range_basis
 source_basis
 product
 solver_options
The
solver_options
for the projected operator.
 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.
 jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 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 matrixbased operator will assemble its matrix, a
LincombOperator
will try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator
. The only assured property of the assembled operator is that it no longer depends on aParameter
.Parameters
 mu
The
parameter values
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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.
 class pymor.operators.constructions.LowRankOperator(left, core, right, inverted=False, solver_options=None, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Nonparametric lowrank operator.
Represents an operator of the form \(L C R^H\) or \(L C^{1} R^H\) where \(L\) and \(R\) are
VectorArrays
of column vectors and \(C\) a 2DNumPy array
.Parameters
 left
VectorArray
representing \(L\). core
NumPy array
representing \(C\). right
VectorArray
representing \(R\). inverted
Whether \(C\) is inverted.
 solver_options
The
solver_options
for the operator. name
Name of the operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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.
 class pymor.operators.constructions.LowRankUpdatedOperator(operator, lr_operator, coeff, lr_coeff, solver_options=None, name=None)[source]¶
Bases:
LincombOperator
Operator
plusLowRankOperator
.Represents a linear combination of an
Operator
andLowRankOperator
. Uses the ShermanMorrisonWoodbury formula inapply_inverse
andapply_inverse_adjoint
:\[\begin{split}\left(\alpha A + \beta L C R^H \right)^{1} & = \alpha^{1} A^{1}  \alpha^{1} \beta A^{1} L C \left(\alpha C + \beta C R^H A^{1} L C \right)^{1} C R^H A^{1}, \\ \left(\alpha A + \beta L C^{1} R^H \right)^{1} & = \alpha^{1} A^{1}  \alpha^{1} \beta A^{1} L \left(\alpha C + \beta R^H A^{1} L \right)^{1} R^H A^{1}.\end{split}\]Parameters
 operator
 lr_operator
 coeff
A linear coefficient for
operator
. Can either be a fixed number or aParameterFunctional
. lr_coeff
A linear coefficient for
lr_operator
. Can either be a fixed number or aParameterFunctional
. solver_options
The
solver_options
for the operator. name
Name of the operator.
 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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 class pymor.operators.constructions.ComponentProjectionOperator(components, source, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Operator
representing the projection of aVectorArray
onto some of its components.Parameters
 components
List or 1D
NumPy array
of the indices of the vectorcomponents
that are to be extracted by the operator. source
Source
VectorSpace
of the operator. name
Name of the operator.
 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.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 class pymor.operators.constructions.IdentityOperator(space, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
The identity
Operator
.In other words:
op.apply(U) == U
Parameters
 space
The
VectorSpace
the operator acts on. name
Name of the operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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 matrixbased operator will assemble its matrix, a
LincombOperator
will try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator
. The only assured property of the assembled operator is that it no longer depends on aParameter
.Parameters
 mu
The
parameter values
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 class pymor.operators.constructions.ConstantOperator(value, source, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
A constant
Operator
always returning the same vector.Parameters
 value
A
VectorArray
of length 1 containing the vector which is returned by the operator. source
Source
VectorSpace
of the operator. name
Name of the operator.
 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.
 jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 class pymor.operators.constructions.ZeroOperator(range, source, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
The
Operator
which maps every vector to zero.Parameters
 range
Range
VectorSpace
of the operator. source
Source
VectorSpace
of the operator. name
Name of the operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 class pymor.operators.constructions.VectorArrayOperator(array, adjoint=False, space_id=None, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Wraps a
VectorArray
as anOperator
.If
adjoint
isFalse
, the operator maps fromNumpyVectorSpace(len(array))
toarray.space
by forming linear combinations of the vectors in the array with given coefficient arrays.If
adjoint == True
, the operator maps fromarray.space
toNumpyVectorSpace(len(array))
by forming the inner products of the argument with the vectors in the given array.Parameters
 array
The
VectorArray
which is to be treated as an operator. adjoint
See description above.
 space_id
Id of the
source
(range
)VectorSpace
in caseadjoint
isFalse
(True
). name
The name of the operator.
 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.
 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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 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
assource
, this method returns for givenparameter values
mu
aVectorArray
V
in the operator’srange
, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArrays
U
.Parameters
 mu
The
parameter values
for which to return theVectorArray
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
asrange
, this method returns for givenparameter values
mu
aVectorArray
V
in the operator’ssource
, such thatself.range.make_array(V.inner(U).T) == self.apply(U, mu)
for all
VectorArrays
U
.Parameters
 mu
The
parameter values
for which to return theVectorArray
representation.
Returns
 V
The
VectorArray
defined above.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 class pymor.operators.constructions.VectorOperator(vector, name=None)[source]¶
Bases:
VectorArrayOperator
Wrap a vector as a vectorlike
Operator
.Given a vector
v
of dimensiond
, this class represents the operatorop: R^1 > R^d x > x⋅v
In particular:
VectorOperator(vector).as_range_array() == vector
Parameters
 vector
VectorArray
of length 1 containing the vectorv
. name
Name of the operator.
 class pymor.operators.constructions.VectorFunctional(vector, product=None, name=None)[source]¶
Bases:
VectorArrayOperator
Wrap a vector as a linear
Functional
.Given a vector
v
of dimensiond
, this class represents the functionalf: R^d > R^1 u > (u, v)
where
( , )
denotes the inner product given byproduct
.In particular, if
product
isNone
VectorFunctional(vector).as_source_array() == vector.
If
product
is not none, we obtainVectorFunctional(vector).as_source_array() == product.apply(vector).
Parameters
 vector
VectorArray
of length 1 containing the vectorv
. product
Operator
representing the scalar product to use. name
Name of the operator.
 class pymor.operators.constructions.ProxyOperator(operator, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Forwards all interface calls to given
Operator
.Mainly useful as base class for other
Operator
implementations.Parameters
 operator
The
Operator
to wrap. name
Name of the wrapping operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 restricted(self, dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_op
of the operator along with an arraysource_dofs
such that for anyVectorArray
U
inself.source
the following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(NumpyVectorArray(U.dofs(source_dofs)), mu))
Such an operator is mainly useful for
empirical interpolation
where the evaluation of the original operator only needs to be known for few selected degrees of freedom. If the operator has a small stencil, only fewsource_dofs
will be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.Parameters
 dofs
Onedimensional
NumPy array
of degrees of freedom in the operatorrange
to which to restrict.
Returns
 restricted_op
The restricted operator as defined above. The operator will have
NumpyVectorSpace
(len(source_dofs))
assource
andNumpyVectorSpace
(len(dofs))
asrange
. source_dofs
Onedimensional
NumPy array
of source degrees of freedom as defined above.
 class pymor.operators.constructions.FixedParameterOperator(operator, mu=None, name=None)[source]¶
Bases:
ProxyOperator
Makes an
Operator
Parameter
independent by setting fixedparameter values
.Parameters
 operator
The
Operator
to wrap. mu
The fixed
parameter values
that will be fed to theapply
method (and related methods) ofoperator
.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 class pymor.operators.constructions.LinearOperator(operator, name=None)[source]¶
Bases:
ProxyOperator
Mark the wrapped
Operator
to be linear.
 class pymor.operators.constructions.AffineOperator(operator, name=None)[source]¶
Bases:
ProxyOperator
Decompose an affine
Operator
into affine_shift and linear_part. jacobian(self, U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator
.Parameters
 U
Length 1
VectorArray
containing the vector for which to compute the Jacobian. mu
The
parameter values
for which to compute the Jacobian.
Returns
Linear
Operator
representing the Jacobian.
 class pymor.operators.constructions.InverseOperator(operator, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Represents the inverse of a given
Operator
.Parameters
 operator
The
Operator
of which the inverse is formed. name
If not
None
, name of the operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 class pymor.operators.constructions.InverseAdjointOperator(operator, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
Represents the inverse adjoint of a given
Operator
.Parameters
 operator
The
Operator
of which the inverse adjoint is formed. name
If not
None
, name of the operator.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 class pymor.operators.constructions.AdjointOperator(operator, source_product=None, range_product=None, name=None, with_apply_inverse=True, solver_options=None)[source]¶
Bases:
pymor.operators.interface.Operator
Represents the adjoint of a given linear
Operator
.For a linear
Operator
op
the adjointop^*
ofop
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 ofop
. If two products are given byP_s
andP_r
, then:op^*(v) = P_s^(1) o op.H o P_r,
Thus, if
( , )_s
and( , )_r
are the Euclidean inner products,op^*v
is simply given by application of the :attr:adjoint <pymor.operators.interface.Operator.H>`Operator
.Parameters
 operator
The
Operator
of which the adjoint is formed. source_product
If not
None
, inner productOperator
for the sourceVectorSpace
w.r.t. which to take the adjoint. range_product
If not
None
, inner productOperator
for the rangeVectorSpace
w.r.t. which to take the adjoint. name
If not
None
, name of the operator. with_apply_inverse
If
True
, provide ownapply_inverse
andapply_inverse_adjoint
implementations by calling these methods on the givenoperator
. (Is set toFalse
in the default implementation of andapply_inverse_adjoint
.) solver_options
When
with_apply_inverse
isFalse
, thesolver_options
to use for theapply_inverse
default implementation.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_inverse_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.
 class pymor.operators.constructions.SelectionOperator(operators, parameter_functional, boundaries, name=None)[source]¶
Bases:
pymor.operators.interface.Operator
An
Operator
selected from a list ofOperators
.operators[i]
is used ifparameter_functional(mu)
is less or equal thanboundaries[i]
and greater thanboundaries[i1]
:infty  boundaries[i]  boundaries[i+1]  infty    operators[i]  operators[i+1]  operators[i+2]  
Parameters
 operators
List of
Operators
from which oneOperator
is selected based on the givenparameter values
. parameter_functional
The
ParameterFunctional
used for the selection of oneOperator
. boundaries
The interval boundaries as defined above.
 name
Name of the operator.
 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 matrixbased operator will assemble its matrix, a
LincombOperator
will try to form the linear combination of its operators, whereas an arbitrary operator might simply return aFixedParameterOperator
. The only assured property of the assembled operator is that it no longer depends on aParameter
.Parameters
 mu
The
parameter values
for which to assemble the operator.
Returns
Parameterindependent, assembled
Operator
.
 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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.
 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
assource
, this method returns for givenparameter values
mu
aVectorArray
V
in the operator’srange
, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArrays
U
.Parameters
 mu
The
parameter values
for which to return theVectorArray
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
asrange
, this method returns for givenparameter values
mu
aVectorArray
V
in the operator’ssource
, such thatself.range.make_array(V.inner(U).T) == self.apply(U, mu)
for all
VectorArrays
U
.Parameters
 mu
The
parameter values
for which to return theVectorArray
representation.
Returns
 V
The
VectorArray
defined above.
 pymor.operators.constructions.induced_norm(product, raise_negative=True, tol=1e10, name=None)[source]¶
Obtain induced norm of an inner product.
The norm of the vectors in a
VectorArray
U is calculated by callingproduct.pairwise_apply2(U, U, mu=mu).
In addition, negative norm squares of absolute value smaller than
tol
are clipped to0
. Ifraise_negative
isTrue
, aValueError
exception is raised if there are negative norm squares of absolute value larger thantol
.Parameters
 product
The inner product
Operator
for which the norm is to be calculated. raise_negative
If
True
, raise an exception if calculated norm is negative. tol
See above.
 name
optional, if None product’s name is used
Returns
 norm
A function
norm(U, mu=None)
taking aVectorArray
U
as input together with theparameter values
mu
which are passed to the product.
 class pymor.operators.constructions.InducedNorm(product, raise_negative, tol, name)[source]¶
Bases:
pymor.parameters.base.ParametricObject
Instantiated by
induced_norm
. Do not use directly.
 class pymor.operators.constructions.NumpyConversionOperator(space, direction='to_numpy')[source]¶
Bases:
pymor.operators.interface.Operator
Converts
VectorArrays
toNumpyVectorArrays
.Note that the input
VectorArrays
need to supportto_numpy
. For the adjoint,from_numpy
needs to be implemented.Parameters
 space
The
VectorSpace
of theVectorArrays
that are converted toNumpyVectorArrays
. direction
Either
'to_numpy'
or'from_numpy'
. In case of'to_numpy'
apply
takes aVectorArray
fromspace
and returns aNumpyVectorArray
. In case of'from_numpy'
,apply
takes aNumpyVectorArray
and returns aVectorArray
fromspace
.
 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.
 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 asV
containing initial guesses for the solution. Some implementations ofapply_inverse
may ignore this parameter. IfNone
a solverdependent 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.
 apply_adjoint(self, V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operator
op
,parameter values
mu
andVectorArrays
U
,V
in thesource
resp.range
we have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
op
is represented by a matrixM
,apply_adjoint
is given by leftmultplication of (the complex conjugate of)M
withV
.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_adjoint(self, U, mu=None, initial_guess=None, least_squares=False)[source]¶
Apply the inverse adjoint operator.
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 asU
containing initial guesses for the solution. Some implementations ofapply_inverse_adjoint
may ignore this parameter. IfNone
a solverdependent 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.