[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-gsl] GSL, C++, and function pointers
From: |
Jordi Gutierrez Hermoso |
Subject: |
[Help-gsl] GSL, C++, and function pointers |
Date: |
Mon, 5 Mar 2007 14:38:36 -0600 |
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] GSL, C++, and function pointers,
Jordi Gutierrez Hermoso <=
- Re: [Help-gsl] GSL, C++, and function pointers, eknecronzontas, 2007/03/05
- Re: [Help-gsl] GSL, C++, and function pointers, Paulo Jabardo, 2007/03/05
- Re: [Help-gsl] GSL, C++, and function pointers, Jordi Gutierrez Hermoso, 2007/03/06
- Re: [Help-gsl] GSL, C++, and function pointers, Paulo Jabardo, 2007/03/06
- Re: [Help-gsl] GSL, C++, and function pointers, eknecronzontas, 2007/03/07
- Re: [Help-gsl] GSL, C++, and function pointers, Brian Gough, 2007/03/12
- Re: [Help-gsl] GSL, C++, and function pointers, Jordi Gutierrez Hermoso, 2007/03/12
- Re: [Help-gsl] GSL, C++, and function pointers, Brian Gough, 2007/03/13