function w = pad(spectrum, L)
%
% W = pad(spectrum, L)
%
% Pad an input vector representing a spectrum to get its length to equal
% the next larger multiple of 2^L by reflecting the end of the spectrum.

% Copyright (c) 2003, 2004 UT M.D. Anderson Cancer Center. All rights reserved.
% See the accompanying file "license.txt" for details.

needs = ceil(length(spectrum)/2.^L)*2.^L - length(spectrum);
w = [spectrum spectrum(end:-1:end-needs+1)];
