We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When substituting a MatrixSymbol in a Matrix, only the first Matrix component is changed.
MatrixSymbol
Matrix
MVCE:
import sympy a = sympy.MatrixSymbol('a', 2, 1) A = sympy.Matrix([[a[0], a[1]**2]]) a_vals = [1.0, 2.0] print(A.subs(zip(a, a_vals)))
Output:
Matrix([[1.00000000000000, a[1, 0]**2]])
Expected output:
Matrix([[1.00000000000000, 4.00000000000000]])
The text was updated successfully, but these errors were encountered:
It seems the conversion to dict, from our mailing list discussion, is needed sometimes.
>>> print(A.subs(dict(zip(a, a_vals)))) Matrix([[1.00000000000000, 4.00000000000000]])
Same for a tuple or list of tuples.
>>> print(A.subs(tuple(zip(a, a_vals)))) Matrix([[1.00000000000000, 4.00000000000000]]) >>> print(A.subs(list(zip(a, a_vals)))) Matrix([[1.00000000000000, 4.00000000000000]])
But I see no reason why passing an iterator to subs shouldn't work in this specific setup, so looks like a bug.
Sorry, something went wrong.
See also #13330
No branches or pull requests
When substituting a
MatrixSymbol
in aMatrix
, only the firstMatrix
component is changed.MVCE:
Output:
Expected output:
The text was updated successfully, but these errors were encountered: