Skip to content

Speeding up the computation of sliding dot product with fft #938

Open
@NimaSarajpoor

Description

@NimaSarajpoor

[Update]
Here, I am providing some important links to external resources or the comments mentioned here:


Currently, in Stumpy, the sliding dot product [of a query Q and a time series T], is computed via one of the two following functions:

  • core.sliding_dot_product, which takes advantage of fft trick using scipy.signal.convolve
  • core._sliding_dot_product, which uses a njit on top of np.dot

The sliding dot product in MATALB (via fft trick) seems to be faster though.

# MATLAB code

%x is the data, y is the query
m = length(y);
n = length(x);

y = y(end:-1:1);%Reverse the query
y(m+1:n) = 0; %aappend zeros

%The main trick of getting dot products in O(n log n) time
X = fft(x);
Y = fft(y);
Z = X.*Y;
z = ifft(Z);

# and then use the slice `z(m:n)`

Can we get closer to the performance of MATLAB?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions