36 #include <itpp/itexports.h> 88 ITPP_EXPORT
void fft(
const cvec &in, cvec &out);
90 ITPP_EXPORT cvec
fft(
const cvec &in);
97 ITPP_EXPORT cvec
fft(
const cvec &in,
const int N);
99 ITPP_EXPORT
void ifft(
const cvec &in, cvec &out);
101 ITPP_EXPORT cvec
ifft(
const cvec &in);
108 ITPP_EXPORT cvec
ifft(
const cvec &in,
const int N);
111 ITPP_EXPORT
void fft_real(
const vec& in, cvec &out);
113 ITPP_EXPORT cvec
fft_real(
const vec& in);
120 ITPP_EXPORT cvec
fft_real(
const vec &in,
const int N);
127 ITPP_EXPORT
void ifft_real(
const cvec &in, vec &out);
134 ITPP_EXPORT vec
ifft_real(
const cvec &in);
144 ITPP_EXPORT vec
ifft_real(
const cvec &in,
const int N);
195 ITPP_EXPORT
void dct(
const vec &in, vec &out);
197 ITPP_EXPORT vec
dct(
const vec &in);
204 ITPP_EXPORT vec
dct(
const vec &in,
const int N);
206 ITPP_EXPORT
void idct(
const vec &in, vec &out);
208 ITPP_EXPORT vec
idct(
const vec &in);
215 ITPP_EXPORT vec
idct(
const vec &in,
const int N);
223 template <
class T> Vec<T>
dht(
const Vec<T> &v);
225 template <
class T>
void dht(
const Vec<T> &vin, Vec<T> &vout);
227 template <
class T>
void self_dht(Vec<T> &v);
230 template <
class T> Vec<T>
dwht(
const Vec<T> &v);
232 template <
class T>
void dwht(
const Vec<T> &vin, Vec<T> &vout);
234 template <
class T>
void self_dwht(Vec<T> &v);
237 template <
class T> Mat<T>
dht2(
const Mat<T> &m);
239 template <
class T> Mat<T>
dwht2(
const Mat<T> &m);
257 for(
int i = 0; i < N1; ++i) {
277 it_assert_debug((1 << m) == N,
"dht(): The vector size must be a power of two");
282 for(
int ib = 0; ib < N; ib += 2) {
283 vout(ib) = vin(ib) + vin(ib + 1);
284 vout(ib + 1) = vin(ib) - vin(ib + 1);
289 for(
int i = 1; i < m; ++i) {
292 for(
int k = 0; k < N; ++k) {
293 for(
int j = 0; j < l; ++j) {
295 vout(ib + j) += vout(ib + j + l);
296 vout(ib + j + l) = t - vout(ib + j + l);
303 vout /=
static_cast<T
>(
std::sqrt(static_cast<double>(vin.
size())));
311 it_assert_debug((1 << m) == N,
"self_dht(): The vector size must be a power " 315 for(
int i = 0; i < m; ++i) {
318 for(
int k = 0; k < N; ++k) {
319 for(
int j = 0; j < l; ++j) {
321 v(ib + j) += v(ib + j + l);
322 v(ib + j + l) = t - v(ib + j + l);
329 v /=
static_cast<T
>(
std::sqrt(static_cast<double>(v.
size())));
361 for(
int i = 0; i < m.
rows(); ++i) {
366 for(
int i = 0; i < m.
cols(); ++i) {
381 for(
int i = 0; i < m.
rows(); ++i) {
386 for(
int i = 0; i < m.
cols(); ++i) {
401 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
dht(
const vec &v);
402 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
dht(
const cvec &v);
403 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void dht(
const vec &vin, vec &vout);
404 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void dht(
const cvec &vin, cvec &vout);
406 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void self_dht(vec &v);
407 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void self_dht(cvec &v);
409 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT vec
dwht(
const vec &v);
410 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cvec
dwht(
const cvec &v);
411 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void dwht(
const vec &vin, vec &vout);
412 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void dwht(
const cvec &vin, cvec &vout);
414 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void self_dwht(vec &v);
415 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT
void self_dwht(cvec &v);
417 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
dht2(
const mat &m);
418 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
dht2(
const cmat &m);
420 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT mat
dwht2(
const mat &m);
421 ITPP_EXPORT_TEMPLATE
template ITPP_EXPORT cmat
dwht2(
const cmat &m);
427 #endif // #ifndef TRANSFORMS_H int size() const
The size of the vector.
Various functions on vectors and matrices - header file.
Vec< Num_T > get_row(int r) const
Get row r.
ITPP_EXPORT void idct(const vec &in, vec &out)
Inverse Discrete Cosine Transform (IDCT)
ITPP_EXPORT void ifft(const cvec &in, cvec &out)
Inverse Fast Fourier Transform.
ITPP_EXPORT void fft_real(const vec &in, cvec &out)
Real Fast Fourier Transform.
ITPP_EXPORT bool have_cosine_transforms()
Run-time test if library is built with cosine transforms enabled.
void set_size(int size, bool copy=false)
Set length of vector. if copy = true then keeping the old values.
ITPP_EXPORT void fft(const cvec &in, cvec &out)
Fast Fourier Transform.
ITPP_EXPORT void ifft_real(const cvec &in, vec &out)
Inverse Real Fast Fourier Transform.
#define it_assert_debug(t, s)
Abort if t is not true and NDEBUG is not defined.
void self_dwht(Vec< T > &v)
Fast Walsh Hadamard Transform - memory efficient (result in v)
void bitrv(Vec< T > &out)
Bit reverse.
int cols() const
The number of columns.
Mat< T > dht2(const Mat< T > &m)
Fast 2D Hadamard Transform.
ITPP_EXPORT bool have_fourier_transforms()
Run-time test if library is built with Fast Fourier Transforms enabled.
Matrix Class Definitions.
Vec< Num_T > get_col(int c) const
Get column c.
Vec< T > dwht(const Vec< T > &v)
Fast Walsh Hadamard Transform.
void self_dht(Vec< T > &v)
Fast Hadamard Transform - memory efficient. Stores the result in v.
void transpose(const Mat< T > &m, Mat< T > &out)
Transposition of the matrix m returning the transposed matrix in out.
int rows() const
The number of rows.
vec sqrt(const vec &x)
Square root of the elements.
Mat< T > dwht2(const Mat< T > &m)
Fast 2D Walsh Hadamard Transform.
ITPP_EXPORT void dct(const vec &in, vec &out)
Discrete Cosine Transform (DCT)
int levels2bits(int n)
Calculate the number of bits needed to represent n different values (levels).
Templated Vector Class Definitions.
Vec< T > dht(const Vec< T > &v)
Fast Hadamard Transform.