dhermes / butterfly-algorithm

Apache License 2.0
0 stars 0 forks source link

Speed up the O(N) parts of the code #1

Open dhermes opened 9 years ago

dhermes commented 9 years ago

Using custom timing around the L refinement stages, we see the O(N) coefficient creation (putting s in bins) and coefficient application (putting t in bins) dominates:

$ ./butterfly_on_whale.py --M=50 --L=10
N = 8192 points, M = 50 truncated terms, L = 10 refinements
N log N portion duration: 0.294004
total computation time: 0.852146
2-norm: 3.93279e-08
sup-norm: 6.13895e-09
dhermes commented 9 years ago

As of 76ba2518477d37d08ccbdac3de72053d4a6e3613

--- butterfly_algorithm.py  2015-02-17 22:48:16.833886489 -0800
+++ butterfly_algorithm.py  2015-02-17 22:48:55.901887121 -0800
@@ -1,5 +1,6 @@
 import numpy as np
 from itertools import izip
+import time

 def compute_f_hat(f, t, s, kernel_func):
@@ -225,6 +226,7 @@
     A2_minus = A2(M, -delta_S)
     A2_plus = A2(M, delta_S)

+    start = time.time()
     for ell in xrange(1, L + 1):
         update_func = make_update_func(A1_minus, A1_plus, A2_minus,
                                        A2_plus, delta_T)
@@ -239,5 +241,7 @@
         A_update(A1_minus, scale_multiplier=0.5, upper_diags=True)
         A_update(A2_plus, scale_multiplier=2.0, upper_diags=False)
         A_update(A2_minus, scale_multiplier=2.0, upper_diags=False)
+    duration = time.time() - start
+    print 'N log N portion duration: %g' % (duration,)

     return compute_t_by_bins(t, coeff_vals, L)