Problem 4: Expanded Knowledge
Transpose \( B_{ji} = A_{ij} \)
import numpy as np
a = np.arange(0, 9).reshape(3, 3)
b = np.einsum('ij->ji', a)
Full Sum \( \sum_i \sum_j A_{ij} \)
import numpy as np
a = np.arange(0, 9).reshape(3, 3)
b = np.einsum('ij->', a)
Row-wise Sum \( \sum_j A_{ij} \)
import numpy as np
a = np.arange(0, 9).reshape(3, 3)
b = np.einsum('ij->i', a)
Elementwise (Hadamard-style) \( C_{ij} = A_{ij} B_j \)
import numpy as np
a = np.arange(0, 12).reshape(3, 4)
b = np.arange(0, 4)
c = np.einsum('ij,j->ij', a, b)