Skip to content
Snippets Groups Projects
Commit 1de99ef0 authored by Stephan Seitz's avatar Stephan Seitz Committed by Stephan Seitz
Browse files

Add printing support for re,im,ImaginaryUnit,_typed_number(**complex**) to CustomSympyPrinter

parent 2bd6cb86
Branches
No related tags found
No related merge requests found
......@@ -380,6 +380,10 @@ class CustomSympyPrinter(CCodePrinter):
return res + '.0f' if '.' not in res else res + 'f'
elif dtype.numpy_dtype == np.float64:
return res + '.0' if '.' not in res else res
elif dtype.numpy_dtype == np.complex64:
return f"{_typed_number(number.real, np.float32)} + {_typed_number(number.real, np.float32).replace('f', 'if')}"
elif dtype.numpy_dtype == np.complex128:
return f"{_typed_number(number.real, np.float64)} + {_typed_number(number.real, np.float64)}i"
else:
return res
......@@ -431,6 +435,15 @@ class CustomSympyPrinter(CCodePrinter):
_print_Max = C89CodePrinter._print_Max
_print_Min = C89CodePrinter._print_Min
def _print_re(self, expr):
return f"std::real({self._print(expr.args[0])})"
def _print_im(self, expr):
return f"std::imag({self._print(expr.args[0])})"
def _print_ImaginaryUnit(self, expr):
return "1if"
# noinspection PyPep8Naming
class VectorizedCustomSympyPrinter(CustomSympyPrinter):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment