import numpy as np
from scipy.sparse import csc_matrix, csr_matrix
# Create CSC matrix
row_A = np.array([0, 0, 1, 2])
col_A = np.array([0, 1, 0, 1])
data_A = np.array([4, 3, 8, 9])
csc_A = csc_matrix((data_A, (row_A, col_A)), shape=(3, 3))
print("CSC matrix:\n", csc_A.toarray())
# Create CSR matrix
row_B = np.array([0, 1, 1, 2])
col_B = np.array([0, 0, 1, 0])
data_B = np.array([7, 2, 5, 1])
csr_B = csr_matrix((data_B, (row_B, col_B)), shape=(3, 3))
print("CSR matrix:\n", csr_B.toarray())
# Multiply CSC with CSR
result1 = csc_A.multiply(csr_B)
print("Element-wise Product (CSC x CSR):\n", result1.toarray())
# Multiply CSR with CSC
result2 = csr_B.multiply(csc_A)
print("Element-wise Product (CSR x CSC):\n", result2.toarray())