Algrorithm for print order in MatAdd?

21 views
Skip to first unread message

Matthew Brett

unread,
May 24, 2022, 7:04:13 PM5/24/22
to sympy
Dear team,

I was trying to display an equation resulting from MatAdd, and noticed
that I could not control the order in which the Matrices appear in the
result.

For example, consider:

from sympy import MatAdd, Matrix
A = Matrix([1])
B = Matrix([0])
print(MatAdd(A, B, evaluate=False))

This gives

Matrix([[0]]) + Matrix([[1]])

I want to be able to control the order in which the Matrices appear.
What algorithm is Sympy using to sort the output? I guess it is
looking at the Matrix contents? Do you have any suggestions for
controlling the order?

Thanks for any suggestions,

Matthew

Matthew Brett

unread,
May 26, 2022, 6:35:14 AM5/26/22
to sympy
Hi,
Just for reference, I have also just asked this question on StackOverflow:

https://stackoverflow.com/questions/72390408/control-print-order-of-matrix-terms-in-sympy

Cheers,

Matthew
Reply all
Reply to author
Forward
0 new messages