Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frederik Hennig
pystencils
Commits
da54b3ec
Commit
da54b3ec
authored
Nov 13, 2019
by
Nils Kohl
🌝
Browse files
Added integer function that does a post increment
parent
13e4eba9
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
da54b3ec
...
...
@@ -13,7 +13,7 @@ except ImportError:
from
sympy.printing.ccode
import
CCodePrinter
# for sympy versions < 1.1
from
pystencils.integer_functions
import
bitwise_xor
,
bit_shift_right
,
bit_shift_left
,
bitwise_and
,
\
bitwise_or
,
modulo_ceil
,
int_div
,
int_power_of_2
,
int_mod
bitwise_or
,
modulo_ceil
,
int_div
,
int_power_of_2
,
int_mod
,
inc_post
from
pystencils.astnodes
import
Node
,
KernelFunction
from
pystencils.data_types
import
create_type
,
PointerType
,
get_type_of_expression
,
VectorType
,
cast_func
,
\
vector_memory_access
,
reinterpret_cast_func
...
...
@@ -311,6 +311,8 @@ class CustomSympyPrinter(CCodePrinter):
return
"((%s) / (%s))"
%
(
self
.
_print
(
expr
.
args
[
0
]),
self
.
_print
(
expr
.
args
[
1
]))
elif
expr
.
func
==
int_mod
:
return
"((%s) %% (%s))"
%
(
self
.
_print
(
expr
.
args
[
0
]),
self
.
_print
(
expr
.
args
[
1
]))
elif
expr
.
func
==
inc_post
:
return
"(%s++)"
%
(
self
.
_print
(
expr
.
args
[
0
]))
else
:
return
super
(
CustomSympyPrinter
,
self
).
_print_Function
(
expr
)
...
...
pystencils/integer_functions.py
View file @
da54b3ec
...
...
@@ -11,6 +11,7 @@ bitwise_or = sp.Function("bitwise_or")
int_div
=
sp
.
Function
(
"int_div"
)
int_power_of_2
=
sp
.
Function
(
"int_power_of_2"
)
int_mod
=
sp
.
Function
(
"int_mod"
)
inc_post
=
sp
.
Function
(
"inc_post"
)
# noinspection PyPep8Naming
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment