Skip to content
Snippets Groups Projects
Commit d1ee3d7f authored by Christoph Alt's avatar Christoph Alt
Browse files

dirty hack to print sqrt instead of pow( 0.5 )

parent c55ae38c
Branches stencilstream
No related tags found
No related merge requests found
Pipeline #48147 failed
...@@ -6,7 +6,7 @@ import sympy as sp ...@@ -6,7 +6,7 @@ import sympy as sp
from pystencils.astnodes import Node, cast_func from pystencils.astnodes import Node, cast_func
from pystencils.backends.cbackend import CBackend, CustomSympyPrinter, generate_c from pystencils.backends.cbackend import CBackend, CustomSympyPrinter, generate_c
from pystencils.data_types import (Type, VectorType, get_type_of_expression, collate_types,) from pystencils.data_types import Type, VectorType, collate_types, get_type_of_expression
from pystencils.field import Field from pystencils.field import Field
with open(join(dirname(__file__), "sycl_known_functions.txt")) as f: with open(join(dirname(__file__), "sycl_known_functions.txt")) as f:
...@@ -216,10 +216,10 @@ class SyCLSympyPrinter(CustomSympyPrinter): ...@@ -216,10 +216,10 @@ class SyCLSympyPrinter(CustomSympyPrinter):
return f"({self._print(sp.Mul(*[expr.base] * expr.exp, evaluate=False))})" return f"({self._print(sp.Mul(*[expr.base] * expr.exp, evaluate=False))})"
elif expr.exp.is_integer and -8 < expr.exp < 0: elif expr.exp.is_integer and -8 < expr.exp < 0:
return super()._print_Pow(expr) return super()._print_Pow(expr)
if get_type_of_expression(expr.exp) != base_type: if expr.exp == 0.5 or expr.exp == -0.5 or get_type_of_expression(expr.exp) == base_type:
ret = pre_fixed_pow(sp.Pow(expr.base, cast_func(expr.exp, base_type)))
else:
ret = pre_fixed_pow(expr) ret = pre_fixed_pow(expr)
else:
ret = pre_fixed_pow(sp.Pow(expr.base, cast_func(expr.exp, base_type)))
try: try:
number = float(ret) number = float(ret)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment