forum.alglib.net
http://forum.alglib.net/

How to pass a function from a class to ODE solver
http://forum.alglib.net/viewtopic.php?f=2&t=760
Page 1 of 1

Author:  rveltz [ Sun Jan 20, 2013 6:37 am ]
Post subject:  How to pass a function from a class to ODE solver

Hi,

I would like to integrate a function from a class but it does not work because the types do not match.
Have anybody solved this issue before?
Below is an example.

Thank you for your help,

Bests,

Romain

Code:
using namespace alglib;
using namespace std;

class myClass{
public:
   myClass()
   {
   }

   ~myClass()
   {

   }

   void Sig(const real_1d_array &y, double x, real_1d_array &dy, void *ptr)
   {
      dy[0] = -y[0];
   }
};



int main(int argc, char **argv)
{

   myClass A();
   real_1d_array y = "[1]";
   real_1d_array x = "[0, 1]";

   double eps = 0.00001;
   double h = 0;
   odesolverstate s;
   ae_int_t m;
   real_1d_array xtbl;
   real_2d_array ytbl;
   odesolverreport rep;
   odesolverrkck(y, x, eps, h, s);
   alglib::odesolversolve(s, A.Sig);
   odesolverresults(s, m, xtbl, ytbl, rep);
   return 0;
}


Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/