$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Neal Becker (ndbecker2_at_[hidden])
Date: 2005-10-07 12:00:33
Oh, 1 more:
There are many cases you want to define a function F that applies both to
scalar, and when applied to complex the result F(x) = complex (F(real(x)),
F(imag(x))).
ComplexFunc is handy for this:
template<typename UnaryFunction, typename in_t>
inline std::complex<typename boost::result_of<UnaryFunction(typename
in_t::value_type)>::type> ComplexFunc (UnaryFunction f, in_t x) {
typedef std::complex<typename boost::result_of<UnaryFunction(typename
in_t::value_type)>::type> ret_t;
return ret_t (f (real (x)), f (imag (x)));
}