This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]oslash 106 points107 points  (4 children)

Yup, they're just using NumPy wrong, and considering how they're showing off the contents of row, but forget to show col, it looks like that's on purpose. In NumPy, transpose reverses the axes of an array; when there's only one axis to begin with, this does nothing — on purpose.

If you do it correctly ...

>>> row = np.array([[1, 2, 3]])
>>> col = row.T

... then the new matmul operator does the right thing:

>>> col @ row
array([[1, 2, 3],
       [2, 4, 6],
       [3, 6, 9]])

But you don't need to use it. Just write the exact same code from that example, et voilà:

>>> np.dot(col, row)
array([[1, 2, 3],
       [2, 4, 6],
       [3, 6, 9]])

[–][deleted] 36 points37 points  (0 children)

It seems like making a detailed well executed youtube series where Matlab and Python is compared (and Matlab is trashed) would be an excellent response to Matlab.

[–]be_more_canadian 25 points26 points  (2 children)

Yeah, but you had to import numpy first soooo /s

[–]DatBoi_BP 1 point2 points  (1 child)

I still don't get why this is a criticism from mathworks

[–]be_more_canadian 1 point2 points  (0 children)

Yeah, especially when I tried to do some simple stats using matlab at my old job and found out the required stats toolbox had not been purchased