{"id":39461552,"url":"https://github.com/tfpf/mersenne-twister","last_synced_at":"2026-01-18T04:43:39.689Z","repository":{"id":114607686,"uuid":"167185284","full_name":"tfpf/mersenne-twister","owner":"tfpf","description":"High-performance 32- and 64-bit global-state (thread-unsafe) and thread-safe uniform pseudorandom number generators for C, C++ and Python. Provided as an installable package.","archived":false,"fork":false,"pushed_at":"2025-10-19T08:26:22.000Z","size":235,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-19T19:42:56.926Z","etag":null,"topics":["c","global-state","mersenne-twister","mt19937","mt19937-64","random-number-generator","random-numbers","sudoku","sudoku-checker","sudoku-generator","sudoku-solver","thread-safe"],"latest_commit_sha":null,"homepage":"https://tfpf.github.io/mersenne-twister/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tfpf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-01-23T13:09:58.000Z","updated_at":"2025-10-19T08:26:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"75cee867-b272-4f51-b8f6-3efd97a439c4","html_url":"https://github.com/tfpf/mersenne-twister","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/tfpf/mersenne-twister","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfpf%2Fmersenne-twister","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfpf%2Fmersenne-twister/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfpf%2Fmersenne-twister/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfpf%2Fmersenne-twister/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tfpf","download_url":"https://codeload.github.com/tfpf/mersenne-twister/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tfpf%2Fmersenne-twister/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28530067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","global-state","mersenne-twister","mt19937","mt19937-64","random-number-generator","random-numbers","sudoku","sudoku-checker","sudoku-generator","sudoku-solver","thread-safe"],"created_at":"2026-01-18T04:43:39.540Z","updated_at":"2026-01-18T04:43:39.653Z","avatar_url":"https://github.com/tfpf.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"* Makoto Matsumoto and Takuji Nishimura, \"Mersenne Twister: A 623-dimensionally Equidistributed Uniform Pseudo-random\n  Number Generator\", in ACM Transactions on Modeling and Computer Simulation, vol. 8, no. 1, pp. 3-30, 1998,\n  doi:10.1145/272991.272995.\n* Makoto Matsumoto and Takuji Nishimura, \"Mersenne Twister with improved initialization\" [source code],\n  http://www.math.sci.hiroshima-u.ac.jp/m-mat/MT/MT2002/emt19937ar.html, 2002.\n* Christian Stigen Larsen, \"A fast Mersenne Twister in C++\" [source code],\n  https://github.com/cslarsen/mersenne-twister, 2017.\n\n# Mersenne Twister (MT19937): Pseudorandom Number Generators\nThis package provides high-performance 32- and 64-bit global-state (thread-unsafe) and thread-safe uniform pseudorandom\nnumber generators and some utility functions for C. These are intended as replacements for the `rand` family of\nfunctions of the C standard library. An object-oriented C++ API and a module-based Python API are also provided.\n\nThe behaviour of this implementation matches the required behaviour of an MT19937 implementation as set down by the C++\nstandard. However, it is faster than GCC's and Clang's implementations. In theory, its speed is on par with that of C.\nS. Larsen's implementation (which is … extremely fast:sweat_smile:). In practice, it is a couple of nanoseconds\nslower—since it is meant to be used as a shared object, each function has some lookup overhead.\n\nSee [`doc`](doc) for the documentation of this package. [`examples`](examples) contains usage examples and a randomised\nsudoku generator and solver which uses MT19937. For performance analysis, go to [`benchmarks`](benchmarks).\n\n## Installation Requirements\nThese are the versions I have tested the installation with. Older versions may also work. You may not need all of\nthese, depending on how and what you are installing.\n* cURL ≥ 7.68.0\n* GCC ≥ 9.4.0 or Clang ≥ 12.0.0\n* Git ≥ 2.30.2\n* GNU Make ≥ 4.2.1\n* CPython ≥ 3.8 and its C headers and library\n* pip ≥ 23.0\n\nOn Windows, these are available natively via [MSYS2](https://www.msys2.org) and in a Linux environment via\n[WSL](https://learn.microsoft.com/en-us/windows/wsl/about). On macOS, they can be installed using\n[Homebrew](https://brew.sh/); however, their Apple-specific variants provided by\n[Xcode](https://apps.apple.com/app/xcode/id497799835) should also be fine. I am fairly sure that this will work on\nmacOS, though I don't have a Mac to test it.\n\nAny compiler other than GCC and Clang should also be okay, because the code is reasonably standard-compliant. For\ninstance, it doesn't even assume that the `time` function from `stdlib.h` returns an integer. It converts the return\nvalue into an integer, because the return type of `time` is implementation-defined. (Nevertheless, consider creating an\nissue if you encounter compiler errors.)\n\nThe installation commands mentioned below must be entered in\n* the terminal if you are on Linux/macOS, or\n* the MSYS2 terminal or WSL terminal if you are on Windows.\n\n## Install for C (and C++)\n```sh\ncurl https://raw.githubusercontent.com/tfpf/mersenne-twister/main/install.sh | sh\n```\n\nAlternatively:\n```sh\ngit clone https://github.com/tfpf/mersenne-twister.git\ncd mersenne-twister\n./install.sh\n```\nYou can change `Prefix` in [`Makefile`](Makefile) to change the installation location, but then you may additionally\nhave to configure the search paths of your compiler and linker.\n\n### Quick Start\nPut the following code in a file `example.c`:\n```C\n#include \u003cmt19937.h\u003e\n#include \u003cstdio.h\u003e\n\nint main(void)\n{\n    // 32-bit MT19937.\n    mt19937_init32(NULL);\n    for(int i = 0; i \u003c 10; ++i)\n    {\n        long unsigned r = mt19937_rand32(NULL);\n        printf(\"%lu\\n\", r);\n    }\n\n    // 64-bit MT19937.\n    mt19937_init64(NULL);\n    for(int i = 0; i \u003c 10; ++i)\n    {\n        long long unsigned r = mt19937_rand64(NULL);\n        printf(\"%llu\\n\", r);\n    }\n}\n```\ncompile it with\n```sh\ngcc -o example example.c -lmt19937\n```\nand run it using\n```sh\n./example\n```\nto see some random numbers.\n\n## Install for Python\n```\npip install git+https://github.com/tfpf/mersenne-twister.git\n```\n\nAlternatively:\n```sh\ngit clone https://github.com/tfpf/mersenne-twister.git\ncd mersenne-twister\npip install .\n```\n\nThis does not currently work on MSYS2.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfpf%2Fmersenne-twister","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftfpf%2Fmersenne-twister","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftfpf%2Fmersenne-twister/lists"}