Debian Codegraph @

plink2_random.h

raw
1 #ifndef __PLINK2_RANDOM_H__
2 #define __PLINK2_RANDOM_H__
3
4 // This library is part of PLINK 2.0, copyright (C) 2005-2025 Shaun Purcell,
5 // Christopher Chang.
6 //
7 // This library is free software: you can redistribute it and/or modify it
8 // under the terms of the GNU Lesser General Public License as published by the
9 // Free Software Foundation, either version 3 of the License, or (at your
10 // option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15 // for more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with this library. If not, see <http://www.gnu.org/licenses/>.
19
20
21 #include "plink2_cmdline.h"
22 #include "include/SFMT.h"
23
24 #ifdef __cplusplus
25 namespace plink2 {
26 #endif
27
28 HEADER_INLINE double RandUnif(sfmt_t* sfmtp) {
29 return (sfmt_genrand_uint32(sfmtp) + 0.5) * kRecip2m32;
30 }
31
32 double RandNormal(sfmt_t* sfmtp, double* secondval_ptr);
33
34 BoolErr InitAllocSfmtpArr(uint32_t thread_ct, uint32_t use_main_sfmt_as_element_zero, sfmt_t* sfmtp, sfmt_t*** sfmtp_arrp);
35
36 PglErr FillGaussianDArr(uintptr_t entry_pair_ct, uint32_t thread_ct, sfmt_t* sfmtp, double* darray);
37
38 PglErr RandomizeBigstack(uint32_t thread_ct, sfmt_t* sfmtp);
39
40 // might not need plink 1.9-style interleaving, but I'll postpone ripping that
41 // out.
42 // currently requires tot_bit_ct > 1, due to quotient operation.
43 void GeneratePerm1Interleaved(uint32_t tot_bit_ct, uint32_t set_bit_ct, uintptr_t perm_start_idx, uintptr_t perm_end_idx, uintptr_t* perm_buf, sfmt_t* sfmtp);
44
45 #ifdef __cplusplus
46 } // namespace plink2
47 #endif
48
49 #endif // __PLINK2_RANDOM_H__