code: def sqd_yinfast(samples):
      """compute approximate sum of squared difference
  
      Using complex convolution (fast, cost o(n*log(n)) )"""
      # yin_t(tau) = (r_t(0) + r_(t+tau)(0)) - 2r_t(tau)
      B = len(samples)
      W = B // 2
      yin = np.zeros(W)
      sqdiff = np.zeros(W)
      kernel = np.zeros(B)
      # compute r_(t+tau)(0)
      squares = samples**2
      for tau in range(W):
          sqdiff[tau] = squares[tau : tau + W].sum()
      # add r_t(0)
      sqdiff += sqdiff[0]
      # compute r_t(tau) using kernel convolution in complex domain
      samples_fft = np.fft.fft(samples)
      kernel[1 : W + 1] = samples[W - 1 :: -1]  # first half, reversed
      kernel_fft = np.fft.fft(kernel)
      r_t_tau = np.fft.ifft(samples_fft * kernel_fft).real[W:]
      # compute yin_t(tau)
      yin = sqdiff - 2 * r_t_tau
      return yin
  
file_path: aubio/python/demos/demo_yin_compare.py
imports: import sys
  import numpy
  import matplotlib.pyplot
label_desc: Use image node_id 2 for calling a global function with example usage: sqd_yinfast(samples) and returns: yin