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
Markus Holzer
pystencils
Commits
faba3cc4
Commit
faba3cc4
authored
4 years ago
by
Markus Holzer
Browse files
Options
Downloads
Patches
Plain Diff
Changed layout for many summands
parent
6718973d
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#30356
passed
4 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pystencils/backends/cbackend.py
+21
-4
21 additions, 4 deletions
pystencils/backends/cbackend.py
with
21 additions
and
4 deletions
pystencils/backends/cbackend.py
+
21
−
4
View file @
faba3cc4
...
@@ -609,6 +609,20 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
...
@@ -609,6 +609,20 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
return
result
return
result
def
_print_Add
(
self
,
expr
,
order
=
None
):
def
_print_Add
(
self
,
expr
,
order
=
None
):
def
visit
(
summands
):
if
len
(
summands
)
==
2
:
sign
=
summands
[
0
].
sign
*
summands
[
1
].
sign
func
=
self
.
instruction_set
[
'
-
'
]
if
sign
==
-
1
else
self
.
instruction_set
[
'
+
'
]
return
func
.
format
(
summands
[
0
].
term
,
summands
[
1
].
term
)
else
:
elements
=
len
(
summands
)
//
2
if
len
(
summands
[:
elements
])
<
2
:
func
=
self
.
instruction_set
[
'
-
'
]
if
summands
[
0
].
sign
==
-
1
else
self
.
instruction_set
[
'
+
'
]
return
func
.
format
(
summands
[
0
].
term
,
visit
(
summands
[
elements
:]))
else
:
func
=
self
.
instruction_set
[
'
+
'
]
return
func
.
format
(
visit
(
summands
[:
elements
]),
visit
(
summands
[
elements
:]))
result
=
self
.
_scalarFallback
(
'
_print_Add
'
,
expr
)
result
=
self
.
_scalarFallback
(
'
_print_Add
'
,
expr
)
if
result
:
if
result
:
return
result
return
result
...
@@ -628,10 +642,13 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
...
@@ -628,10 +642,13 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
summands
.
insert
(
0
,
self
.
SummandInfo
(
1
,
"
0
"
))
summands
.
insert
(
0
,
self
.
SummandInfo
(
1
,
"
0
"
))
assert
len
(
summands
)
>=
2
assert
len
(
summands
)
>=
2
processed
=
summands
[
0
].
term
if
len
(
summands
)
<
10
:
for
summand
in
summands
[
1
:]:
processed
=
summands
[
0
].
term
func
=
self
.
instruction_set
[
'
-
'
]
if
summand
.
sign
==
-
1
else
self
.
instruction_set
[
'
+
'
]
for
summand
in
summands
[
1
:]:
processed
=
func
.
format
(
processed
,
summand
.
term
)
func
=
self
.
instruction_set
[
'
-
'
]
if
summand
.
sign
==
-
1
else
self
.
instruction_set
[
'
+
'
]
processed
=
func
.
format
(
processed
,
summand
.
term
)
else
:
processed
=
visit
(
summands
)
return
processed
return
processed
def
_print_Pow
(
self
,
expr
):
def
_print_Pow
(
self
,
expr
):
...
...
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