def apply_inverse_adjoint(self, U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False): from pymor.operators.constructions import FixedParameterOperator assembled_op = self.assemble(mu) if assembled_op != self and not isinstance(assembled_op, FixedParameterOperator): return assembled_op.apply_inverse_adjoint(U, ind=ind, source_product=source_product, range_product=range_product, least_squares=least_squares) elif source_product or range_product: if source_product: U = source_product.apply(U, ind=ind) ind = None # maybe there is a better implementation for source_product == None and range_product == None V = self.apply_inverse_adjoint(U, mu=mu, least_squares=least_squares) if range_product: return range_product.apply_inverse(V) else: return V else: if not self.linear: raise NotImplementedError # use generic solver for the adjoint operator from pymor.operators.constructions import AdjointOperator options = {'inverse': self.solver_options.get('inverse_adjoint') if self.solver_options else None} adjoint_op = AdjointOperator(self, with_apply_inverse=False, solver_options=options) return adjoint_op.apply_inverse(U, ind=ind, mu=mu, least_squares=least_squares)
def apply_inverse_adjoint(self, U, mu=None, least_squares=False): """Apply the inverse adjoint operator. Parameters ---------- U |VectorArray| of vectors to which the inverse adjoint operator is applied. mu The |Parameter| for which to evaluate the inverse adjoint operator. 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. """ from pymor.operators.constructions import FixedParameterOperator if not self.linear: raise LinAlgError('Operator not linear.') assembled_op = self.assemble(mu) if assembled_op != self and not isinstance(assembled_op, FixedParameterOperator): return assembled_op.apply_inverse_adjoint( U, least_squares=least_squares) else: # use generic solver for the adjoint operator from pymor.operators.constructions import AdjointOperator options = { 'inverse': self.solver_options.get('inverse_adjoint') if self.solver_options else None } adjoint_op = AdjointOperator(self, with_apply_inverse=False, solver_options=options) return adjoint_op.apply_inverse(U, mu=mu, least_squares=least_squares)
def apply_inverse_adjoint(self, U, mu=None, least_squares=False): from pymor.operators.constructions import FixedParameterOperator if not self.linear: raise LinAlgError('Operator not linear.') assembled_op = self.assemble(mu) if assembled_op != self and not isinstance(assembled_op, FixedParameterOperator): return assembled_op.apply_inverse_adjoint(U, least_squares=least_squares) else: # use generic solver for the adjoint operator from pymor.operators.constructions import AdjointOperator options = {'inverse': self.solver_options.get('inverse_adjoint') if self.solver_options else None} adjoint_op = AdjointOperator(self, with_apply_inverse=False, solver_options=options) return adjoint_op.apply_inverse(U, mu=mu, least_squares=least_squares)
def apply_inverse_transpose(self, U, mu=None, least_squares=False): from pymor.operators.constructions import FixedParameterOperator assembled_op = self.assemble(mu) if assembled_op != self and not isinstance(assembled_op, FixedParameterOperator): return assembled_op.apply_inverse_transpose(U, least_squares=least_squares) else: if not self.linear: raise NotImplementedError # use generic solver for the transpose operator from pymor.operators.constructions import AdjointOperator options = {'inverse': self.solver_options.get('inverse_transpose') if self.solver_options else None} transpose_op = AdjointOperator(self, with_apply_inverse=False, solver_options=options) return transpose_op.apply_inverse(U, mu=mu, least_squares=least_squares)
def apply_inverse_adjoint(self, U, ind=None, mu=None, source_product=None, range_product=None, least_squares=False): from pymor.operators.constructions import FixedParameterOperator assembled_op = self.assemble(mu) if assembled_op != self and not isinstance(assembled_op, FixedParameterOperator): return assembled_op.apply_inverse_adjoint( U, ind=ind, source_product=source_product, range_product=range_product, least_squares=least_squares) elif source_product or range_product: if source_product: U = source_product.apply(U, ind=ind) ind = None # maybe there is a better implementation for source_product == None and range_product == None V = self.apply_inverse_adjoint(U, mu=mu, least_squares=least_squares) if range_product: return range_product.apply_inverse(V) else: return V else: if not self.linear: raise NotImplementedError # use generic solver for the adjoint operator from pymor.operators.constructions import AdjointOperator options = { 'inverse': self.solver_options.get('inverse_adjoint') if self.solver_options else None } adjoint_op = AdjointOperator(self, with_apply_inverse=False, solver_options=options) return adjoint_op.apply_inverse(U, ind=ind, mu=mu, least_squares=least_squares)