[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gh & gsl example not working
From: |
Panagiotis Vossos |
Subject: |
Re: gh & gsl example not working |
Date: |
Thu, 27 Dec 2001 21:08:29 +0200 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
Brian Gough <address@hidden> writes:
> 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.
I tried it, and I think 'gsl_rng_get_uniform' should be
'gsl_rng_uniform'. Other than that, it works as expected. I attach
the new patch below.
Thanks for your help.
--- /home/vozzer/src/guile-1.5.4/doc/ref/gh.texi Fri Aug 24 14:58:36 2001
+++ /home/vozzer/src/guile-1.5.4/doc/ref/gh.texi_patched Thu Dec 27
20:50:27 2001
@@ -182,12 +182,14 @@
@smallexample
#include <guile/gh.h>
-#include <gsl_ran.h>
+#include <gsl/gsl_rng.h>
+
+static gsl_rng * r;
/* random number suite */
SCM gw_ran_seed(SCM s)
@{
- gsl_ran_seed(gh_scm2int(s));
+ gsl_rng_set(r, gh_scm2int(s));
return SCM_UNSPECIFIED;
@}
@@ -195,7 +197,7 @@
@{
SCM x;
- x = gh_ulong2scm(gsl_ran_random());
+ x = gh_ulong2scm(gsl_rng_get(r));
return x;
@}
@@ -203,17 +205,19 @@
@{
SCM x;
- x = gh_double2scm(gsl_ran_uniform());
+ x = gh_double2scm(gsl_rng_uniform(r));
return x;
@}
SCM gw_ran_max()
@{
- return gh_double2scm(gsl_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,7 +241,8 @@
@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}.
+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.