Comment #27 on issue 884 by smi...@gmail.com: One line matrix and one
column matrix confusion
http://code.google.com/p/sympy/issues/detail?id=884
n.matrix(1,2)
TypeError: data type not understood
n.matrix([1,2]) # row vector
matrix([[1, 2]])
n.matrix([[1],[2]]) #column vector
matrix([[1],
[2]])
n.matrix([1,2],[3,4])
TypeError: data type not understood
n.matrix([[1,2],[3,4]])
matrix([[1, 2],
[3, 4]])
Matrix(1,2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy\matrices\matrices.py", line 160, in __init__
raise TypeError("Data type not understood")
TypeError: Data type not understood
SparseMatrix(1,2)
[1]
[2]
Matrix([1,2,3])
[1]
[2]
[3]
Matrix([[1,2,3]])
[1, 2, 3]
Matrix([1,2,3],[4,5,6])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sympy\matrices\matrices.py", line 160, in __init__
raise TypeError("Data type not understood")
TypeError: Data type not understood
Matrix([[1,2,3],[4,5,6]])
[1, 2, 3]
[4, 5, 6]
So (presently, except for SparseMatrix) we have an inconsistent
interpretation of ([1,2,3]): sympy gives a column vector and numpy a row
vector. But (unfortunately) numpy interprets ([[1,2,3]]) as a row vector,
too. So if numpy would fix their ([1,2,3]) case to give a column vector and
we allowed (1,2,3) to be a column vector then we could say that the syntax
for sympy's Matrix is just one level of [] less than numpy.
My proposal:
M(1,2,3) -> column vector (or M([1],[2],[3]) )
M([1,2,3]) -> row vector
M([1,2],[3,4]) -> square matrix
--
You received this message because you are subscribed to the Google Groups
"sympy-patches" group.
To post to this group, send email to sympy-patches@googlegroups.com.
To unsubscribe from this group, send email to
sympy-patches+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/sympy-patches?hl=en.