Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- a = [[1,0,0],[0,1,0],[0,0,1]]
- b = [1,1,1]
- c = numpy.diag(b)
- numpy.dot(c,a)
- #I'm having issues with getting them to work more than once, often they fail, but these should be correct.
- import numpy as np
- a = np.array([[1,0,0],[0,1,0],[0,0,1]])
- b = np.array([1,1,1])
- a * b[:, np.newaxis]
- array([[ 1, 0, 0],
- [ 0, 1, 0],
- [ 0, 0, 1]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement