[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gh & gsl example not working
From: |
Brian Gough |
Subject: |
Re: gh & gsl example not working |
Date: |
Wed, 26 Dec 2001 22:07:52 +0000 (GMT) |
Panagiotis Vossos writes:
>
> I have guile 1.5.4 installed and I tried to compile the example from
> "Starting and controlling the interpreter" section of the GH chapter.
> With latest GSL 1.0 installed, it didn't work. I am not familiar with
> neither GSL nor random number generation in general, but a quick
> search of the GSL manual didn't find the functions used in the
> example. The <gsl_ran.h> header seems also wrong, it should be either
> <gsl/gsl_randist.h> or <gsl/gsl_rng.h>. I also checked the latest
> version of the manual from glug/doc-bits but it contains the same
> example.
Hi,
The example was written for a very early alpha version of GSL. The
GSL function names were changed after that. Try the patch below, it's
untested though.
regards
--
Brian Gough
----------------------------------------------------------------------
Network Theory Ltd Phone: +44 (0)117 3179309
15 Royal Park WWW: http://www.network-theory.co.uk/
Clifton Email: address@hidden
Bristol BS8 3AL
----------------------------------------------------------------------
Index: gh.texi
===================================================================
RCS file: /cvsroot/guile/guile/guile-core/doc/ref/gh.texi,v
retrieving revision 1.1
diff -c -r1.1 gh.texi
*** gh.texi 24 Aug 2001 09:40:29 -0000 1.1
--- gh.texi 26 Dec 2001 22:06:13 -0000
***************
*** 182,193 ****
@smallexample
#include <guile/gh.h>
! #include <gsl_ran.h>
/* random number suite */
SCM gw_ran_seed(SCM s)
@{
! gsl_ran_seed(gh_scm2int(s));
return SCM_UNSPECIFIED;
@}
--- 182,195 ----
@smallexample
#include <guile/gh.h>
! #include <gsl/gsl_rng.h>
!
! static gsl_rng * r;
/* random number suite */
SCM gw_ran_seed(SCM s)
@{
! gsl_rng_set(r, gh_scm2int(s));
return SCM_UNSPECIFIED;
@}
***************
*** 195,201 ****
@{
SCM x;
! x = gh_ulong2scm(gsl_ran_random());
return x;
@}
--- 197,203 ----
@{
SCM x;
! x = gh_ulong2scm(gsl_rng_get(r));
return x;
@}
***************
*** 203,219 ****
@{
SCM x;
! x = gh_double2scm(gsl_ran_uniform());
return x;
@}
SCM gw_ran_max()
@{
! return gh_double2scm(gsl_ran_max());
@}
void
init_gsl()
@{
/* random number suite */
gh_new_procedure("gsl-ran-seed", gw_ran_seed, 1, 0, 0);
gh_new_procedure("gsl-ran-random", gw_ran_random, 0, 0, 0);
--- 205,223 ----
@{
SCM x;
! x = gh_double2scm(gsl_rng_get_uniform(r));
return x;
@}
SCM gw_ran_max()
@{
! return gh_double2scm(gsl_rng_max(r));
@}
void
init_gsl()
@{
+ r = gsl_rng_alloc (gsl_rng_default);
+
/* random number suite */
gh_new_procedure("gsl-ran-seed", gw_ran_seed, 1, 0, 0);
gh_new_procedure("gsl-ran-random", gw_ran_random, 0, 0, 0);
***************
*** 237,243 ****
@end smallexample
Then, supposing the C program is in @file{guile-gsl.c}, you could
! compile it with @kbd{gcc -o guile-gsl guile-gsl.c -lguile -lgsl}.
The resulting program @file{guile-gsl} would have new primitive
procedures @code{gsl-ran-random}, @code{gsl-ran-gaussian} and so forth.
--- 241,248 ----
@end smallexample
Then, supposing the C program is in @file{guile-gsl.c}, you could
! compile it with @kbd{gcc -o guile-gsl guile-gsl.c -lguile -lgsl
! -lgslcblas -lm}.
The resulting program @file{guile-gsl} would have new primitive
procedures @code{gsl-ran-random}, @code{gsl-ran-gaussian} and so forth.