(matrix)
| 4 | |
| 5 | from numpy import * |
| 6 | def sparseToTriple(matrix): |
| 7 | m, n = shape(matrix) |
| 8 | triple = [] |
| 9 | for i in range(m): |
| 10 | for j in range(n): |
| 11 | if matrix[i][j] != 0: |
| 12 | triple.append([i, j, matrix[i][j]]) |
| 13 | return triple |
| 14 | |
| 15 | def multiTriple(tripleA, tripleB): |
| 16 | rowA = shape(tripleA)[0] |