Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )
- For vector:
point value by seeking out a
* corresponds to multiplication by multiplying each element
may benp.dot(u,v)
, it may be written asu.dot(v)
Caution: the * operator will perform an elementwise multiplication, NOT a dot product:
- For matrix:
A.dot(B)
, Denotes the matrix multiplication, a matrix is obtained. (Row vector A
column vector of B and
, respectively, do dot dot, end up with a matrix
. )
A*B
Represents a multiplication element,
Caution: NumPy’s * operator performs elementwise multiplication, NOT a matrix multiplication
Point multiply and multiply * the meaning and role of unity.
- * Take boardcasting trigger mechanism of python
‘
import numpy as np
a = np.array([1,2,3])
b = np.array([2])
print(a*b)
[2 4 6]
c = np.array([1,2,3,4])
print(a*c)
Traceback (most recent call last):File "<stdin>", line 1, in <module>ValueError: operands could not be broadcast together with shapes (3,) (4,)