Import Upstream version 0.8.2
[platform/upstream/mpc.git] / src / urandom.c
1 /* mpc_urandom -- Generate a random complex number uniformly distributed in
2    the interval [0,1[.
3
4 Copyright (C) 2008, 2009 Philippe Th\'eveny
5
6 This file is part of the MPC Library.
7
8 The MPC Library is free software; you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or (at your
11 option) any later version.
12
13 The MPC Library is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
16 License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with the MPC Library; see the file COPYING.LIB.  If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
21 MA 02111-1307, USA. */
22
23 #include "mpc-impl.h"
24
25 int
26 mpc_urandom (mpc_ptr a, gmp_randstate_t state)
27 {
28   int r, i;
29
30   r = mpfr_urandomb (MPC_RE(a), state);
31   i = mpfr_urandomb (MPC_IM(a), state);
32   return r && i;
33 }