Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonas Plewinski
pystencils
Commits
37650bc9
Commit
37650bc9
authored
Jun 12, 2019
by
Nils Kohl
🌝
Browse files
Added new sympy integer function: integer modulo, extended cbackend
parent
102f07f8
Changes
2
Hide whitespace changes
Inline
Side-by-side
pystencils/backends/cbackend.py
View file @
37650bc9
...
...
@@ -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
bitwise_or
,
modulo_ceil
,
int_div
,
int_power_of_2
,
int_mod
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
...
...
@@ -308,6 +308,8 @@ class CustomSympyPrinter(CCodePrinter):
return
"(1 << (%s))"
%
(
self
.
_print
(
expr
.
args
[
0
]))
elif
expr
.
func
==
int_div
:
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
]))
else
:
return
super
(
CustomSympyPrinter
,
self
).
_print_Function
(
expr
)
...
...
pystencils/integer_functions.py
View file @
37650bc9
...
...
@@ -10,6 +10,7 @@ bitwise_and = sp.Function("bitwise_and")
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"
)
# noinspection PyPep8Naming
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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