# Path: blond/utils/butils_wrap.py
# class Precision:
# class c_complex128(ct.Structure):
# class c_complex64(ct.Structure):
#     def __init__(self, precision='double'):
# def __getPointer(x):
# def __getLen(x):
# def __c_real(x):
#     def __init__(self, pycomplex):
#     def to_complex(self):
#     def __init__(self, pycomplex):
#     def to_complex(self):
# def where(x, more_than=None, less_than=None, result=None):
# def add(a, b, result=None, inplace=False):
# def mul(a, b, result=None):
# def argmin(x):
# def argmax(x):
# def linspace(start, stop, num=50, retstep=False, result=None):
# def arange(start, stop, step, dtype=float, result=None):
# def sum(x):
# def sort(x, reverse=False):
# def convolve(signal, kernel, mode='full', result=None):
# def mean(x):
# def std(x):
# def sin(x, result=None):
# def cos(x, result=None):
# def exp(x, result=None):
# def interp(x, xp, yp, left=None, right=None, result=None):
# def interp_const_space(x, xp, yp, left=None, right=None, result=None):
# def rfft(a, n=0, result=None):
# def irfft(a, n=0, result=None):
# def rfftfreq(n, d=1.0, result=None):
# def irfft_packed(signal, fftsize=0, result=None):
# def cumtrapz(y, x=None, dx=1.0, initial=None, result=None):
# def trapz(y, x=None, dx=1.0):
# def beam_phase(bin_centers, profile, alpha, omegarf, phirf, bin_size):
# def rf_volt_comp(voltages, omega_rf, phi_rf, bin_centers):
# def kick(dt, dE, voltage, omega_rf, phi_rf, charge, n_rf, acceleration_kick):
# def drift(dt, dE, solver, t_rev, length_ratio, alpha_order, eta_0,
#           eta_1, eta_2, alpha_0, alpha_1, alpha_2, beta, energy):
# def linear_interp_kick(dt, dE, voltage,
#                        bin_centers, charge,
#                        acceleration_kick):
# def linear_interp_kick_n_drift(dt, dE, total_voltage, bin_centers, charge, acc_kick,
#                                solver, t_rev, length_ratio, alpha_order, eta_0, eta_1,
#                                eta_2, beta, energy):
# def slice(dt, profile, cut_left, cut_right):
# def slice_smooth(dt, profile, cut_left, cut_right):
# def sparse_histogram(dt, profile, cut_left, cut_right, bunch_indexes, n_slices_bucket):
# def music_track(dt, dE, induced_voltage, array_parameters,
#                 alpha, omega_bar,
#                 const, coeff1, coeff2, coeff3, coeff4):
# def music_track_multiturn(dt, dE, induced_voltage, array_parameters,
#                           alpha, omega_bar,
#                           const, coeff1, coeff2, coeff3, coeff4):
# def synchrotron_radiation(dE, U0, n_kicks, tau_z):
# def synchrotron_radiation_full(dE, U0, n_kicks, tau_z, sigma_dE, energy):
# def set_random_seed(seed):
# def fast_resonator(R_S, Q, frequency_array, frequency_R, impedance=None):
#     R_S = R_S.astype(dtype=precision.real_t, order='C', copy=False)
#     Q = Q.astype(dtype=precision.real_t, order='C', copy=False)


import numpy as np
from ..utils import butils_wrap
'''
BLonD math and physics core functions

@author Stefan Hegglin, Konstantinos Iliakis
@date 20.10.2017
'''
# from functools import wraps
# from ..utils import bphysics_wrap

precision = butils_wrap.precision
__exec_mode = 'single_node'
# Other modes: multi_node

