S
StephQ
I'm still working on the library for the simulation of SDEs.
The following test code compiles fine with the digital mars compiler,
but fails with gcc.
Error: no matching function for call to 'prova(Diff_sine&, double,
double)'
#include <iostream>
#include "math.h"
using namespace std;
class Diff_sine {
double theta;
double gamma;
double ea_Kc1, ea_Kc2;
public:
Diff_sine(double theta_, double gamma_);
double ea_K(double x);
};
inline Diff_sine:iff_sine(double theta_, double gamma_) :
theta(theta_), gamma(gamma_),
ea_Kc1(theta_*gamma_/2), ea_Kc2(theta_*theta_/2)
{}
inline double Diff_sine::ea_K(double x) {
return ea_Kc1*cos(gamma*x) + ea_Kc2*sin(gamma*x)*sin(gamma*x) ;
}
template<class F, double (F::*f)(double) const>
double prova2(const F& theF, double a, double b) {
return (theF.*f)(b);
}
template<class F, double (F::*f)(double) const>
double prova(const F& theF, double a, double b) {
double val;
val = prova2<F, f>(theF, a, b) ;
return val;
}
int main() {
Diff_sine theDiff_sine(1,1);
double minimum ;
minimum = prova<Diff_sine, &Diff_sine::ea_K>(theDiff_sine,
-1.0,1.0) ;
}
Thank you again in advance for your help.
Best Regards
StephQ
The following test code compiles fine with the digital mars compiler,
but fails with gcc.
Error: no matching function for call to 'prova(Diff_sine&, double,
double)'
#include <iostream>
#include "math.h"
using namespace std;
class Diff_sine {
double theta;
double gamma;
double ea_Kc1, ea_Kc2;
public:
Diff_sine(double theta_, double gamma_);
double ea_K(double x);
};
inline Diff_sine:iff_sine(double theta_, double gamma_) :
theta(theta_), gamma(gamma_),
ea_Kc1(theta_*gamma_/2), ea_Kc2(theta_*theta_/2)
{}
inline double Diff_sine::ea_K(double x) {
return ea_Kc1*cos(gamma*x) + ea_Kc2*sin(gamma*x)*sin(gamma*x) ;
}
template<class F, double (F::*f)(double) const>
double prova2(const F& theF, double a, double b) {
return (theF.*f)(b);
}
template<class F, double (F::*f)(double) const>
double prova(const F& theF, double a, double b) {
double val;
val = prova2<F, f>(theF, a, b) ;
return val;
}
int main() {
Diff_sine theDiff_sine(1,1);
double minimum ;
minimum = prova<Diff_sine, &Diff_sine::ea_K>(theDiff_sine,
-1.0,1.0) ;
}
Thank you again in advance for your help.
Best Regards
StephQ