help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] GSL, C++, and function pointers


From: Paulo Jabardo
Subject: Re: [Help-gsl] GSL, C++, and function pointers
Date: Mon, 5 Mar 2007 22:27:45 -0300 (ART)

If I understand you correctly, you need to write a
wrapper class. Since your function should be defined
(in GSL) as gsl_function structure which has two
fields:

a function pointer to a function that accepts a double
and a void* and returns a double and a second field
that is a void*.

The params field is a pointer to user data. It can be
anything you want so you can define a structure/class
that contains every information necessary. Then you
write a global function (as defined by GSL) that knows
how to use this structure/class you defined.


--- Jordi Gutierrez Hermoso <address@hidden>
escreveu:

> Sometimes I think that besides joke languages like
> Brainfuck, C++ must
> be the most complicated language ever... I'll try to
> explain, but I
> tend to be verbose and chatty when I write.
> 
> Here's what's happening: I want to use GSL's
> differentation routines,
> but due to the vicissitudes of OOP, my functions
> take in
> linalg::vector objects and return doubles. A
> linalg::vector is pretty
> much what its name suggests, and in fact, it's just
> my own wrapper for
> GSL vectors. So my functions are from \mathbb{R}^n
> to \mathbb{R}.
> 
> I want partial derivatives now for a differential
> operator class I'm
> building for giving some flexibility in defining and
> solving BVPs, but
> I have just realised that differentiation is one of
> those things
> that's harder than it looks to accomplish
> gracefully. I trust the GSL
> has better differentiation routines than anything I
> could come up
> with, but they all take function pointers to
> functions that take in
> doubles and return doubles.
> 
> Now, C++'s STL, I just discovered, provides some
> routines and classes
> for creating functors (function-like objects) out of
> any function by
> binding some variables (e.g. the index of the
> coordinate along which I
> would like to differentiate my multi-variable
> function). However, I
> don't see how to adapt these C++ functors into the
> function pointers
> that the GSL expects. This is one of those times
> when I wish C++ would
> allow function definition at runtime. :-(
> 
> Help, ideas? It's mostly a design issue, and I'd
> rather resolve it
> cleanly so as to avoid rewriting any code, if
> possible.
> 
> Thanks,
> - Jordi G. H.
> 
> 
> _______________________________________________
> Help-gsl mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/help-gsl
> 


__________________________________________________
Fale com seus amigos  de graça com o novo Yahoo! Messenger 
http://br.messenger.yahoo.com/ 




reply via email to

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