Update of /project/cl-gsl/cvsroot/cl-gsl/c
In directory common-lisp.net:/tmp/cvs-serv1293
Modified Files:
cwrapperstub.c
Log Message:
Add wrappers for random-number-generator functions.
Date: Mon May 16 03:31:17 2005
Author: edenny
Index: cl-gsl/c/cwrapperstub.c
diff -u cl-gsl/c/cwrapperstub.c:1.6 cl-gsl/c/cwrapperstub.c:1.7
--- cl-gsl/c/cwrapperstub.c:1.6 Wed May 4 04:50:44 2005
+++ cl-gsl/c/cwrapperstub.c Mon May 16 03:31:16 2005
@@ -18,6 +18,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <gsl/gsl_blas.h>
#include <gsl/gsl_block.h>
@@ -863,6 +864,164 @@
stream = fopen(fn, "r");
ret = gsl_permutation_fscanf(stream, p);
+ fclose(stream);
+
+ return ret;
+}
+
+gsl_rng *wrap_gsl_rng_set_type(char *tp)
+{
+ gsl_rng *r;
+
+ if (strncmp( "borosh13", tp, 8) == 0)
+ r = gsl_rng_alloc (gsl_rng_borosh13);
+ else if (strncmp( "coveyou", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_coveyou);
+ else if (strncmp( "cmrg", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_cmrg);
+ else if (strncmp( "fishman18", tp, 9) == 0)
+ r = gsl_rng_alloc(gsl_rng_fishman18);
+ else if (strncmp( "fishman20", tp, 9) == 0)
+ r = gsl_rng_alloc(gsl_rng_fishman20);
+ else if (strncmp( "fishman2x", tp, 9) == 0)
+ r = gsl_rng_alloc(gsl_rng_fishman2x);
+ else if (strncmp( "gfsr4", tp, 5) == 0)
+ r = gsl_rng_alloc(gsl_rng_gfsr4);
+ else if (strncmp( "knuthran", tp, 8) == 0)
+ r = gsl_rng_alloc(gsl_rng_knuthran);
+ else if (strncmp( "knuthran2", tp, 9) == 0)
+ r = gsl_rng_alloc(gsl_rng_knuthran2);
+ else if (strncmp( "lecuyer21", tp, 9) == 0)
+ r = gsl_rng_alloc(gsl_rng_lecuyer21);
+ else if (strncmp( "minstd", tp, 6) == 0)
+ r = gsl_rng_alloc(gsl_rng_minstd);
+ else if (strncmp( "mrg", tp, 3) == 0)
+ r = gsl_rng_alloc(gsl_rng_mrg);
+ else if (strncmp( "mt19937", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_mt19937);
+ else if (strncmp( "mt19937-1999", tp, 12) == 0)
+ r = gsl_rng_alloc(gsl_rng_mt19937_1999);
+ else if (strncmp( "mt19937-1998", tp, 12) == 0)
+ r = gsl_rng_alloc(gsl_rng_mt19937_1998);
+ else if (strncmp( "r250", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_r250);
+ else if (strncmp( "ran0", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_ran0);
+ else if (strncmp( "ran1", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_ran1);
+ else if (strncmp( "ran2", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_ran2);
+ else if (strncmp( "ran3", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_ran3);
+ else if (strncmp( "rand", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_rand);
+ else if (strncmp( "rand48", tp, 6) == 0)
+ r = gsl_rng_alloc(gsl_rng_rand48);
+ else if (strncmp( "random128-bsd", tp, 13) == 0)
+ r = gsl_rng_alloc(gsl_rng_random128_bsd);
+ else if (strncmp( "random128-glibc2", tp, 16) == 0)
+ r = gsl_rng_alloc(gsl_rng_random128_glibc2);
+ else if (strncmp( "random128-libc5", tp, 15) == 0)
+ r = gsl_rng_alloc(gsl_rng_random128_libc5);
+ else if (strncmp( "random256-bsd", tp, 13) == 0)
+ r = gsl_rng_alloc(gsl_rng_random256_bsd);
+ else if (strncmp( "random256-glibc2", tp, 16) == 0)
+ r = gsl_rng_alloc(gsl_rng_random256_glibc2);
+ else if (strncmp( "random256-libc5", tp, 15) == 0)
+ r = gsl_rng_alloc(gsl_rng_random256_libc5);
+ else if (strncmp( "random32-bsd", tp, 12) == 0)
+ r = gsl_rng_alloc(gsl_rng_random32_bsd);
+ else if (strncmp( "random32-glibc2", tp, 15) == 0)
+ r = gsl_rng_alloc(gsl_rng_random32_glibc2);
+ else if (strncmp( "random32-libc5", tp, 14) == 0)
+ r = gsl_rng_alloc(gsl_rng_random32_libc5);
+ else if (strncmp( "random64-bsd", tp, 12) == 0)
+ r = gsl_rng_alloc(gsl_rng_random64_bsd);
+ else if (strncmp( "random64-glibc2", tp, 15) == 0)
+ r = gsl_rng_alloc(gsl_rng_random64_glibc2);
+ else if (strncmp( "random64-libc5", tp, 14) == 0)
+ r = gsl_rng_alloc(gsl_rng_random64_libc5);
+ else if (strncmp( "random8-bsd", tp, 11) == 0)
+ r = gsl_rng_alloc(gsl_rng_random8_bsd);
+ else if (strncmp( "random8-glibc2", tp, 14) == 0)
+ r = gsl_rng_alloc(gsl_rng_random8_glibc2);
+ else if (strncmp( "random8-libc5", tp, 13) == 0)
+ r = gsl_rng_alloc(gsl_rng_random8_libc5);
+ else if (strncmp( "random-bsd", tp, 10) == 0)
+ r = gsl_rng_alloc(gsl_rng_random_bsd);
+ else if (strncmp( "random-glibc2", tp, 13) == 0)
+ r = gsl_rng_alloc(gsl_rng_random_glibc2);
+ else if (strncmp( "random-libc5", tp, 12) == 0)
+ r = gsl_rng_alloc(gsl_rng_random_libc5);
+ else if (strncmp( "randu", tp, 5) == 0)
+ r = gsl_rng_alloc(gsl_rng_randu);
+ else if (strncmp( "ranf", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranf);
+ else if (strncmp( "ranlux", tp, 6) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlux);
+ else if (strncmp( "ranlux389", tp, 9) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlux389);
+ else if (strncmp( "ranlxd1", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlxd1);
+ else if (strncmp( "ranlxd2", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlxd2);
+ else if (strncmp( "ranlxs0", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlxs0);
+ else if (strncmp( "ranlxs1", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlxs1);
+ else if (strncmp( "ranlxs2", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranlxs2);
+ else if (strncmp( "ranmar", tp, 6) == 0)
+ r = gsl_rng_alloc(gsl_rng_ranmar);
+ else if (strncmp( "slatec", tp, 6) == 0)
+ r = gsl_rng_alloc(gsl_rng_slatec);
+ else if (strncmp( "taus", tp, 4) == 0)
+ r = gsl_rng_alloc(gsl_rng_taus);
+ else if (strncmp( "taus2", tp, 5) == 0)
+ r = gsl_rng_alloc(gsl_rng_taus2);
+ else if (strncmp( "taus113", tp, 7) == 0)
+ r = gsl_rng_alloc(gsl_rng_taus113);
+ else if (strncmp( "transputer", tp, 10) == 0)
+ r = gsl_rng_alloc(gsl_rng_transputer);
+ else if (strncmp( "tt800", tp, 5) == 0)
+ r = gsl_rng_alloc(gsl_rng_tt800);
+ else if (strncmp( "uni", tp, 3) == 0)
+ r = gsl_rng_alloc(gsl_rng_uni);
+ else if (strncmp( "uni32", tp, 5) == 0)
+ r = gsl_rng_alloc(gsl_rng_uni32);
+ else if (strncmp( "vax", tp, 3) == 0)
+ r = gsl_rng_alloc(gsl_rng_vax);
+ else if (strncmp( "waterman14", tp, 10) == 0)
+ r = gsl_rng_alloc(gsl_rng_waterman14);
+ else if (strncmp( "zuf", tp, 3) == 0)
+ r = gsl_rng_alloc(gsl_rng_zuf);
+ else
+ r = gsl_rng_alloc(gsl_rng_default);
+
+ return r;
+}
+
+/* ----------------------------------------------------------------- */
+
+int wrap_gsl_rng_fwrite(char *fn, const gsl_rng *r)
+{
+ FILE* stream;
+ int ret;
+
+ stream = fopen(fn, "wb");
+ ret = gsl_rng_fwrite(stream, r);
+ fclose(stream);
+
+ return ret;
+}
+
+int wrap_gsl_rng_fread(char *fn, gsl_rng *r)
+{
+ FILE* stream;
+ int ret;
+
+ stream = fopen(fn, "rb");
+ ret = gsl_rng_fread(stream, r);
fclose(stream);
return ret;