def inner(self, vec): """ Computes the inner product with vec. """ assert isinstance(vec, DolfinPrimalVector) events.increment("Inner product") v = self.riesz_map.dual_map(self.data.vector()) return v.inner(self.data.vector())
def dual(self): """ Returns the dual representation. """ events.increment("Primal -> dual map") if isinstance(self.data, dolfin.Function): V = self.data.function_space() dual_vec = self.riesz_map.dual_map(self.data.vector()) dual = dolfin.Function(V, dual_vec) return DolfinDualVector(dual, riesz_map=self.riesz_map) else: return self
def primal(self): """ Returns the primal representation. """ events.increment("Dual -> primal map") if isinstance(self.data, dolfin.Function): V = self.data.function_space() dual = dolfin.Function(V) self.riesz_map.primal_map(dual.vector(), self.data.vector()) return DolfinPrimalVector(dual, riesz_map=self.riesz_map) elif isinstance(self.data, dolfin.MultiMeshFunction): V = self.data.function_space() dual = dolfin.MultiMeshFunction(V) self.riesz_map.primal_map(dual.vector(), self.data.vector()) return DolfinPrimalVector(dual, riesz_map=self.riesz_map) else: return self
def inner(self, vec): """ Computes the inner product with vec. """ assert isinstance(vec, DolfinPrimalVectorSet) events.increment("Inner product") return sum([ss.inner(vec) for ss, vec in zip(self.vector_list, vec.vector_list)])
def primal(self): """ Returns the primal representation. """ events.increment("Dual -> primal map") return NumpyPrimalVector(self.data.copy())
def inner(self, vec): """ Computes the inner product with vec. """ assert isinstance(vec, NumpyPrimalVector) events.increment("Inner product") return float(np.dot(self.data, vec.data))