diff options
author | 2009-09-28 00:32:31 +0200 | |
---|---|---|
committer | 2009-09-28 00:32:31 +0200 | |
commit | bee14ee8e606c2686785a986a37a6a2f9493c416 (patch) | |
tree | b0d395777d3d7705cf9b6ff711a5a175602bc958 /unsupported/test/NonLinear.cpp | |
parent | 956d65ea631d7696c1cf9a34554c7104297790e7 (diff) |
use operator() so that to be coherent with eigen AutoDiff functor
Diffstat (limited to 'unsupported/test/NonLinear.cpp')
-rw-r--r-- | unsupported/test/NonLinear.cpp | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/unsupported/test/NonLinear.cpp b/unsupported/test/NonLinear.cpp index 8ab00701a..86def7106 100644 --- a/unsupported/test/NonLinear.cpp +++ b/unsupported/test/NonLinear.cpp @@ -130,7 +130,7 @@ struct Functor */ struct lmder_functor : Functor<double,3,15> { - int f(const VectorXd &x, VectorXd &fvec) const + int operator()(const VectorXd &x, VectorXd &fvec) const { double tmp1, tmp2, tmp3; double y[ValuesAtCompileTime] = {1.4e-1, 1.8e-1, 2.2e-1, 2.5e-1, 2.9e-1, 3.2e-1, 3.5e-1, @@ -246,7 +246,7 @@ void testLmder() struct hybrj_functor : Functor<double,9,9> { - static int f(const VectorXd &x, VectorXd &fvec) + int operator()(const VectorXd &x, VectorXd &fvec) { double temp, temp1, temp2; const int n = x.size(); @@ -262,7 +262,7 @@ struct hybrj_functor : Functor<double,9,9> } return 0; } - static int df(const VectorXd &x, MatrixXd &fjac) + int df(const VectorXd &x, MatrixXd &fjac) { const int n = x.size(); assert(fjac.rows()==n); @@ -349,7 +349,7 @@ void testHybrj() struct hybrd_functor : Functor<double,9,9> { - static int f(const VectorXd &x, VectorXd &fvec) + int operator()(const VectorXd &x, VectorXd &fvec) const { double temp, temp1, temp2; const int n = x.size(); @@ -429,7 +429,7 @@ void testHybrd() struct lmstr_functor : Functor<double,3,15> { - static int f(const VectorXd &x, VectorXd &fvec) + int operator()(const VectorXd &x, VectorXd &fvec) { /* subroutine fcn for lmstr1 example. */ double tmp1, tmp2, tmp3; @@ -448,7 +448,7 @@ struct lmstr_functor : Functor<double,3,15> } return 0; } - static int df(const VectorXd &x, VectorXd &jac_row, int rownb) + int df(const VectorXd &x, VectorXd &jac_row, int rownb) { assert(x.size()==3); assert(jac_row.size()==x.size()); @@ -528,7 +528,7 @@ void testLmstr() struct lmdif_functor : Functor<double,3,15> { - static int f(const VectorXd &x, VectorXd &fvec) + int operator()(const VectorXd &x, VectorXd &fvec) const { /* function fcn for lmdif1 example */ @@ -632,7 +632,7 @@ struct chwirut2_functor : Functor<double,3,54> { static const double m_x[54]; static const double m_y[54]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { int i; @@ -644,7 +644,7 @@ struct chwirut2_functor : Functor<double,3,54> } return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==3); assert(fjac.rows()==54); @@ -718,7 +718,7 @@ struct misra1a_functor : Functor<double,2,14> { static const double m_x[14]; static const double m_y[14]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==2); assert(fvec.size()==14); @@ -727,7 +727,7 @@ struct misra1a_functor : Functor<double,2,14> } return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==2); assert(fjac.rows()==14); @@ -790,11 +790,11 @@ void testNistMisra1a(void) struct hahn1_functor : Functor<double,7,236> { static const double m_x[236]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { static const double m_y[236] = { .591E0 , 1.547E0 , 2.902E0 , 2.894E0 , 4.703E0 , 6.307E0 , 7.03E0 , 7.898E0 , 9.470E0 , 9.484E0 , 10.072E0 , 10.163E0 , 11.615E0 , 12.005E0 , 12.478E0 , 12.982E0 , 12.970E0 , 13.926E0 , 14.452E0 , 14.404E0 , 15.190E0 , 15.550E0 , 15.528E0 , 15.499E0 , 16.131E0 , 16.438E0 , 16.387E0 , 16.549E0 , 16.872E0 , 16.830E0 , 16.926E0 , 16.907E0 , 16.966E0 , 17.060E0 , 17.122E0 , 17.311E0 , 17.355E0 , 17.668E0 , 17.767E0 , 17.803E0 , 17.765E0 , 17.768E0 , 17.736E0 , 17.858E0 , 17.877E0 , 17.912E0 , 18.046E0 , 18.085E0 , 18.291E0 , 18.357E0 , 18.426E0 , 18.584E0 , 18.610E0 , 18.870E0 , 18.795E0 , 19.111E0 , .367E0 , .796E0 , 0.892E0 , 1.903E0 , 2.150E0 , 3.697E0 , 5.870E0 , 6.421E0 , 7.422E0 , 9.944E0 , 11.023E0 , 11.87E0 , 12.786E0 , 14.067E0 , 13.974E0 , 14.462E0 , 14.464E0 , 15.381E0 , 15.483E0 , 15.59E0 , 16.075E0 , 16.347E0 , 16.181E0 , 16.915E0 , 17.003E0 , 16.978E0 , 17.756E0 , 17.808E0 , 17.868E0 , 18.481E0 , 18.486E0 , 19.090E0 , 16.062E0 , 16.337E0 , 16.345E0 , 16.388E0 , 17.159E0 , 17.116E0 , 17.164E0 , 17.123E0 , 17.979E0 , 17.974E0 , 18.007E0 , 17.993E0 , 18.523E0 , 18.669E0 , 18.617E0 , 19.371E0 , 19.330E0 , 0.080E0 , 0.248E0 , 1.089E0 , 1.418E0 , 2.278E0 , 3.624E0 , 4.574E0 , 5.556E0 , 7.267E0 , 7.695E0 , 9.136E0 , 9.959E0 , 9.957E0 , 11.600E0 , 13.138E0 , 13.564E0 , 13.871E0 , 13.994E0 , 14.947E0 , 15.473E0 , 15.379E0 , 15.455E0 , 15.908E0 , 16.114E0 , 17.071E0 , 17.135E0 , 17.282E0 , 17.368E0 , 17.483E0 , 17.764E0 , 18.185E0 , 18.271E0 , 18.236E0 , 18.237E0 , 18.523E0 , 18.627E0 , 18.665E0 , 19.086E0 , 0.214E0 , 0.943E0 , 1.429E0 , 2.241E0 , 2.951E0 , 3.782E0 , 4.757E0 , 5.602E0 , 7.169E0 , 8.920E0 , 10.055E0 , 12.035E0 , 12.861E0 , 13.436E0 , 14.167E0 , 14.755E0 , 15.168E0 , 15.651E0 , 15.746E0 , 16.216E0 , 16.445E0 , 16.965E0 , 17.121E0 , 17.206E0 , 17.250E0 , 17.339E0 , 17.793E0 , 18.123E0 , 18.49E0 , 18.566E0 , 18.645E0 , 18.706E0 , 18.924E0 , 19.1E0 , 0.375E0 , 0.471E0 , 1.504E0 , 2.204E0 , 2.813E0 , 4.765E0 , 9.835E0 , 10.040E0 , 11.946E0 , 12.596E0 , 13.303E0 , 13.922E0 , 14.440E0 , 14.951E0 , 15.627E0 , 15.639E0 , 15.814E0 , 16.315E0 , 16.334E0 , 16.430E0 , 16.423E0 , 17.024E0 , 17.009E0 , 17.165E0 , 17.134E0 , 17.349E0 , 17.576E0 , 17.848E0 , 18.090E0 , 18.276E0 , 18.404E0 , 18.519E0 , 19.133E0 , 19.074E0 , 19.239E0 , 19.280E0 , 19.101E0 , 19.398E0 , 19.252E0 , 19.89E0 , 20.007E0 , 19.929E0 , 19.268E0 , 19.324E0 , 20.049E0 , 20.107E0 , 20.062E0 , 20.065E0 , 19.286E0 , 19.972E0 , 20.088E0 , 20.743E0 , 20.83E0 , 20.935E0 , 21.035E0 , 20.93E0 , 21.074E0 , 21.085E0 , 20.935E0 }; - // static int called=0; printf("call hahn1_functor with iflag=%d, called=%d\n", iflag, called); if (iflag==1) called++; + // int called=0; printf("call hahn1_functor with iflag=%d, called=%d\n", iflag, called); if (iflag==1) called++; assert(b.size()==7); assert(fvec.size()==236); @@ -805,7 +805,7 @@ struct hahn1_functor : Functor<double,7,236> return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==7); assert(fjac.rows()==236); @@ -887,7 +887,7 @@ struct misra1d_functor : Functor<double,2,14> { static const double x[14]; static const double y[14]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==2); assert(fvec.size()==14); @@ -896,7 +896,7 @@ struct misra1d_functor : Functor<double,2,14> } return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==2); assert(fjac.rows()==14); @@ -962,7 +962,7 @@ struct lanczos1_functor : Functor<double,6,24> { static const double x[24]; static const double y[24]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==6); assert(fvec.size()==24); @@ -970,7 +970,7 @@ struct lanczos1_functor : Functor<double,6,24> fvec[i] = b[0]*exp(-b[1]*x[i]) + b[2]*exp(-b[3]*x[i]) + b[4]*exp(-b[5]*x[i]) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==6); assert(fjac.rows()==24); @@ -1047,7 +1047,7 @@ struct rat42_functor : Functor<double,3,9> { static const double x[9]; static const double y[9]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==3); assert(fvec.size()==9); @@ -1057,7 +1057,7 @@ struct rat42_functor : Functor<double,3,9> return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==3); assert(fjac.rows()==9); @@ -1125,7 +1125,7 @@ struct MGH10_functor : Functor<double,3,16> { static const double x[16]; static const double y[16]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==3); assert(fvec.size()==16); @@ -1133,7 +1133,7 @@ struct MGH10_functor : Functor<double,3,16> fvec[i] = b[0] * exp(b[1]/(x[i]+b[2])) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==3); assert(fjac.rows()==16); @@ -1202,7 +1202,7 @@ void testNistMGH10(void) struct BoxBOD_functor : Functor<double,2,6> { static const double x[6]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { static const double y[6] = { 109., 149., 149., 191., 213., 224. }; assert(b.size()==2); @@ -1211,7 +1211,7 @@ struct BoxBOD_functor : Functor<double,2,6> fvec[i] = b[0]*(1.-exp(-b[1]*x[i])) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==2); assert(fjac.rows()==6); @@ -1281,7 +1281,7 @@ struct MGH17_functor : Functor<double,5,33> { static const double x[33]; static const double y[33]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==5); assert(fvec.size()==33); @@ -1289,7 +1289,7 @@ struct MGH17_functor : Functor<double,5,33> fvec[i] = b[0] + b[1]*exp(-b[3]*x[i]) + b[2]*exp(-b[4]*x[i]) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==5); assert(fjac.rows()==33); @@ -1366,7 +1366,7 @@ struct MGH09_functor : Functor<double,4,11> { static const double _x[11]; static const double y[11]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==4); assert(fvec.size()==11); @@ -1376,7 +1376,7 @@ struct MGH09_functor : Functor<double,4,11> } return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==4); assert(fjac.rows()==11); @@ -1452,7 +1452,7 @@ struct Bennett5_functor : Functor<double,3,154> { static const double x[154]; static const double y[154]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==3); assert(fvec.size()==154); @@ -1460,7 +1460,7 @@ struct Bennett5_functor : Functor<double,3,154> fvec[i] = b[0]* pow(b[1]+x[i],-1./b[2]) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==3); assert(fjac.rows()==154); @@ -1529,9 +1529,9 @@ struct thurber_functor : Functor<double,7,37> { static const double _x[37]; static const double _y[37]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { - // static int called=0; printf("call hahn1_functor with iflag=%d, called=%d\n", iflag, called); if (iflag==1) called++; + // int called=0; printf("call hahn1_functor with iflag=%d, called=%d\n", iflag, called); if (iflag==1) called++; assert(b.size()==7); assert(fvec.size()==37); for(int i=0; i<37; i++) { @@ -1540,7 +1540,7 @@ struct thurber_functor : Functor<double,7,37> } return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==7); assert(fjac.rows()==37); @@ -1627,7 +1627,7 @@ struct rat43_functor : Functor<double,4,15> { static const double x[15]; static const double y[15]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==4); assert(fvec.size()==15); @@ -1635,7 +1635,7 @@ struct rat43_functor : Functor<double,4,15> fvec[i] = b[0] * pow(1.+exp(b[1]-b[2]*x[i]),-1./b[3]) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==4); assert(fjac.rows()==15); @@ -1714,7 +1714,7 @@ struct eckerle4_functor : Functor<double,3,35> { static const double x[35]; static const double y[35]; - static int f(const VectorXd &b, VectorXd &fvec) + int operator()(const VectorXd &b, VectorXd &fvec) { assert(b.size()==3); assert(fvec.size()==35); @@ -1722,7 +1722,7 @@ struct eckerle4_functor : Functor<double,3,35> fvec[i] = b[0]/b[1] * exp(-0.5*(x[i]-b[2])*(x[i]-b[2])/(b[1]*b[1])) - y[i]; return 0; } - static int df(const VectorXd &b, MatrixXd &fjac) + int df(const VectorXd &b, MatrixXd &fjac) { assert(b.size()==3); assert(fjac.rows()==35); |