# dictionary storing the CPU versions of the desired functions #
_CPU_func_dict = {
    'rfft': np.fft.rfft,
    'irfft': np.fft.irfft,
    'rfftfreq': np.fft.rfftfreq,
    'irfft_packed': butils_wrap.irfft_packed,
    'sin': butils_wrap.sin,
    'cos': butils_wrap.cos,
    'exp': butils_wrap.exp,
    'mean': butils_wrap.mean,
    'std': butils_wrap.std,
    'where': butils_wrap.where,
    'interp': butils_wrap.interp,
    'interp_const_space': butils_wrap.interp_const_space,

# Path: blond/utils/butils_wrap.py
# class Precision:
# class c_complex128(ct.Structure):
# class c_complex64(ct.Structure):
#     def __init__(self, precision='double'):
# def __getPointer(x):
# def __getLen(x):
# def __c_real(x):
#     def __init__(self, pycomplex):
#     def to_complex(self):
#     def __init__(self, pycomplex):
#     def to_complex(self):
# def where(x, more_than=None, less_than=None, result=None):
# def add(a, b, result=None, inplace=False):
# def mul(a, b, result=None):
# def argmin(x):
# def argmax(x):
# def linspace(start, stop, num=50, retstep=False, result=None):
# def arange(start, stop, step, dtype=float, result=None):
# def sum(x):
# def sort(x, reverse=False):
# def convolve(signal, kernel, mode='full', result=None):
# def mean(x):
# def std(x):
# def sin(x, result=None):
# def cos(x, result=None):
# def exp(x, result=None):
# def interp(x, xp, yp, left=None, right=None, result=None):
# def interp_const_space(x, xp, yp, left=None, right=None, result=None):
# def rfft(a, n=0, result=None):
# def irfft(a, n=0, result=None):
# def rfftfreq(n, d=1.0, result=None):
# def irfft_packed(signal, fftsize=0, result=None):
# def cumtrapz(y, x=None, dx=1.0, initial=None, result=None):
# def trapz(y, x=None, dx=1.0):
# def beam_phase(bin_centers, profile, alpha, omegarf, phirf, bin_size):
# def rf_volt_comp(voltages, omega_rf, phi_rf, bin_centers):
# def kick(dt, dE, voltage, omega_rf, phi_rf, charge, n_rf, acceleration_kick):
# def drift(dt, dE, solver, t_rev, length_ratio, alpha_order, eta_0,
#           eta_1, eta_2, alpha_0, alpha_1, alpha_2, beta, energy):
# def linear_interp_kick(dt, dE, voltage,
#                        bin_centers, charge,
#                        acceleration_kick):
# def linear_interp_kick_n_drift(dt, dE, total_voltage, bin_centers, charge, acc_kick,
#                                solver, t_rev, length_ratio, alpha_order, eta_0, eta_1,
#                                eta_2, beta, energy):
# def slice(dt, profile, cut_left, cut_right):
# def slice_smooth(dt, profile, cut_left, cut_right):
# def sparse_histogram(dt, profile, cut_left, cut_right, bunch_indexes, n_slices_bucket):
# def music_track(dt, dE, induced_voltage, array_parameters,
#                 alpha, omega_bar,
#                 const, coeff1, coeff2, coeff3, coeff4):
# def music_track_multiturn(dt, dE, induced_voltage, array_parameters,
#                           alpha, omega_bar,
#                           const, coeff1, coeff2, coeff3, coeff4):
# def synchrotron_radiation(dE, U0, n_kicks, tau_z):
# def synchrotron_radiation_full(dE, U0, n_kicks, tau_z, sigma_dE, energy):
# def set_random_seed(seed):
# def fast_resonator(R_S, Q, frequency_array, frequency_R, impedance=None):
#     R_S = R_S.astype(dtype=precision.real_t, order='C', copy=False)
#     Q = Q.astype(dtype=precision.real_t, order='C', copy=False)


# Path: blond/utils/bmath.py
import numpy as np
from ..utils import butils_wrap

'''
BLonD math and physics core functions

@author Stefan Hegglin, Konstantinos Iliakis
@date 20.10.2017
'''
# from functools import wraps
# from ..utils import bphysics_wrap

precision = butils_wrap.precision
__exec_mode = 'single_node'
# Other modes: multi_node

# dictionary storing the CPU versions of the desired functions #
_CPU_func_dict = {
    'rfft': np.fft.rfft,
    'irfft': np.fft.irfft,
    'rfftfreq': np.fft.rfftfreq,
    'irfft_packed': butils_wrap.irfft_packed,
    'sin': butils_wrap.sin,
    'cos': butils_wrap.cos,
    'exp': butils_wrap.exp,
    'mean': butils_wrap.mean,
    'std': butils_wrap.std,
    'where': butils_wrap.where,
    'interp': butils_wrap.interp,
    'interp_const_space': butils_wrap.interp_const_space,

    'cumtrapz': butils_wrap.cumtrapz,