Advertisement
UF6

Problem 7 Final

UF6
May 8th, 2016
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.37 KB | None | 0 0
  1. import numpy as np
  2. a = [[1,0,0],[0,1,0],[0,0,1]]
  3. b = [1,1,1]
  4. c = numpy.diag(b)
  5.  
  6. numpy.dot(c,a)
  7.  
  8. #I'm having issues with getting them to work more than once, often they fail, but these should be correct.
  9. import numpy as np
  10. a = np.array([[1,0,0],[0,1,0],[0,0,1]])
  11. b = np.array([1,1,1])
  12. a * b[:, np.newaxis]
  13. array([[ 1,  0,  0],
  14.        [ 0,  1, 0],
  15.        [ 0,  0, 1]])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement