dct

Functions

int main(int argc, char *argv[])

dct [ option ] [ infile ]

  • -l int

    • DCT length \((1 \le L)\)

  • -q int

    • input format

      • 0 real and imaginary parts

      • 1 real part

  • -o int

    • output format

      • 0 real and imaginary parts

      • 1 real part

      • 2 imaginary part

      • 3 amplitude spectrum

      • 4 power spectrum

  • infile str

    • double-type data sequence

  • stdout

    • double-type DCT sequence

Parameters:
  • argc[in] Number of arguments.

  • argv[in] Argument vector.

Returns:

0 on success, 1 on failure.

See also

idct

class DiscreteCosineTransform

Calculate DCT-II of complex-valued input data.

The inputs are \(L\)-length order complex-valued data:

\[\begin{split} \begin{array}{cccc} \mathrm{Re}(x(0)), & \mathrm{Re}(x(1)), & \ldots, & \mathrm{Re}(x(L-1)), \\ \mathrm{Im}(x(0)), & \mathrm{Im}(x(1)), & \ldots, & \mathrm{Im}(x(L-1)). \end{array} \end{split}\]
The outputs are
\[\begin{split} \begin{array}{cccc} \mathrm{Re}(X(0)), & \mathrm{Re}(X(1)), & \ldots, & \mathrm{Re}(X(L-1)), \\ \mathrm{Im}(X(0)), & \mathrm{Im}(X(1)), & \ldots, & \mathrm{Im}(X(L-1)). \end{array} \end{split}\]
They are computed as
\[ X(k) = \sqrt{\frac{2}{L}} c(k) \sum_{n=0}^{L-1} x(n) \cos \left( \frac{\pi}{L} \left( n + \frac{1}{2} \right) k \right), \]
where
\[\begin{split} c(k) = \left\{ \begin{array}{ll} 1/\sqrt{2}, & k = 0 \\ 1. & 1 \le k < L \end{array} \right. \end{split}\]

Public Functions

explicit DiscreteCosineTransform(int dct_length)
Parameters:

dct_length[in] DCT length, \(L\).

inline int GetDctLength() const
Returns:

DCT length.

inline bool IsValid() const
Returns:

True if this object is valid.

bool Run(const std::vector<double> &real_part_input, const std::vector<double> &imag_part_input, std::vector<double> *real_part_output, std::vector<double> *imag_part_output, DiscreteCosineTransform::Buffer *buffer) const
Parameters:
  • real_part_input[in] \(L\)-length real part of input.

  • imag_part_input[in] \(L\)-length imaginary part of input.

  • real_part_output[out] \(L\)-length real part of output.

  • imag_part_output[out] \(L\)-length imaginary part of output.

  • buffer[out] Buffer.

Returns:

True on success, false on failure.

bool Run(std::vector<double> *real_part, std::vector<double> *imag_part, DiscreteCosineTransform::Buffer *buffer) const
Parameters:
  • real_part[inout] \(L\)-length real part.

  • imag_part[inout] \(L\)-length imaginary part.

  • buffer[out] Buffer.

Returns:

True on success, false on failure.

class Buffer

Buffer for DiscreteCosineTransform class.