SciPy - Sparse Linear Algebra
Identify the error in the following code that attempts to create a Jacobi preconditioner:
import numpy as np
from scipy.sparse.linalg import LinearOperator
A = np.array([[3, 1], [1, 4]])
M = LinearOperator(shape=A.shape, matvec=lambda x: np.diag(A) * x)
print(M.matvec(np.array([1, 2])))
