I'm trying to implement Algorithm 2 from this paper:
Xuancheng Shao and Steven G. Johnson: Type-IV DCT, DST, and MDCT algorithms with reduced numbers of arithmetic operations, https://arxiv.org/pdf/0708.4399.pdf
It outlines an algorithm for computing an even-sized DCT type 4 via a DCT type 3 and a DST type 3 of half size.
I've made a few attempts at implementing this, but either the paper has a mistake or I have a serious misunderstanding about what's happening here.
https://pastebin.com/uFiHsMKX Here's my C++ code, which uses FFTW to compute the inner transforms, as well as to compute an "expected output". Aside from FFTW all the code necessary to compile is in this one file. The function
compute_dct4 is what does the actual processing -- I did my best to name variables the same as in the paper, so it should be clear what in the code corresponds to what in the paper.
I'd appreciate some extra eyes on what's going wrong. Thanks!