def inner(self, o, a, b): ash = a.ufl_shape bsh = b.ufl_shape if ash != bsh: error("Nonmatching shapes.") ii = indices(len(ash)) # Creates multiple IndexSums over a Product s = a[ii]*Conj(b[ii]) return s
def handle_conj(v, fac, sf, F): fac = fac[0] if fac: factors = {} for k in fac: f0 = F.nodes[fac[k]]['expression'] factors[k] = graph_insert(F, Conj(f0)) else: raise RuntimeError("No arguments") return factors
def alternative_inner(self, o, a, b): # TODO: Test this ash = a.ufl_shape bsh = b.ufl_shape if ash != bsh: error("Nonmatching shapes.") # Simplification for tensors with one or more dimensions of # length 1 ii = [] zi = FixedIndex(0) for n in ash: if n == 1: ii.append(zi) else: ii.append(Index()) ii = tuple(ii) # ii = indices(len(a.ufl_shape)) # Potentially creates multiple IndexSums over a Product s = a[ii]*Conj(b[ii]) return s
def conj(self, o, df): return Conj(df)
def outer(self, o, a, b): ii = indices(len(a.ufl_shape)) jj = indices(len(b.ufl_shape)) # Create a Product with no shared indices s = Conj(a[ii])*b[jj] return as_tensor(s, ii+jj)