![]() |
NFFT
3.3.2
|
00001 /* 00002 * Copyright (c) 2002, 2016 Jens Keiner, Stefan Kunis, Daniel Potts 00003 * 00004 * This program is free software; you can redistribute it and/or modify it under 00005 * the terms of the GNU General Public License as published by the Free Software 00006 * Foundation; either version 2 of the License, or (at your option) any later 00007 * version. 00008 * 00009 * This program is distributed in the hope that it will be useful, but WITHOUT 00010 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00011 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 00012 * details. 00013 * 00014 * You should have received a copy of the GNU General Public License along with 00015 * this program; if not, write to the Free Software Foundation, Inc., 51 00016 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "infft.h" 00020 00021 R Y(drand48)(void) 00022 { 00023 #ifdef HAVE_DRAND48 00024 return (R)(drand48()); 00025 #else 00026 return ((R)rand())/((R)RAND_MAX); 00027 #endif 00028 } 00029 00030 void Y(srand48)(long int seed) 00031 { 00032 #ifdef HAVE_SRAND48 00033 srand48(seed); 00034 #else 00035 srand((unsigned int)seed); 00036 #endif 00037 } 00038 00039 void Y(vrand_unit_complex)(C *x, const INT n) 00040 { 00041 INT k; 00042 00043 for (k = 0; k < n; k++) 00044 x[k] = Y(drand48)() + II * Y(drand48)(); 00045 } 00046 00047 void Y(vrand_shifted_unit_double)(R *x, const INT n) 00048 { 00049 INT k; 00050 00051 for (k = 0; k < n; k++) 00052 x[k] = Y(drand48)() - K(0.5); 00053 } 00054 00055 void Y(vrand_real)(R *x, const INT n, const R a, const R b) 00056 { 00057 INT k; 00058 00059 for (k = 0; k < n; k++) 00060 x[k] = a + Y(drand48)() * (b - a); 00061 }