In [1]:
import numpy as np

We compute the matrix multiplication

$$ \begin{bmatrix} 0 & 1 & 0 \\ 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \\ 3 \end{bmatrix}. $$

The dimensions are $(2 \times 3)(3 \times 1)$, so the result is a $(2 \times 1)$ vector.

First row: $$ 0\cdot 1 + 1\cdot 2 + 0\cdot 3 = 2. $$

Second row: $$ 0\cdot 1 + 0\cdot 2 + 1\cdot 3 = 3. $$

Therefore,

$$ \begin{bmatrix} 2 \\ 3 \end{bmatrix}. $$

In [2]:
X = np.array([[0, 1, 0], [0, 0, 1]])
X, X.shape
Out[2]:
(array([[0, 1, 0],
        [0, 0, 1]]),
 (2, 3))
In [3]:
w = np.array([1,2,3])[:, None]
In [4]:
X @ w, (X @ w).shape
Out[4]:
(array([[2],
        [3]]),
 (2, 1))
In [5]:
X + 10 
Out[5]:
array([[10, 11, 10],
       [10, 10, 11]])
In [6]:
X + 10 * np.ones_like(X)
Out[6]:
array([[10, 11, 10],
       [10, 10, 11]])
In [ ]:
 
In [7]:
A = np.array([[1,2,3],[4,5,6]])
b = np.array([10, 20, 30])
A, b
Out[7]:
(array([[1, 2, 3],
        [4, 5, 6]]),
 array([10, 20, 30]))
In [8]:
A.shape, b.shape
Out[8]:
((2, 3), (3,))
In [9]:
b[None, :].shape
Out[9]:
(1, 3)
In [10]:
b[None, :] + A
Out[10]:
array([[11, 22, 33],
       [14, 25, 36]])