r/Python • • Aug 05 '19

Python's response to MATLAB

Post image
4.3k Upvotes

372 comments sorted by

View all comments

Show parent comments

4

u/mexiKobe Aug 06 '19 edited Aug 06 '19

Tensor operations are very easy with MATLAB. It’s just like any other matrix operation. I have no idea where you got this idea that you had to loop when N>2.

0

u/[deleted] Aug 06 '19

[deleted]

1

u/mexiKobe Aug 06 '19 edited Aug 06 '19

did you try using repmat in the first example on V or something like that? and your 2nd example can almost certainly be vectorized from glancing at it

https://www.mathworks.com/help/matlab/matlab_prog/vectorization.html

You should also look into bsxfun

0

u/[deleted] Aug 06 '19

[deleted]

1

u/mexiKobe Aug 06 '19

Do you remember the numpy code?