// file: $isip/class/algo/FourierTransform/ft_17.cc
// version: $Id: ft_17.cc 7859 2002-03-07 21:11:04Z zheng $
//

// isip include files
//
#include "FourierTransform.h"

// method: dct3Init
//
// arguments:
//  long order: (input) new order
//
// return: a boolean value indicating status
//
// this method creates lookup tables for the discrete cosine transform
//
boolean FourierTransform::dct3Init(long order_a) {

  return Error::handle(name(), L"dct3Init", ERR, __FILE__, __LINE__);
}

// method: dct3Real
//
// arguments:
//  VectorFloat& output: (output) output data vector
//  const VectorFloat& input: (input) input data vector
//
// return: a boolean value indicating status
//
// this method implements a discrete cosine transformation with type 3
// (DCT_III) given input vector. The trick is that DCT_III is inverse
// of DCT_II.
//
// this code very closely follows the algorithm described in:
//   X. Huang, A. Acero, and H. Hon, Spoken Language Processing,
//   Prentice Hall PTR, Upper Saddle River, New Jersey, pp. 228, 2001.
//   
//   K, Rao, and P. Yip, Discrete Cosine Transform: Algorithms,
//   Advantages and Applications, Academic Press, San Diego,
//   California, pp. 15, 1990.
//
// Forward Algorithm:
//  C[k] = sqrt(2/N) * sum{c[n] * x[n] * cos(k*(2n+1)*pi/2N)}, k = 0,1,..,N-1
//                    n=[0:N-1]
//
// Inverse Algorithm:
//  x[n] = sqrt(2/N) * c[n] * sum{C[k] * cos(k*(2n+1)*pi/2N)}, n = 0,1,..,N-1
//                          k=[0:N-1]
//
//    where, c[n] = 1 / sqrt(2) when n = 0 or N
//           c[n] = 1           when n != 0 or N
//
boolean FourierTransform::dct3Real(VectorFloat& output_a,
				   const VectorFloat& input_a) {

  // forward DCT_III = inverse DCT_II
  // inverse DCT_III = forward DCT_II
  //
  DIRECTION tmp_direction = direction_d;
  direction_d = (tmp_direction == FORWARD) ? INVERSE : FORWARD;
  dct2Real(output_a, input_a);
  direction_d = tmp_direction;

  // exit gracefully
  //
  return true;
}

// method: dct3Complex
//
// arguments:
//  VectorFloat& output: (output) output data vector
//  const VectorFloat& input: (input) input data vector
//
// return: a boolean value indicating status
//
// this method computes the discrete cosine transform of given input vector
//
boolean FourierTransform::dct3Complex(VectorFloat& output_a,
				     const VectorFloat& input_a) {

  return Error::handle(name(), L"dct3Complex", Error::NOT_IMPLEM,
		       __FILE__, __LINE__);  
  
}
