Skip to content
Snippets Groups Projects
Commit e1f5683e authored by Markus Holzer's avatar Markus Holzer
Browse files

fixed add printing

parent 3d2b7fb5
No related branches found
No related tags found
No related merge requests found
Pipeline #30509 passed
......@@ -631,15 +631,16 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
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['+']
func = self.instruction_set['-' + suffix] if sign == -1 else self.instruction_set['+' + suffix]
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['+']
func = self.instruction_set['-' + suffix] \
if summands[0].sign == -1 else self.instruction_set['+' + suffix]
return func.format(summands[0].term, visit(summands[elements:]))
else:
func = self.instruction_set['+']
func = self.instruction_set['+' + suffix]
return func.format(visit(summands[:elements]), visit(summands[elements:]))
try:
result = self._scalarFallback('_print_Add', expr)
......@@ -675,10 +676,13 @@ class VectorizedCustomSympyPrinter(CustomSympyPrinter):
summands.insert(0, self.SummandInfo(1, "0"))
assert len(summands) >= 2
processed = summands[0].term
for summand in summands[1:]:
func = self.instruction_set['-' + suffix] if summand.sign == -1 else self.instruction_set['+' + suffix]
processed = func.format(processed, summand.term)
if len(summands) < 10:
processed = summands[0].term
for summand in summands[1:]:
func = self.instruction_set['-' + suffix] if summand.sign == -1 else self.instruction_set['+' + suffix]
processed = func.format(processed, summand.term)
else:
processed = visit(summands)
return processed
def _print_Pow(self, expr):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment