This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BenchmarkTools. LinearAlgebra | |
function naive_mul!(C,A,B) | |
C[1,1] = A[1,1] * B[1,1] + A[1,2] * B[2,1] | |
C[1,2] = A[1,1] * B[1,2] + A[1,2] * B[2,2] | |
C[2,1] = A[2,1] * B[1,1] + A[2,2] * B[2,1] | |
C[2,2] = A[2,1] * B[1,2] + A[2,2] * B[2,2] | |
return nothing | |
end | |
function strassen_mul!(C,A,B) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GPUArrays, FFTW | |
""" | |
hilbert(x) | |
Computes the analytic representation of x, ``x_a = x + j | |
\\hat{x}``, where ``\\hat{x}`` is the Hilbert transform of x, | |
along the first dimension of x. | |
""" | |
function hilbert(x::GPUArray{T}) where T<:Real | |
N = size(x, 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a function to reshape a 1d array using a sliding window with a step. | |
# NOTE: The function uses numpy's internat as_strided function because looping in python is slow in comparison. | |
# Adopted from http://www.rigtorp.se/2011/01/01/rolling-statistics-numpy.html and | |
# https://gist.github.com/codehacken/708f19ae746784cef6e68b037af65788 | |
import numpy as np | |
# Reshape a numpy array 'a' of shape (x) to form shape((n - window_size) // step + 1, window_size)) | |
def rolling_window(a, window, step): | |
shape = a.shape[:-1] + ((a.shape[-1] - window + 1)//step, window) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using GPUArrays | |
using CuArrays | |
import Base.sin, Base.cos, Base.exp | |
function sin(A::GPUArray{ComplexF64}) | |
return sin.(real(A)) .* cosh.(imag(A)) .+ im .* cos.(real(A)) .* sinh.(imag(A)) | |
end | |
function cos(A::GPUArray{ComplexF64}) | |
return cos.(real(A)) .* cosh.(imag(A)) .- im .* sin.(real(A)) .* sinh.(imag(A)) |