Skip to content

Instantly share code, notes, and snippets.

@davidwhogg
Created April 25, 2014 01:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidwhogg/11275291 to your computer and use it in GitHub Desktop.
Save davidwhogg/11275291 to your computer and use it in GitHub Desktop.
import numpy as np
import time as tt
def main():
timing = np.array([])
log2N = np.arange(6) + 8
for N in 2 ** log2N:
uu = np.random.normal(size=(N, N+2))
matrix = np.dot(uu, uu.T)
print matrix.shape
vector = np.random.normal(size=N)
print "start %d" % N
t1 = tt.time()
np.linalg.solve(matrix, vector)
timing = np.append(timing, [tt.time() - t1,])
print "end %d" % N
print timing
print np.polyfit(log2N, np.log(timing)/np.log(2.), 1)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment