Guest User

Untitled

a guest
Jul 21st, 2023
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. @numba.jit(nopython=True, fastmath=True, boundscheck=False, parallel=False)
  2. def abs_argmax2(re, im):
  3.     N = re.shape[0]
  4.     i = 0
  5.     max_idx = 0
  6.     current_max = 0
  7.     current_abs2 = 0
  8.  
  9.     # main loop
  10.     while i < N:
  11.         current_abs2 = re[i]**2 + im[i]**2
  12.         if current_abs2 > current_max:
  13.             max_idx = i
  14.             current_max = current_abs2
  15.         i += 1
  16.     return max_idx
Advertisement
Add Comment
Please, Sign In to add comment