Project 8: RSVP Matrix Builder
Scientific Computing
Builds on these lessons
Current Task
Objective
A sparse matrix can also be built directly from (data, (row, col)) coordinates, without ever materializing the full dense array.
Task: build a 3x3 sparse RSVP matrix from coordinate data and print it as a dense array with .toarray().
index.py
from scipy.sparse import csr_matrix
import numpy as np
data = np.array([1, 2, 3])
row = np.array([0, 1, 2])
col = np.array([0, 1, 2])
rsvp_matrix = csr_matrix((data, (row, col)), shape=(3, 3))
print(rsvp_matrix.toarray())
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview