Boost logo

Boost :

From: nbecker_at_[hidden]
Date: 2001-05-16 12:22:57


One example:

A Modulator takes an input sequence, and a funtion that maps elements
of the input into complex values.

For reasons too detailed to explain here, at some point I want to just
produce constant values of Complex(0,0) as the result of the mapping
funtion.

Thus, for normal operation the input sequence may be a vector<int>,
which gives a symbol index, and the mapping might be
QPSKConstellation(), which maps symbols [0..3] into complex numbers.

When the modulator is turned off, the mapping is set to
Constant<Complex>(0).

A slightly different version:
template<class T>
class constant : public unary_function<T, T> {
  T val;
public:
  constant (T _val) :
    val (_val) {}
  T operator () (const T& x) const {
    return val;
  }
};

I used this in conjunction with a 2d Romberg numerical intergration.
The general romberg2d looks like:

template<class func, class fa, class fb>
double romberg2d (const func& f, const fa& ax, const fb& bx, double ay, double by, double eps = 1e-6, int jmax = 20, int K = 5) {
  return romberg (g2<func, fa, fb>(f, ax, bx, eps, jmax, K), ay, by, eps, jmax, K);
}

where fa and fb are limits on the inner integration that in general
are functions of the outer integration variable. For the case that
the fa and fb are really just constant, you can use
constant<double>(5), for example.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk