Skip to content
Snippets Groups Projects
Commit 3f114046 authored by Markus Holzer's avatar Markus Holzer
Browse files

Fix precision problems

parent 553eb5bf
No related merge requests found
Pipeline #36461 passed with stages
in 33 minutes and 50 seconds
...@@ -160,7 +160,7 @@ class LbmWeightInfo(CustomCodeNode): ...@@ -160,7 +160,7 @@ class LbmWeightInfo(CustomCodeNode):
self.weights_symbol = TypedSymbol("weights", data_type) self.weights_symbol = TypedSymbol("weights", data_type)
data_type_string = "double" if self.weights_symbol.dtype.numpy_dtype == np.float64 else "float" data_type_string = "double" if self.weights_symbol.dtype.numpy_dtype == np.float64 else "float"
weights = [str(w.evalf()) for w in lb_method.weights] weights = [str(w.evalf(17)) for w in lb_method.weights]
if data_type_string == "float": if data_type_string == "float":
weights = "f, ".join(weights) weights = "f, ".join(weights)
weights += "f" # suffix for the last element weights += "f" # suffix for the last element
...@@ -172,7 +172,7 @@ class LbmWeightInfo(CustomCodeNode): ...@@ -172,7 +172,7 @@ class LbmWeightInfo(CustomCodeNode):
def weight_of_direction(self, dir_idx, lb_method=None): def weight_of_direction(self, dir_idx, lb_method=None):
if isinstance(sp.sympify(dir_idx), sp.Integer): if isinstance(sp.sympify(dir_idx), sp.Integer):
return lb_method.weights[dir_idx].evalf() return lb_method.weights[dir_idx].evalf(17)
else: else:
return sp.IndexedBase(self.weights_symbol, shape=(1,))[dir_idx] return sp.IndexedBase(self.weights_symbol, shape=(1,))[dir_idx]
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment