Merge pull request #25 from joeyfreund/patch-1

Add alternative solution using matrix multiplication operator
This commit is contained in:
Nicolas P. Rougier 2016-10-01 19:12:11 +02:00 committed by GitHub
commit 44b5e1e940
2 changed files with 8 additions and 1 deletions

View File

@ -477,7 +477,10 @@
"outputs": [],
"source": [
"Z = np.dot(np.ones((5,3)), np.ones((3,2)))\n",
"print(Z)"
"print(Z)",
"\n\n",
"# Alternative solution, in Python 3.5 and above\n",
"Z = np.ones((5,3)) @ np.ones((3,2))"
]
},
{

View File

@ -208,6 +208,10 @@ color = np.dtype([("r", np.ubyte, 1),
```python
Z = np.dot(np.ones((5,3)), np.ones((3,2)))
print(Z)
# Alternative solution, in Python 3.5 and above
Z = np.ones((5,3)) @ np.ones((3,2))
print(Z)
```
#### 25. Given a 1D array, negate all elements which are between 3 and 8, in place. (★☆☆)