Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import time
- def readMatrixFile(FileName):
- rows,cols=np.fromfile(FileName, dtype=int, count=2, sep=",")
- a = np.fromfile(FileName, dtype=float, count=rows*cols, sep=" ").reshape((rows,cols))
- return a
- t1 = time.time()
- vetIN = readMatrixFile('1000000.txt')
- vet2 = np.zeros(max(vetIN)+1)
- for i in vetIN:
- vet2[i] = vet2[i] + 1
- for i in range(len(vet2)-1):
- vet2[i+1] = vet2[i+1] + vet2[i]
- vetOut = np.zeros(len(vetIN)+1)
- for i in range(len(vetIN)):
- vetOut[int(vet2[vetIN[i]])] = vetIN[i]
- vet2[vetIN[i]] -= 1
- t2 = time.time();
- print vetOut
- print "Tempo: " + str(t2-t1);
Add Comment
Please, Sign In to add comment