• 大小: 7KB
    文件类型: .gz
    金币: 2
    下载: 1 次
    发布日期: 2021-05-27
  • 语言: PHP
  • 标签: php  

资源简介

mt_rand() 产生随机数 随机数种子一样,随机数序列则会完全一相同。 所以知道随机数种子后,就能知道所有随机数序列。(随机数种子 => 随机数序列) 知道随机数后,也能推出随机数种子。(随机数 => 随机数种子 => 随机数序列)

资源截图

代码片段和文件信息

/*
 * Copyright (c) 20122013 Solar Designer 
 *
 * Redistribution and use in source and binary forms with or without
 * modification are permitted.
 *
 * There‘s ABSOLUTELY NO WARRANTY express or implied.
 */

#include 
#include 
#include 
#include 
#include  /* sysconf() */
#include 
#include 

#ifdef __MIC__
#include 
typedef __m512i vtype;
/* hack */
#define _mm_set1_epi32(x) _mm512_set1_epi32(x)
#define _mm_add_epi32(x y) _mm512_add_epi32(x y)
#define _mm_macc_epi32(x y z) _mm512_fmadd_epi32(x y z)
#define _mm_slli_epi32(x i) _mm512_slli_epi32(x i)
#define _mm_srli_epi32(x i) _mm512_srli_epi32(x i)
#define _mm_and_si128(x y) _mm512_and_epi32(x y)
#define _mm_or_si128(x y) _mm512_or_epi32(x y)
#define _mm_xor_si128(x y) _mm512_xor_epi32(x y)
#elif defined(__AVX2__)
#include 
typedef __m256i vtype;
/* hack */
#define _mm_set1_epi32(x) _mm256_set1_epi32(x)
#define _mm_add_epi32(x y) _mm256_add_epi32(x y)
#define _mm_macc_epi32(x y z) \
_mm256_add_epi32(_mm256_mullo_epi32((x) (y)) (z))
#define _mm_slli_epi32(x i) _mm256_slli_epi32(x i)
#define _mm_srli_epi32(x i) _mm256_srli_epi32(x i)
#define _mm_and_si128(x y) _mm256_and_si256(x y)
#define _mm_or_si128(x y) _mm256_or_si256(x y)
#define _mm_xor_si128(x y) _mm256_xor_si256(x y)
#define _mm_cmpeq_epi32(x y) _mm256_cmpeq_epi32(x y)
#define _mm_testz_si128(x y) _mm256_testz_si256(x y)
#elif defined(__SSE4_1__)
#include 
#include 
typedef __m128i vtype;
#ifdef __XOP__
#include 
#else
#define _mm_macc_epi32(a b c) \
_mm_add_epi32(_mm_mullo_epi32((a) (b)) (c))
#ifdef __AVX__
#warning XOP and AVX2 are not enabled. Try gcc -mxop (on AMD Bulldozer or newer) or -mavx2 (on Intel Haswell or newer).
#else
#warning AVX* and XOP are not enabled. Try gcc -mxop (on AMD Bulldozer or newer) -mavx (on Intel Sandy Bridge or newer) or -mavx2 (on Intel Haswell or newer).
#endif
#endif
#else
/*
 * We require at least SSE4.1 for vectorization because we use
 * SSE4.1‘s _mm_mullo_epi32() or XOP‘s _mm_macc_epi32() as well as SSE4.1‘s
 * _mm_testz_si128().
 */
#warning SSE4.1 not enabled will use non-vectorized code. Try gcc -msse4 (only on capable CPUs).
#endif

#ifndef _OPENMP
#warning OpenMP not enabled will only use one CPU core. Try gcc -fopenmp.
#endif

#define M 397
#define N 624

#define MATCH_PURE 1
#define MATCH_FULL 2
#define MATCH_SKIP 4
#define MATCH_LAST 8

typedef struct {
uint32_t flags;
int32_t mmin mmax;
int32_t rmin;
double rspan;
} match_t;

#define NEXT_STATE(x i) \
(x) = 1812433253U * ((x) ^ ((x) >> 30)) + (i);

#if defined(__SSE4_1__) || defined(__AVX2__) || defined(__MIC__)
static inline int diff(uint32_t x uint32_t xs uint32_t seed
    const match_t *match)
#else
static inline int diff(uint32_t x uint32_t x1 uint32_t xs
    const match_t *match)
#endif
{
#if defined(__SSE4_1__) ||

评论

共有 条评论