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
Model registry
Operate
Environments
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
Stephan Seitz
pystencils
Commits
1de99ef0
Commit
1de99ef0
authored
5 years ago
by
Stephan Seitz
Committed by
Stephan Seitz
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add printing support for re,im,ImaginaryUnit,_typed_number(**complex**) to CustomSympyPrinter
parent
2bd6cb86
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/backends/cbackend.py
+13
-0
13 additions, 0 deletions
pystencils/backends/cbackend.py
with
13 additions
and
0 deletions
pystencils/backends/cbackend.py
+
13
−
0
View file @
1de99ef0
...
...
@@ -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
):
...
...
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