All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines
Public Types | Public Member Functions
QGpCoreTools::ComplexExponential Class Reference

Fast computation of complex exponential with a rational argument. More...

#include <ComplexExponential.h>

List of all members.

Public Types

enum  Sign { Positive, Negative }

Public Member Functions

 ComplexExponential (int n, Sign s)
const Complexvalue (long int x)
 ~ComplexExponential ()

Detailed Description

Fast computation of complex exponential with a rational argument.

Compute values of expression exp(2*pi*i*x/n), 0<x, i is the imaginary number. As x and n are integers, this expression has a maximum of n distinct values, even if x is not limited to n (by periodic properties).

This object was first designed for the computation fast partial Fourier transform where a lot of redundant computation of this exponential are required. All values are kept in a cache of dimension n.


Member Enumeration Documentation

Enumerator:
Positive 
Negative 

Constructor & Destructor Documentation

Description of constructor still missing

{
  _s=s;
  _n=n;
  _cache=new Complex[_n];
  _invn=1.0/(double)_n;
}

Description of destructor still missing

{
  delete [] _cache;
}

Member Function Documentation

const Complex & QGpCoreTools::ComplexExponential::value ( long int  x) [inline]

References QGpCoreTools::Complex::isNull(), Negative, Positive, and QGpCoreTools::Complex::setUnitExp().

{
  if(x >= _n) {
    x=x % _n;
  }
  Complex& c=_cache[x];
  if(c.isNull()) {
    switch (_s) {
    case Positive:
      c.setUnitExp(2 * M_PI * (double)x*_invn);
      break;
    case Negative:
      c.setUnitExp( -2 * M_PI * (double)x*_invn);
      break;
    }
  }
  return c;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines