static Matrixf dct()

in StreamingASR/StreamingASR/app/src/main/cpp/librosa/librosa.h [161:175]


static Matrixf dct(Matrixf& x, bool norm, int type) {
  int N = x.cols();
  Matrixf xi = Matrixf::Zero(N, N);
  xi.rowwise() += Vectorf::LinSpaced(N, 0.f, static_cast<float>(N-1));
  // type 2
  Matrixf coeff = 2*(M_PI*xi.transpose().array()/N*(xi.array()+0.5)).cos();
  Matrixf dct = x*coeff.transpose();
  // ortho
  if (norm) {
    Vectorf ortho = Vectorf::Constant(N, std::sqrtf(0.5f/N));
    ortho[0] = std::sqrtf(0.25f/N);
    dct = dct*ortho.asDiagonal();
  }
  return dct;
}