Skip to content

Instantly share code, notes, and snippets.

@wence-
Created March 13, 2014 12:26
Show Gist options
  • Select an option

  • Save wence-/9527461 to your computer and use it in GitHub Desktop.

Select an option

Save wence-/9527461 to your computer and use it in GitHub Desktop.
diff --git a/python/firedrake/nullspace.py b/python/firedrake/nullspace.py
index 382f039..0daf197 100644
--- a/python/firedrake/nullspace.py
+++ b/python/firedrake/nullspace.py
@@ -1,5 +1,5 @@
from petsc4py import PETSc
-from types import IndexedFunctionSpace
+from types import IndexedFunctionSpace, Function
class VectorSpaceBasis(object):
@@ -38,10 +38,15 @@ class VectorSpaceBasis(object):
return self._nullspace
def orthogonalize(self, b):
- """Orthogonalize ``b`` with respect to this :class:`.VectorSpaceBasis`.
+ """Return a copy of ``b`` orthogonalized with respect to this :class:`.VectorSpaceBasis`.
:arg b: a :class:`.Function`"""
- raise NotImplementedError
+ ret = Function(b)
+ with b.dat.vec_ro as bv:
+ for v, iv in zip(self._vecs, self._petsc_vecs):
+ dot = iv.dot(bv)
+ ret += -dot * v
+ return ret
def is_orthonormal(self):
"""Is this vector space basis orthonormal?"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment