Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
pystencils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hyteg
pystencils
Commits
e012de4b
Commit
e012de4b
authored
6 years ago
by
Nils Kohl
Committed by
Martin Bauer
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added int_div and int_power_of_2 functions
parent
a95b6503
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pystencils/backends/cbackend.py
+5
-1
5 additions, 1 deletion
pystencils/backends/cbackend.py
pystencils/integer_functions.py
+2
-0
2 additions, 0 deletions
pystencils/integer_functions.py
with
7 additions
and
1 deletion
pystencils/backends/cbackend.py
+
5
−
1
View file @
e012de4b
...
...
@@ -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
bitwise_or
,
modulo_ceil
,
int_div
,
int_power_of_2
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
...
...
@@ -301,6 +301,10 @@ class CustomSympyPrinter(CCodePrinter):
return
"
({})
"
.
format
(
self
.
_print
(
1
/
sp
.
sqrt
(
expr
.
args
[
0
])))
elif
expr
.
func
in
infix_functions
:
return
"
(%s %s %s)
"
%
(
self
.
_print
(
expr
.
args
[
0
]),
infix_functions
[
expr
.
func
],
self
.
_print
(
expr
.
args
[
1
]))
elif
expr
.
func
==
int_power_of_2
:
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
]))
else
:
return
super
(
CustomSympyPrinter
,
self
).
_print_Function
(
expr
)
...
...
This diff is collapsed.
Click to expand it.
pystencils/integer_functions.py
+
2
−
0
View file @
e012de4b
...
...
@@ -8,6 +8,8 @@ bit_shift_right = sp.Function("bit_shift_right")
bit_shift_left
=
sp
.
Function
(
"
bit_shift_left
"
)
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
"
)
# noinspection PyPep8Naming
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment