inner product & outer product; 向量的內外積
np.inner() np.outer()向量的內外積
Example Code
- import numpy as np
- vectorA = [1,2,3]
- vectorB = [0,5,10]
- print('vectorA = ', vectorA)
- print('vectorB = ', vectorB)
- print('vectorA adds vectorB = ', np.add(vectorA,vectorB))
- print('wraning!! "+" sign will combine two vectors')
- print('vectorA + vector = ', vectorA+vectorB)
- print('vectorA subtracts vectorB = ', np.subtract(vectorA,vectorB))
Note and Comments
- import numpy as np: 讀入numpy函式庫並命名為np
- np.add(A, B): 相加A,B兩向量
- np.subtract(A, B): 相減A,B兩向量
result