MCPcopy Create free account
hub / github.com/Jack-Lee-Hiter/AlgorithmsByPython / sparseToTriple

Function sparseToTriple

Target Offer/transSparseMatrix.py:8–15  ·  view source on GitHub ↗
(matrix)

Source from the content-addressed store, hash-verified

6'''
7from numpy import *
8def sparseToTriple(matrix):
9 m, n = shape(matrix)
10 triple = []
11 for i in range(m):
12 for j in range(n):
13 if matrix[i][j] != 0:
14 triple.append([i, j, matrix[i][j]])
15 return triple
16
17def transTriple(triple):
18 m, n = shape(triple)

Callers 1

matrixTransFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected