From 98f072ff6bcf52abc1aced86ba5fe9c2db829560 Mon Sep 17 00:00:00 2001 From: Dominik Thoennes <dominik.thoennes@fau.de> Date: Tue, 5 Jan 2021 17:44:19 +0100 Subject: [PATCH] some fixes for hyteg --- pystencils/backends/cbackend.py | 5 ++++- pystencils/integer_functions.py | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pystencils/backends/cbackend.py b/pystencils/backends/cbackend.py index ae29ee1da..7f8e546c9 100644 --- a/pystencils/backends/cbackend.py +++ b/pystencils/backends/cbackend.py @@ -228,7 +228,8 @@ class CBackend: def _print_LoopOverCoordinate(self, node): counter_symbol = node.loop_counter_name start = f"int {counter_symbol} = {self.sympy_printer.doprint(node.start)}" - condition = f"{counter_symbol} < {self.sympy_printer.doprint(node.stop)}" + condition = f"{self.sympy_printer.doprint(node.relational(node.loop_counter_symbol, node.stop))}" + #condition = f"{counter_symbol} < {self.sympy_printer.doprint(node.stop)}" update = f"{counter_symbol} += {self.sympy_printer.doprint(node.step)}" loop_str = f"for ({start}; {condition}; {update})" @@ -412,6 +413,8 @@ class CustomSympyPrinter(CCodePrinter): return f"(1 << ({self._print(expr.args[0])}))" elif expr.func == int_div: return f"(({self._print(expr.args[0])}) / ({self._print(expr.args[1])}))" + elif expr.func == post_increment: + return f"({self._print(expr.args[0])})" else: name = expr.name if hasattr(expr, 'name') else expr.__class__.__name__ arg_str = ', '.join(self._print(a) for a in expr.args) diff --git a/pystencils/integer_functions.py b/pystencils/integer_functions.py index c6fae4fbf..a6b9daf21 100644 --- a/pystencils/integer_functions.py +++ b/pystencils/integer_functions.py @@ -59,7 +59,11 @@ class int_div(IntegerFunctionTwoArgsMixIn): # noinspection PyPep8Naming -class int_power_of_2(IntegerFunctionTwoArgsMixIn): +class int_power_of_2(sp.Function): + pass + +# noinspection PyPep8Naming +class post_increment(sp.Function): pass -- GitLab