Skip to content

Instantly share code, notes, and snippets.

@imneme
imneme / gjrand.hpp
Created May 28, 2018 07:45
A C++ implementation of David Blackman's GJrand PRNG(s)
#ifndef GJRAND_HPP_INCLUDED
#define GJRAND_HPP_INCLUDED 1
/*
* A C++ implementation of David Blackman's GJrand PRNG(s)
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Melissa E. O'Neill
*
@imneme
imneme / jsf.hpp
Created May 28, 2018 02:40
A C++ Implementation of Bob Jenkins's Small Fast Noncryptographic PRNG (JSF)
#ifndef JSF_HPP_INCLUDED
#define JSF_HPP_INCLUDED 1
/*
* A C++ implementation of a Bob Jenkins Small Fast (Noncryptographic) PRNGs
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Melissa E. O'Neill
*
@imneme
imneme / xoroshiro.hpp
Last active December 3, 2020 22:37
A C++ implementation of a family of Xoroshiro+ generators
#ifndef XOROSHIRO_HPP_INCLUDED
#define XOROSHIRO_HPP_INCLUDED 1
/*
* A C++ implementation of a family of Xoroshiro generators.
*
* See:
* https://en.wikipedia.org/wiki/Xoroshiro128%2B
* http://xoroshiro.di.unimi.it/xoroshiro128plus.c
*
@imneme
imneme / xorshift.hpp
Last active February 15, 2023 17:47
A Family of Truncated XorShift* PRNGs
#ifndef XORSHIFT_HPP_INCLUDED
#define XORSHIFT_HPP_INCLUDED 1
/*
* A C++ implementation of a family of truncated XorShift* generators.
*
* The MIT License (MIT)
*
* Copyright (c) 2017-19 Melissa E. O'Neill
*
@imneme
imneme / randutils.hpp
Last active March 28, 2024 20:43
Addresses common issues with C++11 random number generation; makes good seeding easier, and makes using RNGs easy while retaining all the power.
/*
* Random-Number Utilities (randutil)
* Addresses common issues with C++11 random number generation.
* Makes good seeding easier, and makes using RNGs easy while retaining
* all the power.
*
* The MIT License (MIT)
*
* Copyright (c) 2015-2022 Melissa E. O'Neill
*
// badseed:
// Provides examples showing std::seed_seq is not a bijection
// i.e., that some seeds get repeated for different inputs
// and thus some other seeds must never be generated
#include <random>
#include <iostream>
#include <iomanip>
#include <cstddef>