In [1]:
import numpy as np

In [2]:
a = b = np.arange(3)
print(a)


[0 1 2]

In [3]:
print(a.shape)


(3,)

In [4]:
print(a * b)


[0 1 4]

In [5]:
print(np.multiply(a, b))


[0 1 4]

In [6]:
a_1_3 = a.reshape(1, 3)
print(a_1_3)


[[0 1 2]]

In [7]:
print(a_1_3.shape)


(1, 3)

In [8]:
b_3_1 = b.reshape(3, 1)
print(b_3_1)


[[0]
 [1]
 [2]]

In [9]:
print(b_3_1.shape)


(3, 1)

In [10]:
print(a_1_3 * b_3_1)


[[0 0 0]
 [0 1 2]
 [0 2 4]]

In [11]:
print(np.multiply(a_1_3, b_3_1))


[[0 0 0]
 [0 1 2]
 [0 2 4]]

In [12]:
print(a * b_3_1)


[[0 0 0]
 [0 1 2]
 [0 2 4]]

In [13]:
print(np.multiply(a, b_3_1))


[[0 0 0]
 [0 1 2]
 [0 2 4]]

In [14]:
print(a_1_3 @ b_3_1)


[[5]]

In [15]:
print(np.matmul(a_1_3, b_3_1))


[[5]]

In [16]:
print(np.dot(a_1_3, b_3_1))


[[5]]

In [17]:
print(type(a_1_3 @ b_3_1))


<class 'numpy.ndarray'>

In [18]:
print((a_1_3 @ b_3_1).shape)


(1, 1)

In [19]:
print(a_1_3 @ b)


[5]

In [20]:
print(np.matmul(a_1_3, b))


[5]

In [21]:
print(np.dot(a_1_3, b))


[5]

In [22]:
print(type(a_1_3 @ b))


<class 'numpy.ndarray'>

In [23]:
print((a_1_3 @ b).shape)


(1,)

In [24]:
print(a @ b)


5

In [25]:
print(np.matmul(a, b))


5

In [26]:
print(np.dot(a, b))


5

In [27]:
print(type(a @ b))


<class 'numpy.int64'>

In [28]:
a = np.arange(6).reshape(2, 3)
print(a)


[[0 1 2]
 [3 4 5]]

In [29]:
b = np.arange(2).reshape(1, 2)
print(b)


[[0 1]]

In [30]:
# print(a @ b)
# ValueError: shapes (2,3) and (1,2) not aligned: 3 (dim 1) != 1 (dim 0)

In [31]:
print(np.tile(b, (3, 1)))


[[0 1]
 [0 1]
 [0 1]]

In [32]:
print(a @ np.tile(b, (3, 1)))


[[ 0  3]
 [ 0 12]]