I need to apply a 1D type-II DCT (Discrete Cosine Transform) to each column of a matrix while normalizing the result in C++. Effectively, I want to multiply my matrix with an orthogonal type-II DCT-matrix (while avoiding the performance cost of matrix multiplication, of course).

Since this seems like an important computational kernel in many applications, isn't there a highly optimized library for this purpose out there? After searching for a bit I can find a couple of implementations, but I don't know if they're good. I was expecting a function somewhere in a well-known library such as Boost or Eigen. After all, in Python everything I need to do is this (using SciPy): dct(x, norm='ortho')

  • 1
    $\begingroup$ What do you mean by DCT? Discrete Cosine Transform? I would strongly suggest you always define an acronym when you first use it, just because you know what it means doesn't mean everybody else does $\endgroup$ – Ian Bush Sep 25 '20 at 16:00
  • 3
    $\begingroup$ FFTW (fftw.org) is one of the leading c++ FFT libraries and is pretty easy to use. I would also try Intel's MKL FFT routines (which include wrappers for FFTW), as you may find other related linear algebra utilities to solve your problem. $\endgroup$ – Charlie S Sep 25 '20 at 16:00
  • $\begingroup$ Here is a related post using FFTW for DCT stackoverflow.com/questions/37530613/… $\endgroup$ – Charlie S Sep 25 '20 at 16:10
  • $\begingroup$ As @CharlieS mentioned, MKL is frequently used in HPC for FFT computations. $\endgroup$ – Mansoor Sep 26 '20 at 15:02
  • 1
    $\begingroup$ @CharlieS I concur to FFTW being a very sensible choice. A word of caution concerning MKL wrappers: some of them are empty (i.e. the planner would return an empty plan, without warning). Related to this question, this is the case for the multidimensional DCTs (the planner of which is empty in MKL FFTW). source : software.intel.com/content/www/us/en/develop/documentation/… $\endgroup$ – BenBoulderite Oct 1 '20 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.