Hacker News new | past | comments | ask | show | jobs | submit login

Both languages allow for incompatible arrays to be operated on in this manner though, just because it fails in numpy just means that numpy hasn't implemented that type of broadcasting. For instance, this operation:

np.array([1,2]) + np.array([[1],[2]])

is not broadly defined and understood in pure mathematics. Looking at it, it's not immediately obvious what it would do. You are adding a (1,2) matrix to a (2,1) matrix. It turns out, numpy extends the rules of matrix multiplication to matrix addition through the rule of broadcasting.

R is just doing the same thing, in a different way. These types of implementations are common in scientific computing because it creates easy ways to do these operations, programming robustness and rigidity be damned.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: