[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-gsl] gsl_rng_type that needs initialization and cleanup
From: |
Brian Gough |
Subject: |
Re: [Help-gsl] gsl_rng_type that needs initialization and cleanup |
Date: |
Mon, 23 Jul 2007 20:34:35 +0100 |
User-agent: |
Wanderlust/2.14.0 (Africa) Emacs/22.1 Mule/5.0 (SAKAKI) |
At Fri, 20 Jul 2007 06:14:48 -0700,
Henric Jungheim wrote:
> I'm trying to implement a standard gsl_rng_type that is
> backed by a file. The file should be opened when the
> gsl_rng is created, a clone needs to dup() the file handle
> and copy the file offset, and the file needs to be closed
> when gsl_rng_free() is called.
Hello,
Thanks for your email. There is no simple way to do that in GSL. The
way I would recommend is to define an extended type/object in your own
code which includes a gsl_rng object in its struct. The extended type
should have its own custom alloc/free functions, not use the gsl rng
alloc functions.
At the point where you want a plain gsl rng, extract it from the
extended type with a function defined to do that:
rngx * rx = rngx_alloc(Tx, file, ...)
gsl_rng * r = rngx_extract(rx);
--
Brian Gough
(GSL Maintainer)
Network Theory Ltd,
Publishing the GSL Manual - http://www.network-theory.co.uk/gsl/manual/