Python C extension to compute the permanent.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

36 行
882B

  1. import os
  2. import time
  3. import multiprocessing as mp
  4. import numpy as np
  5. import lib
  6. def test_fn(perm_fn, name, dimension=6, steps=1000, dt=1e-3, bodies=101, threads=1):
  7. # Test the speed of the evolution function.
  8. sreal=np.random.uniform(0,1,(dimension, dimension))
  9. scomp=np.random.uniform(0,1,(dimension, dimension))
  10. submatrix=sreal+1j*scomp
  11. t0 = time.time()
  12. for i in range(steps):
  13. p=perm_fn(submatrix)
  14. t1 = time.time()
  15. print "{0} ({1}): {2} steps/sec".format(name, threads, int(steps / (t1 - t0)))
  16. if __name__ == "__main__":
  17. d=4
  18. steps=1000
  19. # Test on one core
  20. test_fn(lib.perm_python, "1 core, C", steps=steps, threads=1)
  21. # Test on one core
  22. test_fn(lib.perm_c, "1 core, C", steps=steps, threads=1)
  23. # Test on four cores
  24. test_fn(lib.perm_c, "All cores, C", steps=steps/threads, threads=threads)