-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to create a gsl_odeiv_system structure? #156
Comments
@hakonhagland Thanks for this detailed bug report. Can you show exactly what error you get? Also, which version of GSL and Math::GSL ? |
This was run on my Ubuntu laptop:
The error I get when including the commented out line:
is
|
@hakonhagland have you tried creating the object, and then trying to set the jacobian? There should be some way to set it after creation time |
This function can set the jacobian after creation time:
|
@leto I tried both:
and
both of these give error:
|
We may need more swig/xs glue, similar to the fdf solver stuff that was just merged |
leto, hakonhagland, My thanks to both of you for looking into gsl_odeiv_system. It may be asking a bit much, but would it be possible to add the 'driver' GSL functions to any new distro of Math::GSL::ODEIV? Note that they also require a useful gsl_odeiv_system method. One other question: I have seen reference to 'odeiv2' in the GSL lib and in the Math::GSL::ODEIV package. How does it relate to the functions in the perl libs? Thanx, |
@morgantomj it looks like odeiv2 was added in 1.15 and Math::GSL has never had any glue for it. Just created an issue for that: #157 I haven't used these 'driver' functions before, can you give an example of what you want to do with them? |
Duke,
I'm interested in using the Math::GSL::ODEIV module functions to replace
some code that now uses Numerical Recipes C-code (which is copyrighted).
There is an example of using the gsl driver functions in the gsl example
for the ODEIV C-code. The example shows that the driver functions simplify
solving the ODE system. It still needs the gsl_odeiv_system data type, tho.
I don't quite follow how SWIG is used to glue the gsl C-code together with
perl, but I would guess that the SWIG code for the driver funstions is very
similar to the code for the control or evolution SWIG code. So my naive
view is that extending the code to the driver functions should be fairly
easy and quick...Famous Last Words and Easy for me to say.
Thanx again for you work on this.
Tom Morgan
…On Sat, Oct 20, 2018 at 11:31 AM Duke Leto ***@***.***> wrote:
@morgantomj <https://github.com/morgantomj> it looks like odeiv2 was
added in 1.15 and Math::GSL has never had any glue for it. Just created an
issue for that: #157 <#157>
I haven't used these 'driver' functions before, can you give an example of
what you want to do with them?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#156 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AqQEXDlOBJISNCJkbAfC5BThOUv9sUKUks5um0HCgaJpZM4XZ_ja>
.
|
Duke, gsl_odeiv2_system sys = {func, jac, 2, &mu}; If there were a C-function like ( but properly written): My C-code is poor but he idea is to NOT use the construct 'sys = {...}' but to have a function that returns *sys, given the func, jac, etc. as arguments, then there could be a corresponding swig function to implement it in perl Math::GSL::ODEIV. Ideally this new function would be defined in the gsl C source itself. I think then it would just fall out of the code that builds Math::GSL::ODEIV. I don't know if it's possible to add such a function to the Math::GSL side, so that swig can add it to the pile, assuming the gsl library has already been compiled. Thanks for your work on this ... Tom Morgan |
Implements some typemaps for Math::GSL::ODEIV to fix issue leto#156 for gsl_odeiv_system and gsl_odeiv_evolve_apply().
@morgantomj you might want to look at and test out the latest code from @hakonhagland . it's likely to be merged |
Thu Jan 30 15:55:39 EST 2020 I have been thinking about how to get around the problem of using the Math::GSL::ODEIV module - In the C-code for the gsl library for the ODEIV module, there is a C-code example: /////////////// beginning of C code /////////////// #include <stdio.h> int int int gsl_odeiv2_driver * d = for (i = 1; i <= 100; i++)
gsl_odeiv2_driver_free (d); /////////////// End of C-code ////////////// A few things to notice:
The above all works to solve the user provided ODE system difined by 'func' and 'jac'. The problem, as I see it, occurs when trying to use the perl module Math::GSL::ODEIV Somehow the 4 'sys' structure fields must be correctly assigned to. In particular, So it appears that in order to use the Math::GSL::ODEIV module, the user needs to write By the way, there are other parts of the gls library that require the user to define a C function, I am at the limit of my knowledge of both C, perl, and Dynaloader. Is there some way to use If not SWIG, would it be feasible to use something like Inlne::C to do the same thing. By the way I wrote a C-function which can take the place of the 'sys = {func, jac, 2, &mu}'. ///////////// Beginning of C code system.c //////////////
/* System routine for odeiv2. */ #include <config.h> static gsl_odeiv2_system * sys = (gsl_odeiv2_system *) calloc (1, sizeof (gsl_odeiv2_system)); // this should allocate the space for struct 'sys' if (sys == NULL) sys->function = function; void /////////////// End of system.c ////////// So I'm stumped as to how to get around this problem. Any thoughts? Tom Morgan [email protected] |
Hi Tom, nice to see that you are still working on this issue! Have you tried the code in PR #172 ? I think it solves the problem you are referring to. Can you try the following:
Then create a this Perl test script:
When I run this test script on my Ubuntu laptop I get the expected output. |
@hakonhagland I would like to get some of your stuff merged, but we ran into test failures on GSL 2.6 stuff. What is the current state of things? I haven't looked at this code in a while. |
Håkon Hægland, duke,
Good job ... I was able to run your code successfully after following
your instructions. Then I modified my perl code to mimic yours, and was
able to get mine to run as well.
I had to hide my gsl-2.5 library, and my Math::GSL, but things seem to be
working as advertised. My sincere thanx to the both of you for getting this
to work. I'm not sure how you did it, but I'm very happy you solved the
problem I was having passing ref's to functions, and fill out the '$sys'
structure.
Thanx again to both of you..
Tom Morgan
…On Sun, Feb 2, 2020 at 10:53 PM Duke Leto ***@***.***> wrote:
@hakonhagland <https://github.com/hakonhagland> I would like to get some
of your stuff merged, but we ran into test failures on GSL 2.6 stuff. What
is the current state of things? I haven't looked at this code in a while.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#156?email_source=notifications&email_token=AKSAIXABWZOKN4VMYYQHPJTRA6IMHA5CNFSM4F3H7DNKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKSM24I#issuecomment-581225841>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AKSAIXH3WCPEFSYTYXMGJQDRA6IMHANCNFSM4F3H7DNA>
.
|
@morgantomj all the thanks go to @hakonhagland for this fix, but I am glad that Math::GSL exists and is useful for you! Hopefully we can get this cleaned up and merged and working with recent versions of GSL |
Implements some typemaps for Math::GSL::ODEIV to fix issue leto#156 for gsl_odeiv_system and gsl_odeiv_evolve_apply().
Implements some typemaps for Math::GSL::ODEIV to fix issue leto#156 for gsl_odeiv_system and gsl_odeiv_evolve_apply().
I am following this example: https://www.math.utah.edu/software/gsl/gsl-ref_367.html :
I would like to write this in Perl using
Math::GSL
. I tried:The text was updated successfully, but these errors were encountered: