Exemplo n.º 1
0
 def _ad_convert_type(self, value, options={}):
     if value is None:
         # TODO: Should the default be 0 constant here or return just None?
         return Constant(numpy.zeros(self.ufl_shape))
     value = gather(value)
     value = compat.constant_function_firedrake_compat(value)
     return constant_from_values(self, value)
Exemplo n.º 2
0
 def _applyBinary(self, f, y):
     npdata = self.values()
     npdatacopy = self.values().copy()
     npdatay = y.values()
     for i in range(len(npdata)):
         npdatacopy[i] = f(npdata[i], npdatay[i])
     self.assign(constant_from_values(self, npdatacopy))
Exemplo n.º 3
0
 def _ad_iadd(self, other):
     self.assign(constant_from_values(self, self.values() + other.values()))
Exemplo n.º 4
0
 def _ad_imul(self, other):
     self.assign(constant_from_values(self, self.values() * other))
Exemplo n.º 5
0
 def _ad_copy(self):
     return constant_from_values(self)
Exemplo n.º 6
0
 def _ad_add(self, other):
     return constant_from_values(self, self.values() + other.values())
Exemplo n.º 7
0
 def _ad_mul(self, other):
     return constant_from_values(self, self.values() * other)
Exemplo n.º 8
0
 def _ad_create_checkpoint(self):
     return constant_from_values(self)
Exemplo n.º 9
0
 def __deepcopy__(self, memodict={}):
     return constant_from_values(self)
Exemplo n.º 10
0
 def _applyUnary(self, f):
     npdata = self.values()
     npdatacopy = npdata.copy()
     for i in range(len(npdata)):
         npdatacopy[i] = f(npdata[i])
     self.assign(constant_from_values(self, npdatacopy))