help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

oct-file with GSL


From: Michael Kopp
Subject: oct-file with GSL
Date: Mon, 22 May 2006 15:57:18 +0200
User-agent: Thunderbird 1.5.0.2 (X11/20060411)

Hello,

I am trying to write an oct-file that uses the random-number generator from
 the GNU Scientific Library (see e.g.
http://www.lsw.uni-heidelberg.de/manuals/gsl-ref-html/gsl-ref_16.html.)

Here is a minimal example:

// *******************************************************************

#include <octave/oct.h>
#include <gsl/gsl_rng.h>

DEFUN_DLD(gsl_rand, args, , "Test function for using octave with GSL.")
{

    // initialize the random number generator mt19937
    // with the first argument and return a list of 10
    // random numbers

    unsigned long seed = (int) args(0).scalar_value();
    octave_value_list retval;

    gsl_rng *rng;
    rng = gsl_rng_alloc(gsl_rng_mt19937);
    gsl_rng_set (rng, seed);
    for(int i=0; i<10; i++) retval(i) = gsl_rng_get(rng);
    return retval;
}

// *******************************************************************

Saving this in a file called gsl_rand.cc and calling

        mkoctfile gsl_rand.cc

works just fine. However, if I try to call

        seed = 1234;
        gsl_rand(seed)

I get an error message stating

        error: /home/michael/gsl_rand.oct:
        undefined symbol: gsl_rng_mt19937
        error: `gsl_rand' undefined near line 2 column 1

Note that gsl_rng_mt19937 is defined in gsl_rng.h and that the C-compiler
does not complain.

Does anyone know what the problem is and how to avoid it?

I am using octave 2.1.71 and gsl-1.6-5 on Suse Linux 9.3.

TIA,

Michael.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]