function Xcq = vecq(x, K)
% Xcq = vecq(x, K)
%
% Calculate the constant-Q transform of x, sampled at sr, using the efficient
% algorithm described in [1] and vector optimizations.
%
% K is the spectral kernel, which can be calculated using cqkern.
%
% 1. An efficient algorithm for the calculation of a constant Q transform
%    Judith C. Brown and Miller S. Puckette
%    J. Acoust. Soc. Am. 92 (5), November 1992

error(nargchk(2,2,nargin));

B = rows(K); % number of bins
N0 = columns(K); % FFT length

X = vec(fft(x, N0))';

Xcq = sum((repmat(X, B, 1) .* K), 2) / N0;
