(tripleA, tripleB)
| 13 | return triple |
| 14 | |
| 15 | def multiTriple(tripleA, tripleB): |
| 16 | rowA = shape(tripleA)[0] |
| 17 | rowB = shape(tripleB)[0] |
| 18 | multiMatrix = [] |
| 19 | for i in range(rowA): |
| 20 | for j in range(rowB): |
| 21 | if tripleA[i][1] == tripleB[j][0]: |
| 22 | multiMatrix.append([tripleA[i][0], tripleB[j][1], tripleA[i][2]*tripleB[j][2]]) |
| 23 | return multiMatrix |
| 24 | |
| 25 | def tripleToSparse(triple, m, n): |
| 26 | outMatrix = zeros([m, n]) |