Ignore:
Timestamp:
Nov 20, 2022, 10:24:14 PM (18 months ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, master
Children:
910e1d0
Parents:
25b0fde
Message:

major update of PRNG

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/bits/random.hfa

    r25b0fde rd2ad151  
    1010// Created On       : Fri Jan 14 07:18:11 2022
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jan 14 07:18:58 2022
    13 // Update Count     : 1
     12// Last Modified On : Sat Nov 19 17:47:43 2022
     13// Update Count     : 8
    1414//
    1515
     
    1818#include <stdint.h>
    1919
     20#ifdef __x86_64__                                                                               // 64-bit architecture
     21#define LEHMER64
     22#else                                                                                                   // 32-bit architecture
     23#define XORSHIFT_6_21_7
     24#endif // __x86_64__
     25
    2026// Pipelined to allow out-of-order overlap with reduced dependencies. Critically, the current random state is returned
    2127// (copied), and then compute and store the next random value.
     
    2329#if defined(__SIZEOF_INT128__)
    2430//--------------------------------------------------
     31        #ifdef LEHMER64
     32        #define PRNG_ARG_T __uint128_t
     33        #define PRNG_NAME lehmer64
     34        #endif // LEHMER64
     35
    2536        static inline uint64_t lehmer64( __uint128_t & state ) {
    2637                __uint128_t ret = state;
     
    5162
    5263//--------------------------------------------------
     64
     65#ifdef XORSHIFT_6_21_7
     66#define PRNG_ARG_T uint32_t
     67#define PRNG_NAME xorshift_6_21_7
     68#endif // XORSHIFT_6_21_7
     69
    5370static inline uint32_t xorshift_6_21_7( uint32_t & state ) {
    5471        uint32_t ret = state;
Note: See TracChangeset for help on using the changeset viewer.