pymor.operators.constructions¶
Module containing some constructions to obtain new operators from old ones.
Module Contents¶
- class pymor.operators.constructions.AdjointOperator(operator, source_product=None, range_product=None, with_apply_inverse=True, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorRepresents the adjoint of a given linear
Operator.For a linear
Operatoropthe adjointop^*ofopis given by:(op^*(v), u)_s = (v, op(u))_r,
where
( , )_sand( , )_rdenote the inner products on the source and range space ofop. If two products are given byP_sandP_r, then:op^*(v) = P_s^(-1) o op.H o P_r,
Thus, if
( , )_sand( , )_rare the Euclidean inner products,op^*vis simply given by application of the :attr:adjoint <pymor.operators.interface.Operator.H>`Operator.- Parameters:
operator – The
Operatorof which the adjoint is formed.source_product – If not
None, inner productOperatorfor the sourceVectorSpacew.r.t. which to take the adjoint.range_product – If not
None, inner productOperatorfor the rangeVectorSpacew.r.t. which to take the adjoint.with_apply_inverse – If
True, provide ownapply_inverseandapply_inverse_adjointimplementations by calling these methods on the givenoperator. (Is set toFalsein the default implementation of andapply_inverse_adjoint.)solver – The
Solverfor the operator.name – If not
None, name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- class pymor.operators.constructions.AffineOperator(operator, solver=None, name=None)[source]¶
Bases:
ProxyOperatorDecompose an affine
Operatorinto affine_shift and linear_part.- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- class pymor.operators.constructions.ComponentProjectionOperator(components, source, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorOperatorrepresenting the projection of aVectorArrayonto some of its components.- Parameters:
components – List or 1D
NumPy arrayof the indices of the vectordofsthat are to be extracted by the operator.source – Source
VectorSpaceof the operator.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.operators.constructions.ConcatenationOperator(operators, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorOperatorrepresenting the concatenation of twoOperators.- Parameters:
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Return the operator's derivative with respect to a given parameter.
Return the operator's Jacobian as a new
Operator.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- d_mu(parameter, index=0)[source]¶
Return the operator’s derivative with respect to a given parameter.
If the operator has a
Solver, the derivativeOperatorwill be equipped with the sameSolver.- 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.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.operators.constructions.ConstantOperator(value, source, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorA constant
Operatoralways returning the same vector.- Parameters:
value – A
VectorArrayof length 1 containing the vector which is returned by the operator.source – Source
VectorSpaceof the operator.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Return the operator's Jacobian as a new
Operator.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.operators.constructions.FixedParameterOperator(operator, mu=None, solver=None, name=None)[source]¶
Bases:
ProxyOperatorMakes an
OperatorParameter-independent by setting fixedparameter values.- Parameters:
operator – The
Operatorto wrap.mu – The fixed
parameter valuesthat will be fed to theapplymethod (and related methods) ofoperator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Return the operator's Jacobian as a new
Operator.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- class pymor.operators.constructions.IdentityOperator(space, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorThe identity
Operator.In other words:
op.apply(U) == U
- Parameters:
space – The
VectorSpacethe operator acts on.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Assemble the operator for given
parameter values.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- assemble(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
LincombOperatorwill 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.If the operator has a
Solver, the assembledOperatorwill be equipped with the sameSolver.- Parameters:
mu – The
parameter valuesfor which to assemble the operator.- Returns:
Parameter-independent, assembled |Operator|.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.operators.constructions.InducedNorm(product, raise_negative, tol, name)[source]¶
Bases:
pymor.parameters.base.ParametricObjectInstantiated by
induced_norm. Do not use directly.
- class pymor.operators.constructions.InverseAdjointOperator(operator, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorRepresents the inverse adjoint of a given
Operator.- Parameters:
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- class pymor.operators.constructions.InverseOperator(operator, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorRepresents the inverse of a given
Operator.- Parameters:
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- class pymor.operators.constructions.LincombOperator(operators, coefficients, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorLinear combination of arbitrary
Operators.This
Operatorrepresents a (possiblyParameterdependent) linear combination of a given list ofOperators.- Parameters:
operators – List of
Operatorswhose linear combination is formed.coefficients – A list of linear coefficients. A linear coefficient can either be a fixed number or a
ParameterFunctional.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Treat the operator as a 2-form and apply it to V and U.
Apply the adjoint operator.
Return a
VectorArrayrepresentation of the operator in its range space.Return a
VectorArrayrepresentation of the operator in its source space.Assemble the operator for given
parameter values.Return the operator's derivative with respect to a given parameter.
Compute the linear coefficients for given
parameter values.Return the operator's Jacobian as a new
Operator.Treat the operator as a 2-form and apply it to V and U in pairs.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- apply2(V, U, mu=None)[source]¶
Treat the operator as a 2-form 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, thenapply2is given as:op.apply2(V, U) = V^T*M*U.
In the case of complex numbers, note that
apply2is anti-linear in the first variable by definition ofinner.- Parameters:
V –
VectorArrayof the left arguments V.U –
VectorArrayof the right arguments U.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
A
NumPy arraywith shape(len(V), len(U))containing the 2-formevaluations.
- apply_adjoint(V, mu=None)[source]¶
Apply the adjoint operator.
For any given linear
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- as_range_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for givenparameter valuesmuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- as_source_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for givenparameter valuesmuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.inner(U)) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- assemble(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
LincombOperatorwill 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.If the operator has a
Solver, the assembledOperatorwill be equipped with the sameSolver.- Parameters:
mu – The
parameter valuesfor which to assemble the operator.- Returns:
Parameter-independent, assembled |Operator|.
- d_mu(parameter, index=0)[source]¶
Return the operator’s derivative with respect to a given parameter.
If the operator has a
Solver, the derivativeOperatorwill be equipped with the sameSolver.- 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.
- evaluate_coefficients(mu)[source]¶
Compute the linear coefficients for given
parameter values.- Parameters:
mu –
Parameter valuesfor which to compute the linear coefficients.- Returns:
List of linear coefficients.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- pairwise_apply2(V, U, mu=None)[source]¶
Treat the operator as a 2-form 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, thenapply2is given as:op.apply2(V, U)[i] = V[i]^T*M*U[i].
In the case of complex numbers, note that
pairwise_apply2is anti-linear in the first variable by definition ofpairwise_inner.- Parameters:
V –
VectorArrayof the left arguments V.U –
VectorArrayof the right arguments U.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
A
NumPy arraywith shape(len(V),) == (len(U),)containingthe 2-form evaluations.
- class pymor.operators.constructions.LinearInputOperator(B, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorOperator representing the product B(mu)*input(t).
- Parameters:
Methods
Apply the operator to a
VectorArray.Return a
VectorArrayrepresentation of the operator in its range space.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- as_range_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for givenparameter valuesmuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- class pymor.operators.constructions.LinearOperator(operator, solver=None, name=None)[source]¶
Bases:
ProxyOperatorMark the wrapped
Operatorto be linear.
- class pymor.operators.constructions.LowRankOperator(left, core, right, inverted=False, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorNon-parametric low-rank operator.
Represents an operator of the form \(L C R^H\) or \(L C^{-1} R^H\) where \(L\) and \(R\) are
VectorArraysof column vectors and \(C\) a 2DNumPy array.- Parameters:
left –
VectorArrayrepresenting \(L\).core –
NumPy arrayrepresenting \(C\).right –
VectorArrayrepresenting \(R\).inverted – Whether \(C\) is inverted.
solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor 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=None, name=None)[source]¶
Bases:
LincombOperatorOperatorplusLowRankOperator.Represents a linear combination of an
OperatorandLowRankOperator. Uses the Sherman-Morrison-Woodbury formula inapply_inverseandapply_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 –
Operator.lr_operator –
LowRankOperator.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 – The
Solverfor the operator.name – Name of the operator.
- class pymor.operators.constructions.NumpyConversionOperator(space, direction='to_numpy', solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorConverts
VectorArraystoNumpyVectorArrays.Note that the input
VectorArraysneed to supportto_numpy. For the adjoint,from_numpyneeds to be implemented.- Parameters:
space – The
VectorSpaceof theVectorArraysthat are converted toNumpyVectorArrays.direction – Either
'to_numpy'or'from_numpy'. In case of'to_numpy'applytakes aVectorArrayfromspaceand returns aNumpyVectorArray. In case of'from_numpy',applytakes aNumpyVectorArrayand returns aVectorArrayfromspace.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- class pymor.operators.constructions.ProjectedOperator(operator, range_basis, source_basis, product=None, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorGeneric
Operatorrepresenting the projection of anOperatorto a subspace.This operator is implemented as the concatenation of the linear combination with
source_basis, application of the originaloperatorand 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.projectas a default implementation for parametric or nonlinear operators.- Parameters:
operator – The
Operatorto project.range_basis – See
pymor.algorithms.projection.project.source_basis – See
pymor.algorithms.projection.project.product – See
pymor.algorithms.projection.project.solver – The
Solverfor the projected operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Assemble the operator for given
parameter values.Return the operator's Jacobian as a new
Operator.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- assemble(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
LincombOperatorwill 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.If the operator has a
Solver, the assembledOperatorwill be equipped with the sameSolver.- Parameters:
mu – The
parameter valuesfor which to assemble the operator.- Returns:
Parameter-independent, assembled |Operator|.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- class pymor.operators.constructions.ProxyOperator(operator, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorForwards all interface calls to given
Operator.Mainly useful as base class for other
Operatorimplementations.- Parameters:
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Return the operator's Jacobian as a new
Operator.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.operators.constructions.QuadraticFunctional(operator, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorAn
Operatorrepresenting a quadratic functional.Given an operator
Aacting on R^d, this class represents the functional:op: R^d ----> R^1 u |---> (A(u), u).
- Parameters:
Methods
Apply the operator to a
VectorArray.Return the operator's derivative with respect to a given parameter.
Return the operator's Jacobian as a new
Operator.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor which to evaluate the operator.
- Returns:
|VectorArray| of the operator evaluations.
- d_mu(parameter, index=1)[source]¶
Return the operator’s derivative with respect to a given parameter.
If the operator has a
Solver, the derivativeOperatorwill be equipped with the sameSolver.- 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.
- jacobian(U, mu=None)[source]¶
Return the operator’s Jacobian as a new
Operator.If the operator has a
Solver, the JacobianOperatorwill be equipped with the solver’sjacobian_solver.- Parameters:
U – Length 1
VectorArraycontaining the vector for which to compute the Jacobian.mu – The
parameter valuesfor which to compute the Jacobian.
- Returns:
Linear |Operator| representing the Jacobian.
- class pymor.operators.constructions.QuadraticProductFunctional(left, right, product=None, solver=None, name=None)[source]¶
Bases:
QuadraticFunctionalAn
Operatorrepresenting a quadratic functional by multiplying two linear functionals.Given linear operators
A,B: R^d —-> R^n, this class represents the functional:op: R^d ----> R^1 u |---> (A(u), B(u)).
- Parameters:
- class pymor.operators.constructions.SelectionOperator(operators, parameter_functional, boundaries, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorAn
Operatorselected from a list ofOperators.operators[i]is used ifparameter_functional(mu)is less or equal thanboundaries[i]and greater thanboundaries[i-1]:-infty ------- boundaries[i] ---------- boundaries[i+1] ------- infty | | --- operators[i] ---|---- operators[i+1] ----|---- operators[i+2] | |
- Parameters:
operators – List of
Operatorsfrom which oneOperatoris selected based on the givenparameter values.parameter_functional – The
ParameterFunctionalused for the selection of oneOperator.boundaries – The interval boundaries as defined above.
solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Return a
VectorArrayrepresentation of the operator in its range space.Return a
VectorArrayrepresentation of the operator in its source space.Assemble the operator for given
parameter values.- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- as_range_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for givenparameter valuesmuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- as_source_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for givenparameter valuesmuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.inner(U)) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- assemble(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
LincombOperatorwill 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.If the operator has a
Solver, the assembledOperatorwill be equipped with the sameSolver.- Parameters:
mu – The
parameter valuesfor which to assemble the operator.- Returns:
Parameter-independent, assembled |Operator|.
- class pymor.operators.constructions.VectorArrayOperator(array, adjoint=False, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorWraps a
VectorArrayas anOperator.If
adjointisFalse, the operator maps fromNumpyVectorSpace(len(array))toarray.spaceby forming linear combinations of the vectors in the array with given coefficient arrays.If
adjoint == True, the operator maps fromarray.spacetoNumpyVectorSpace(len(array))by forming the inner products of the argument with the vectors in the given array.- Parameters:
array – The
VectorArraywhich is to be treated as an operator.adjoint – See description above.
solver – The
Solverfor the operator.name – The name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Return a
VectorArrayrepresentation of the operator in its range space.Return a
VectorArrayrepresentation of the operator in its source space.Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- as_range_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its range space.In the case of a linear operator with
NumpyVectorSpaceassource, this method returns for givenparameter valuesmuaVectorArrayVin the operator’srange, such thatV.lincomb(U.to_numpy()) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- as_source_array(mu=None)[source]¶
Return a
VectorArrayrepresentation of the operator in its source space.In the case of a linear operator with
NumpyVectorSpaceasrange, this method returns for givenparameter valuesmuaVectorArrayVin the operator’ssource, such thatself.range.make_array(V.inner(U)) == self.apply(U, mu)
for all
VectorArraysU.- Parameters:
mu – The
parameter valuesfor which to return theVectorArrayrepresentation.- Returns:
V – The
VectorArraydefined above.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- class pymor.operators.constructions.VectorFunctional(vector, product=None, solver=None, name=None)[source]¶
Bases:
VectorArrayOperatorWrap a vector as a linear
Functional.Given a vector
vof dimensiond, this class represents the functionalf: R^d ----> R^1 u |---> (u, v)
where
( , )denotes the inner product given byproduct.In particular, if
productisNoneVectorFunctional(vector).as_source_array() == vector.
If
productis not none, we obtainVectorFunctional(vector).as_source_array() == product.apply(vector).
- Parameters:
vector –
VectorArrayof length 1 containing the vectorv.product –
Operatorrepresenting the scalar product to use.solver – The
Solverfor the operator.name – Name of the operator.
- class pymor.operators.constructions.VectorOperator(vector, solver=None, name=None)[source]¶
Bases:
VectorArrayOperatorWrap a vector as a vector-like
Operator.Given a vector
vof dimensiond, this class represents the operatorop: R^1 ----> R^d x |---> x⋅vIn particular:
VectorOperator(vector).as_range_array() == vector
- Parameters:
vector –
VectorArrayof length 1 containing the vectorv.solver – The
Solverfor the operator.name – Name of the operator.
- class pymor.operators.constructions.ZeroOperator(range, source, solver=None, name=None)[source]¶
Bases:
pymor.operators.interface.OperatorThe
Operatorwhich maps every vector to zero.- Parameters:
range – Range
VectorSpaceof the operator.source – Source
VectorSpaceof the operator.solver – The
Solverfor the operator.name – Name of the operator.
Methods
Apply the operator to a
VectorArray.Apply the adjoint operator.
Restrict the operator range to a given set of degrees of freedom.
- apply(U, mu=None)[source]¶
Apply the operator to a
VectorArray.- Parameters:
U –
VectorArrayof vectors to which the operator is applied.mu – The
parameter valuesfor 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
Operatorop,parameter valuesmuandVectorArraysU,Vin thesourceresp.rangewe have:op.apply_adjoint(V, mu).dot(U) == V.inner(op.apply(U, mu))
Thus, when
opis represented by a matrixM,apply_adjointis given by left-multiplication of (the complex conjugate of)MwithV.- Parameters:
V –
VectorArrayof vectors to which the adjoint operator is applied.mu – The
parameter valuesfor which to apply the adjoint operator.
- Returns:
|VectorArray| of the adjoint operator evaluations.
- restricted(dofs)[source]¶
Restrict the operator range to a given set of degrees of freedom.
This method returns a restricted version
restricted_opof the operator along with an arraysource_dofssuch that for anyVectorArrayUinself.sourcethe following is true:self.apply(U, mu).dofs(dofs) == restricted_op.apply(restricted_op.source.from_numpy(U.dofs(source_dofs)) mu).to_numpy()
Such an operator is mainly useful for
empirical interpolationwhere 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_dofswill be needed to evaluate the restricted operator which can make its evaluation very fast compared to evaluating the original operator.- Parameters:
dofs – One-dimensional
NumPy arrayof degrees of freedom in the operatorrangeto which to restrict.- Returns:
restricted_op – The restricted operator as defined above. The operator will have
NumpyVectorSpace(len(source_dofs))assourceandNumpyVectorSpace(len(dofs))asrange.source_dofs – One-dimensional
NumPy arrayof source degrees of freedom as defined above.
- pymor.operators.constructions.induced_norm(product, raise_negative=True, tol=1e-10, name=None)[source]¶
Obtain induced norm of an inner product.
The norm of the vectors in a
VectorArrayU is calculated by callingproduct.pairwise_apply2(U, U, mu=mu).
In addition, negative norm squares of absolute value smaller than
tolare clipped to0. Ifraise_negativeisTrue, aValueErrorexception is raised if there are negative norm squares of absolute value larger thantol.- Parameters:
product – The inner product
Operatorfor 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 aVectorArrayUas input together with theparameter valuesmuwhich are passed to the product.
- pymor.operators.constructions.vector_array_to_selection_operator(array, time_instances=None, initial_time=None, end_time=None, name=None)[source]¶
Create a
SelectionOperatorfrom aVectorArray.A
SelectionOperatoris created that selects an element from theVectorArrayarraydepending on the time component of the parameter that is passed to theOperator. Iftime_instancesis provided, these values are used for selection according to the behavior of theSelectionOperator. Ifinitial_timeandend_timeare used, the time interval is split equidistantly where the number of subintervals is determined by the length ofarray. In time, the operator is therefore piecewise constant and the discontinuity points are att_i - eps, i.e.:-infty ------- initial_time --------- t_1 ----------- t_2 --------------- ... --------------- t_{n-1} ----------- end_time ----------- infty | | | | | ---------------- array[0] ---------|--- array[1] --|--- array[2] --|----------...----------|---- array[n-2] ---|-------- array[n-1] -------- | | | | |
where
n = len(array),t_i = initial_time + i * (end_time - initial_time) / n,eps = (end_time - initial_time) * machine_eps * n * 10.- Parameters:
array –
VectorArraythat is used to buildVectorArrayOperatorsthat can be selected using the createdSelectionOperator.time_instances – List of time instances used for selecting the element of the
VectorArrayarraywithin theSelectionOperator. IfNone,initial_timeandend_timeneed to be provided.initial_time – If
time_instancesis not provided, theinitial_timeis used to determine the start of the time interval that is equidistantly divided into subintervals on which theSelectionOperatoris piecewise constant.end_time – Similar to
initial_timebut determines the end time of the time interval.name – Name of the operator.
- Returns:
operator –
SelectionOperatorwhere the selection of the element in theVectorArrayis performed according to the time parameter.