(triple)
| 15 | return triple |
| 16 | |
| 17 | def transTriple(triple): |
| 18 | m, n = shape(triple) |
| 19 | transMatrix = [] |
| 20 | sortedIndex = array([m[1] for m in triple]).argsort() |
| 21 | for i in range(m): |
| 22 | tempArray = triple[sortedIndex[i]] |
| 23 | transMatrix.append([tempArray[1], tempArray[0], tempArray[2]]) |
| 24 | return transMatrix |
| 25 | |
| 26 | def tripleToSparse(triple, m, n): |
| 27 | outMatrix = zeros([n, m]) |