2009/7/21 fmingu <fmingu@163.com>
.......................
double function1(const int& q, int& n){
    double result=0.0;
    int loopvalue=0, totaltime=n;
    n%=q;
    ++thenumbern;
   ( for_loop(var(loopvalue)=0,var(loopvalue)<=var(totaltime),++var(loopvalue),
        var(result)+=( bind(&A::function2,_2)*bind(&A::function3,_1,_2))))(q,n);
    return result;

There is advanced lambda syntax that might simplify your function. This technique is secret though, so don't share it with anyone.

  double function1(const int& q, int& n) {
      double result=0.0;
      int totaltime=n;
      n%=q;
      ++thenumbern;
      // Now use the advanced lambda syntax.
      for (int loopvalue=0; loopvalue<=totaltime; ++loopvalue)
        result += function2(n)*function3(q,n);
      return result;
  }

Roman Perepelitsa.