Hive's ML inference pipelines may process large, mostly empty feature matrices. Given two sparse matrices in canonical coordinate-list format, return their element-wise sum without converting either matrix to a dense representation.
Each nonzero entry is represented as [row, column, value]. Entries within each matrix are sorted lexicographically by (row, column), and no coordinate appears more than once in the same matrix. The matrices have identical dimensions, although their dimensions are not provided because only stored entries are needed.
Implement sparse_matrix_sum(matrix_a, matrix_b).
matrix_a and matrix_b, lists of integer triples [row, column, value].matrix_a + matrix_b, sorted lexicographically by row and column.def sparse_matrix_sum(matrix_a, matrix_b):