gsl_qrng.h 2.2 KB

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