Advertisement
JoelSjogren

Untitled

Nov 15th, 2020
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. box% python
  2. Python 3.8.6 (default, Sep 30 2020, 04:00:38)
  3. [GCC 10.2.0] on linux
  4. Type "help", "copyright", "credits" or "license" for more information.
  5. >>> import numpy as np
  6. >>> e_0 = np.array([1,0,0,0])
  7. >>> e_1 = np.array([0,1,0,0])
  8. >>> e_2 = np.array([0,0,1,0])
  9. >>> e_3 = np.array([0,0,0,1])
  10. >>> np.einsum('a,b->ab', e_0, e_1)
  11. array([[0, 1, 0, 0],
  12. [0, 0, 0, 0],
  13. [0, 0, 0, 0],
  14. [0, 0, 0, 0]])
  15. >>> np.einsum('a,b,c->abc', e_0, e_1, e_2)
  16. array([[[0, 0, 0, 0],
  17. [0, 0, 1, 0],
  18. [0, 0, 0, 0],
  19. [0, 0, 0, 0]],
  20.  
  21. [[0, 0, 0, 0],
  22. [0, 0, 0, 0],
  23. [0, 0, 0, 0],
  24. [0, 0, 0, 0]],
  25.  
  26. [[0, 0, 0, 0],
  27. [0, 0, 0, 0],
  28. [0, 0, 0, 0],
  29. [0, 0, 0, 0]],
  30.  
  31. [[0, 0, 0, 0],
  32. [0, 0, 0, 0],
  33. [0, 0, 0, 0],
  34. [0, 0, 0, 0]]])
  35. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement