<jupyter_start><jupyter_text>Resample<jupyter_code>start = 0
stop = 10
num = int(1e8)
resample_num = int(1e5)

cx = np.linspace(start, stop, num, endpoint=False) 
cy = np.cos(-cx**2/6.0)
%%time
cf = signal.resample(cy, resample_num, window=('kaiser', 0.5))
gx = cp.linspace(start, stop, num, endpoint=False)
gy = cp.cos(-gx**2/6.0)
%%time
gf = cusignal.resample(gy, resample_num, window=('kaiser',0.5))<jupyter_output>CPU times: user 195 ms, sys: 114 ms, total: 310 ms
Wall time: 321 ms<jupyter_text>Resample Poly<jupyter_code>start = 0
stop = 10
num = int(1e8)
resample_up = 2
resample_down = 3

cx = np.linspace(start, stop, num, endpoint=False) 
cy = np.cos(-cx**2/6.0)
%%time
cf = signal.resample_poly(cy, resample_up, resample_down, window=('kaiser', 0.5))
gx = cp.linspace(start, stop, num, endpoint=False)
gy = cp.cos(-gx**2/6.0)
%%time
cf = cusignal.resample_poly(gy, resample_up, resample_down, window=('kaiser', 0.5), use_numba=True)
%%time
cf = cusignal.resample_poly(gy, resample_up, resample_down, window=('kaiser', 0.5), use_numba=False)
gpu_signal = cusignal.get_shared_mem(num, dtype=np.complex128)
gpu_signal[:] = cy<jupyter_output><empty_output><jupyter_text>FIR Filter Design with Window<jupyter_code>numtaps = int(1e8)
f1, f2 = 0.1, 0.2
%%time
cfirwin = signal.firwin(numtaps, [f1, f2], pass_zero=False)
%%time
gfirwin = cusignal.firwin(numtaps, [f1, f2], pass_zero=False)<jupyter_output>CPU times: user 214 ms, sys: 20.8 ms, total: 235 ms
Wall time: 233 ms<jupyter_text>Correlate<jupyter_code>sig = np.random.rand(int(1e8))
sig_noise = sig + np.random.randn(len(sig))
%%time
ccorr = signal.correlate(sig_noise, np.ones(128), mode='same') / 1e6
sig = cp.random.rand(int(1e8))
sig_noise = sig + cp.random.randn(len(sig))
%%time
gcorr = cusignal.correlate(sig_noise, cp.ones(128), mode='same') / 1e6<jupyter_output>CPU times: user 74.2 ms, sys: 12.8 ms, total: 87 ms
Wall time: 85.2 ms<jupyter_text>Convolve<jupyter_code>sig = np.random.rand(int(1e8))
win = signal.windows.hann(int(1e3))
%%time
cconv = signal.convolve(sig, win, mode='same') / np.sum(sig)
%%time
sig = cp.random.rand(int(1e8))
win = cusignal.hann(int(1e3))
gconv = cusignal.convolve(sig, win, mode='same') / cp.sum(win)<jupyter_output>CPU times: user 60.4 ms, sys: 35.3 ms, total: 95.7 ms
Wall time: 93.8 ms<jupyter_text>Convolution using the FFT Method<jupyter_code>csig = np.random.randn(int(1e8))
%%time
cautocorr = signal.fftconvolve(csig, csig[::-1], mode='full')
gsig = cp.random.randn(int(1e8))
%%time
gautocorr = cusignal.fftconvolve(gsig, gsig[::-1], mode='full')<jupyter_output>CPU times: user 101 ms, sys: 28.4 ms, total: 129 ms
Wall time: 132 ms<jupyter_text>Wiener Filter on N-Dimensional Array<jupyter_code>csig = np.random.rand(int(1e8))
%%time
cfilt = signal.wiener(csig)
gsig = cp.random.randn(int(1e8))
%%time
gfilt = cusignal.wiener(gsig)<jupyter_output>CPU times: user 586 ms, sys: 111 ms, total: 697 ms
Wall time: 700 ms<jupyter_text>Perform 1-D Hilbert Transform<jupyter_code>csig = np.random.rand((int(1e8)))
%%time
chtrans = signal.hilbert(csig)
gsig = cp.random.rand(int(1e8))
%%time
ghtrans = cusignal.hilbert(gsig)<jupyter_output>CPU times: user 45.5 ms, sys: 30.1 ms, total: 75.6 ms
Wall time: 73.7 ms<jupyter_text>Perform 2-D Hilbert Transform<jupyter_code>csig = np.random.rand(int(1e4), int(1e4))
%%time
chtrans2d = signal.hilbert2(csig)
gsig = cp.random.rand(int(1e4), int(1e4))
%%time
ghtrans2d = cusignal.hilbert2(gsig)<jupyter_output>CPU times: user 30.7 ms, sys: 12.9 ms, total: 43.6 ms
Wall time: 41.9 ms<jupyter_text>Perform 2-D Convolution and Correlation<jupyter_code>csig = np.random.rand(int(1e4), int(1e4))
filt = np.random.rand(5,5)
%%time
grad = signal.convolve2d(csig, filt, boundary='symm', mode='same')
%%time
grad = signal.correlate2d(csig, filt, boundary='symm', mode='same')
gsig = cp.random.rand(int(1e4), int(1e4))
gfilt = cp.random.rand(5,5)
%%time
ggrad = cusignal.convolve2d(csig, filt, boundary='symm', mode='same')
%%time
ggrad = cusignal.correlate2d(csig, filt, boundary='symm', mode='same')<jupyter_output>CPU times: user 755 ms, sys: 635 ms, total: 1.39 s
Wall time: 1.39 s
{'fraction_non_alphanumeric': 0.16751638747268754, 'fraction_numerical': 0.05462490895848507, 'mean_word_length': 6.317939609236235, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '15023', 'license': 'Apache-2.0', 'n_tokens_mistral': 1937, 'n_tokens_neox': 1808, 'n_words': 365, 'path': 'notebooks/api_guide/signaltools_examples.ipynb', 'repo_name': 'dicta/cusignal', 'size': '4119'}