fork download
  1. import numpy as np
  2.  
  3. # (3,) · (3, 2) -> (2,)
  4. vec = np.array([1.0, 1.0, 1.0])
  5. mat = np.array([[1.0, 2.0],
  6. [3.0, 4.0],
  7. [5.0, 6.0]])
  8.  
  9. vec_mat_result = np.dot(vec, mat)
  10. print(vec_mat_result.shape)
  11. print(vec_mat_result)
  12.  
  13. # (2, 3) · (3,) -> (2,)
  14. matrix = np.array([[1.0, 2.0, 3.0],
  15. [4.0, 5.0, 6.0]])
  16. vector = np.array([1.0, 1.0, 1.0])
  17.  
  18. mat_vec_result = np.dot(matrix, vector)
  19. print(mat_vec_result.shape)
  20. print(mat_vec_result)
  21.  
Success #stdin #stdout 0.1s 23544KB
stdin
Standard input is empty
stdout
(2,)
[ 9. 12.]
(2,)
[ 6. 15.]