| 1 | /* Author: G. Jungman |
| 2 | */ |
| 3 | #ifndef __GSL_QRNG_H__ |
| 4 | #define __GSL_QRNG_H__ |
| 5 | |
| 6 | #include <stdlib.h> |
| 7 | #include "gsl_types.h" |
| 8 | #include "gsl_errno.h" |
| 9 | |
| 10 | #undef __BEGIN_DECLS |
| 11 | #undef __END_DECLS |
| 12 | #ifdef __cplusplus |
| 13 | # define __BEGIN_DECLS extern "C" { |
| 14 | # define __END_DECLS } |
| 15 | #else |
| 16 | # define __BEGIN_DECLS /* empty */ |
| 17 | # define __END_DECLS /* empty */ |
| 18 | #endif |
| 19 | |
| 20 | __BEGIN_DECLS |
| 21 | |
| 22 | |
| 23 | /* Once again, more inane C-style OOP... kill me now. */ |
| 24 | |
| 25 | /* Structure describing a type of generator. |
| 26 | */ |
| 27 | typedef struct |
| 28 | { |
| 29 | const char * name; |
| 30 | unsigned int max_dimension; |
| 31 | size_t (*state_size) (unsigned int dimension); |
| 32 | int (*init_state) (void * state, unsigned int dimension); |
| 33 | int (*get) (void * state, unsigned int dimension, double x[]); |
| 34 | } |
| 35 | gsl_qrng_type; |
| 36 | |
| 37 | /* Structure describing a generator instance of a |
| 38 | * specified type, with generator-specific state info |
| 39 | * and dimension-specific info. |
| 40 | */ |
| 41 | typedef struct |
| 42 | { |
| 43 | const gsl_qrng_type * type; |
| 44 | unsigned int dimension; |
| 45 | size_t state_size; |
| 46 | void * state; |
| 47 | } |
| 48 | gsl_qrng; |
| 49 | |
| 50 | |
| 51 | /* Supported generator types. |
| 52 | */ |
| 53 | GSL_VAR const gsl_qrng_type * gsl_qrng_niederreiter_2; |
| 54 | GSL_VAR const gsl_qrng_type * gsl_qrng_sobol; |
| 55 | |
| 56 | |
| 57 | /* Allocate and initialize a generator |
| 58 | * of the specified type, in the given |
| 59 | * space dimension. |
| 60 | */ |
| 61 | gsl_qrng * gsl_qrng_alloc (const gsl_qrng_type * T, unsigned int dimension); |
| 62 | |
| 63 | |
| 64 | /* Copy a generator. */ |
| 65 | int gsl_qrng_memcpy (gsl_qrng * dest, const gsl_qrng * src); |
| 66 | |
| 67 | |
| 68 | /* Clone a generator. */ |
| 69 | gsl_qrng * gsl_qrng_clone (const gsl_qrng * q); |
| 70 | |
| 71 | |
| 72 | /* Free a generator. */ |
| 73 | void gsl_qrng_free (gsl_qrng * q); |
| 74 | |
| 75 | |
| 76 | /* Intialize a generator. */ |
| 77 | void gsl_qrng_init (gsl_qrng * q); |
| 78 | |
| 79 | |
| 80 | /* Get the standardized name of the generator. */ |
| 81 | const char * gsl_qrng_name (const gsl_qrng * q); |
| 82 | |
| 83 | |
| 84 | /* ISN'T THIS CONFUSING FOR PEOPLE? |
| 85 | WHAT IF SOMEBODY TRIES TO COPY WITH THIS ??? |
| 86 | */ |
| 87 | size_t gsl_qrng_size (const gsl_qrng * q); |
| 88 | |
| 89 | |
| 90 | void * gsl_qrng_state (const gsl_qrng * q); |
| 91 | |
| 92 | |
| 93 | /* Retrieve next vector in sequence. */ |
| 94 | int gsl_qrng_get (const gsl_qrng * q, double x[]); |
| 95 | |
| 96 | |
| 97 | #ifdef HAVE_INLINE |
| 98 | extern inline int gsl_qrng_get (const gsl_qrng * q, double x[]); |
| 99 | extern inline int gsl_qrng_get (const gsl_qrng * q, double x[]) |
| 100 | { |
| 101 | return (q->type->get) (q->state, q->dimension, x); |
| 102 | } |
| 103 | |
| 104 | #endif /* HAVE_INLINE */ |
| 105 | |
| 106 | |
| 107 | __END_DECLS |
| 108 | |
| 109 | |
| 110 | #endif /* !__GSL_QRNG_H__ */ |