Skip to content

Commit

Permalink
[VectorArrayOperator] implement apply_inverse via QR decomposition
Browse files Browse the repository at this point in the history
  • Loading branch information
sdrave committed Feb 26, 2020
1 parent 5a21744 commit 32fa583
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/pymor/operators/constructions.py
Expand Up @@ -841,6 +841,24 @@ def apply(self, U, mu=None):
else:
return self.range.make_array(self.array.dot(U).T)

def apply_inverse(self, V, mu=None, least_squares=False):
if not least_squares and len(V) != V.dim:
raise InversionError

from pymor.algorithms.gram_schmidt import gram_schmidt
from numpy.linalg import lstsq

Q, R = gram_schmidt(self.array, return_R=True, reiterate=False)
if self.adjoint:
v = lstsq(R.T.conj(), V.to_numpy().T)[0]
U = Q.lincomb(v.T)
else:
v = Q.dot(V)
u = lstsq(R, v)[0]
U = self.source.make_array(u.T)

return U

def apply_adjoint(self, V, mu=None):
assert V in self.range
if not self.adjoint:
Expand Down

0 comments on commit 32fa583

Please sign in to comment.