Complete the code to import the sparse matrix module from scipy.
from scipy import [1]
The scipy.sparse module provides tools for sparse matrix operations.
Complete the code to create a CSR sparse matrix from data, rows, and columns arrays.
from scipy.sparse import csr_matrix matrix = csr_matrix((data, (rows, [1])))
The CSR matrix constructor takes a tuple with data and a tuple of (row indices, column indices).
Fix the error in the code to perform LU factorization on a sparse matrix.
from scipy.sparse.linalg import [1] lu = [1](matrix)
lu_factor which does not support sparse matrices.spsolve which solves linear systems but does not factorize.The correct function for LU factorization of sparse matrices is splu.
Fill both blanks to compute the LU factorization of a sparse matrix and solve a system.
from scipy.sparse.linalg import [1] lu = [1](matrix) result = lu.[2](b)
cholesky instead of splu for sparse factorization.solve.The splu function computes the LU factorization, and the solve method solves the system.
Fill all three blanks to create a sparse identity matrix, convert it to CSC format, and perform LU factorization.
from scipy.sparse import identity from scipy.sparse.linalg import [1] I = identity(5).[2]() lu = [3](I)
csr_matrix instead of converting to CSC.We use identity to create the matrix, convert it to CSC format with tocsc(), and factorize with splu.