forum.alglib.net

ALGLIB forum
It is currently Mon Nov 25, 2024 3:51 pm

All times are UTC


Forum rules


1. This forum can be used for discussion of both ALGLIB-related and general numerical analysis questions
2. This forum is English-only - postings in other languages will be removed.



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: How to pass a function from a class to ODE solver
PostPosted: Sun Jan 20, 2013 6:37 am 
Offline

Joined: Sun Jan 20, 2013 6:24 am
Posts: 1
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;
}



Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 11 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group