PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/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
28#ifndef GMPY_RANDOM_H
29#define GMPY_RANDOM_H
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
35/* gmpy_random C API extension header file.
36 *
37 * Provide support random number state.
38 *
39 * Version 2.00, December 2011 (created) casevh
40 *
41 * This file is expected to be included from gmpy.h
42 */
43
44typedef struct {
45    PyObject_HEAD
46    gmp_randstate_t state;
47} GMPYRandomStateObject;
48
49static PyTypeObject GMPYRandomState_Type;
50#define PyObj_AS_STATE(obj) (((GMPYRandomStateObject *)(obj))->state)
51#define GMPYRandomState_Check(v) (((PyObject*)v)->ob_type == &GMPYRandomState_Type)
52
53static GMPYRandomStateObject * GMPYRandomState_New(void);
54static void GMPYRandomState_Dealloc(GMPYRandomStateObject *self);
55static PyObject * GMPYRandomState_Repr(GMPYRandomStateObject *self);
56static PyObject * GMPY_random_state(PyObject *self, PyObject *args);
57static PyObject * GMPY_mpz_urandomb(PyObject *self, PyObject *args);
58static PyObject * GMPY_mpz_rrandomb(PyObject *self, PyObject *args);
59static PyObject * GMPY_mpz_random(PyObject *self, PyObject *args);
60
61#ifdef __cplusplus
62}
63#endif
64#endif