4 ms·
What's wrong with: >>> import numpy as np >>> m = np.array([[0,1,0],[0,0,1],[1,0,0]]) >>> v = np.array([2,3,1]) >>> np.linalg.solve(m,v) a
by messe 10y ago
What's wrong with:
>>> import numpy as np
>>> m = np.array([[0,1,0],[0,0,1],[1,0,0]])
>>> v = np.array([2,3,1])
>>> np.linalg.solve(m,v)
array([ 1., 2., 3.])
No need to transpose, as numpy handles row and column vectors identically. Using the above variables `m` and `v`:
>>> v @ m # treated as row vector
array([1, 2, 3])
>>> m @ v # treated as column vector
array([3, 1, 2])
Where `@`, for those who don't know, is the matrix multiplication operator (`np.dot`) introduced in recent versions of python 3.
- noobermin 10y agoSounds like a case of familiarity being confused for ease of use.
- TheSpiceIsLife 10y agoWhat's wrong with .... introduced in recent versions of python 3. Exactly.
- foota 10y agoPython3 is ancient, can we stop pretending otherwise?
- TAForObvReasons 10y agoPEP 465 introduced the infix operator @: https://www.python.org/dev/peps/pep-0465/ https://www.python.org/dev/peps/pep-0465/ Python 3.5 was the first version of python3 to implement the PEP: https://docs.python.org/3.5/whatsnew/3.5.html https://docs.python.org/3.5/whatsnew/3.5.html If I am reading the release notes correctly, Python 3.5.0 was released last year (2015-09-13): https://www.python.org/downloads/release/python-350/ https://www.python.org/downloads/release/python-350/ It's fair to say that this is a relatively new development.
- foota 10y agoIt's true that infix multiply is new, but infix multiply if I'm not mistaken is not a breaking change.
- TheSpiceIsLife 10y agoTrue. I mean in the context as @sampo described it above ... In the Stanford/Coursera machine learning class, Andrew Ng said that his teaching experience is that students pick up octave/matlab quicker and the course can cover more actual machine learning, compared to python where more time is spent learning the language. Then "which version of Python, and how is that different..." etc.
- jjawssd 10y agoCode targeting Python 3.2 which was released five years code is still compatible with the latest versions of Python 3. What is the issue exactly?
- collinmanderson 10y agoThere are still hundreds of projects that need to get ported to 3.x. http://portingdb.xyz http://portingdb.xyz
- collinmanderson 10y agoThat link above seems to have broken. Here's an alternative link: https://portingdb-encukou.rhcloud.com/ https://portingdb-encukou.rhcloud.com/