octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Avoid global pointers in dae


From: Francesco Faccio
Subject: Avoid global pointers in dae
Date: Sat, 13 Aug 2016 05:30:55 +0000

Hi! 

I'm writing a class IDA for ode15{i,s} which inherites from class DAE and I would like to avoid using global pointers.

In my dld-function I first create an object of class DAEFunc and I pass it as an argument for the constructor of my class (as it's done in daspk.cc):

DAEFunc func (ida_user_function);
IDA dae (t0, y0, yp0, func);


where ida_user_function is defined as 

ColumnVector
ida_user_function (const ColumnVector& x, const ColumnVector& xdot,
                     double t, octave_idx_type& ires)

and it uses a global pointer to the octave_function supplied by the user to compute residuals.

I would like to overload the constructor of DAEfunc in order to pass the pointer when I construct my object (and avoid declaring it as global):

typedef ColumnVector (*DAERHSFuncIDA) (const ColumnVector& x,
                                         const ColumnVector& xdot,
                                         double t, octave_idx_type& ires,
                                         octave_function *& ida_fcn);

DAEFunc (DAERHSFuncIDA f)
    : fun_ida (f), jac (0), reset (true) { }

and same for the Jacobian.

Since I don't own copiright, I would like to know if it's ok to change the interface of that base class.

Thank you,

Francesco



reply via email to

[Prev in Thread] Current Thread [Next in Thread]