/src/gmpy_random.h

http://gmpy.googlecode.com/ · C Header · 64 lines · 23 code · 7 blank · 34 comment · 1 complexity · e8675efa45766da5c3ad2214e5e4b95f MD5 · raw file

  1. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  2. * gmpy_random.h *
  3. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  4. * Python interface to the GMP or MPIR, MPFR, and MPC multiple precision *
  5. * libraries. *
  6. * *
  7. * Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, *
  8. * 2008, 2009 Alex Martelli *
  9. * *
  10. * Copyright 2008, 2009, 2010, 2011, 2012, 2013 Case Van Horsen *
  11. * *
  12. * This file is part of GMPY2. *
  13. * *
  14. * GMPY2 is free software: you can redistribute it and/or modify it under *
  15. * the terms of the GNU Lesser General Public License as published by the *
  16. * Free Software Foundation, either version 3 of the License, or (at your *
  17. * option) any later version. *
  18. * *
  19. * GMPY2 is distributed in the hope that it will be useful, but WITHOUT *
  20. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
  21. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public *
  22. * License for more details. *
  23. * *
  24. * You should have received a copy of the GNU Lesser General Public *
  25. * License along with GMPY2; if not, see <http://www.gnu.org/licenses/> *
  26. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  27. #ifndef GMPY_RANDOM_H
  28. #define GMPY_RANDOM_H
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. /* gmpy_random C API extension header file.
  33. *
  34. * Provide support random number state.
  35. *
  36. * Version 2.00, December 2011 (created) casevh
  37. *
  38. * This file is expected to be included from gmpy.h
  39. */
  40. typedef struct {
  41. PyObject_HEAD
  42. gmp_randstate_t state;
  43. } GMPYRandomStateObject;
  44. static PyTypeObject GMPYRandomState_Type;
  45. #define PyObj_AS_STATE(obj) (((GMPYRandomStateObject *)(obj))->state)
  46. #define GMPYRandomState_Check(v) (((PyObject*)v)->ob_type == &GMPYRandomState_Type)
  47. static GMPYRandomStateObject * GMPYRandomState_New(void);
  48. static void GMPYRandomState_Dealloc(GMPYRandomStateObject *self);
  49. static PyObject * GMPYRandomState_Repr(GMPYRandomStateObject *self);
  50. static PyObject * GMPY_random_state(PyObject *self, PyObject *args);
  51. static PyObject * GMPY_mpz_urandomb(PyObject *self, PyObject *args);
  52. static PyObject * GMPY_mpz_rrandomb(PyObject *self, PyObject *args);
  53. static PyObject * GMPY_mpz_random(PyObject *self, PyObject *args);
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif