![]() | NumPy has an array type, matrix, much like Matlab's array type
>>> x1 = array([1, 2, 3], float) >>> x2 = matrix(x1) # or just mat(x) >>> x2 # row vector matrix([[ 1., 2., 3.]]) >>> x3 = matrix(x1.transpose() # column vector >>> x3 matrix([[ 1.], [ 2.], [ 3.]]) >>> type(x3) <class 'numpy.core.defmatrix.matrix'> >>> isinstance(x3, matrix) True |
![]() | Only 1- and 2-dimensional arrays can be matrix |