diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-06-20 08:19:41 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-20 08:19:41 -0700 |
commit | 4a0abf48d9246131ee72cfbadf849e05d35267b1 (patch) | |
tree | aa2182f6510ea0a3a5362794843ef6ae913e16f5 /numpy/random/src | |
parent | 0dcd3001eb80a33a60127467fff84747d98c39c8 (diff) | |
parent | 91d34515096622d2ca0e93d12d67567c1122bed1 (diff) | |
download | numpy-4a0abf48d9246131ee72cfbadf849e05d35267b1.tar.gz |
Merge pull request #13791 from mattip/remove-dSFMT
MAINT: remove dSFMT
Diffstat (limited to 'numpy/random/src')
-rw-r--r-- | numpy/random/src/dsfmt/128-bit-jump.poly.txt | 2 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/96-bit-jump.poly.txt | 2 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/LICENSE.md | 34 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/calc-jump.cpp | 81 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-benchmark.c | 43 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-calc-jump.hpp | 106 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-common.h | 115 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-jump.c | 184 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-jump.h | 29 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-params.h | 87 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-params19937.h | 40 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-poly.h | 53 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT-test-gen.c | 58 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT.c | 626 | ||||
-rw-r--r-- | numpy/random/src/dsfmt/dSFMT.h | 697 |
15 files changed, 0 insertions, 2157 deletions
diff --git a/numpy/random/src/dsfmt/128-bit-jump.poly.txt b/numpy/random/src/dsfmt/128-bit-jump.poly.txt deleted file mode 100644 index fea1318fb..000000000 --- a/numpy/random/src/dsfmt/128-bit-jump.poly.txt +++ /dev/null @@ -1,2 +0,0 @@ -jump polynomial: -f4dfa6c62049d0776e0bf6f1e953f3aa38abb113df86be024eab3773ad5f2b82ead936022e656dff7e562691c59dd5f7d2566b78d9669002503c4ddb1888a49f32333f515e6c60c4ecd221078ec6f26f0a90f4875067ca1f399a99775037adf905566e2c7e6b42131420f8f04f112c92621c9b1502f2a8aefad6c667904af62f0d55e02d396902d3b89450103c5ce5fe0408d97cbb864861b49e4e42048ff3310b48faac55095a7f422eea4aade752f947f947c6be0a0c665bdea099246ab9eff658ea8ca468bf49d0227748367878de06d7bd86ea6708fcac6e252f5f00f04309b2aac3036b64afb39d990427c6c9f03477cc7e935c43c0e61bc161db8eb15516eee8cb377ecbc1849207990fb6778721b29bfe0d89bfda1b3772fa5b0b1f7ec3daf36052032285898c6f6396f55010c31f8201b7e2e51d94f920bfe57684c5415cc342cb39a0045d9793d13cf8646096daeb8bb9bfc20a90de8f2426da8733267a9b9674f32154e8f84a9932223a2ca3c787d0b66df6675febbdfcba2f9cef09c621c57e11098b3289c77397aaae8b104642ffe0c4b75598efbc53745984d68b4d6656cae299ae2be55217a9a02b009ca7be32f47fbe434bce4914a34d0c9b0085bede9b8a99319c34660d66f0124b5a7714c4bf3cbfec3ee43ed817087168bad80133bebaeeb68cf7929a24d1bb3de831a8340d220906ab04159cf94b21d5ee813bd7c80f10f01b43052af530917513b169254c25d6fcfe6cb420d6ce92f54886ef6eaf9a5ba35e893ff593834d05ddf28899e42d729c7df3d21ef036020789739366f0c11ec52ff92a0bfd8ba69508e27b20fabb8217bd36b90e5aa918159ac87913bc7b46c04e366c23c92807fbe9c6a407e6a4db0b4fc23c3b6c706b5ca058fe8c190f849f18d16d6b48b5ed760eb202fd566291a799420b9654e08b8118bcbfead8e9dd2fdb9b053e9bdfb665285c78718f726d0b3d6c37e116428ec9ac9db2637259e4e8d6402bbada46c6bdb03985e19a82e9b4e57de1b025a3cb1f850beae7e8da9941655825bce0e89d536b6ee9064865b1a85c185e9fc9cb7f435de13d44773c00eed442a286e4ab807e3cab4dc3441d1b7d2af693812ae8b39652bb8c835fc895d13d6da93541afeadeee450475c29f3b2dfa8ef1c1e2547463b2cc2f0ff7a42ac4dd35e25c4fa030d2d2766fbe9f2d04c1304671747bace2f7dd55142bfa60f8cbc968bfc3d7a342152dc684a0fb5a32c0962a62b5220ac0f72add9d8b84d6cc76b97d03245e01fc8da3414a49bb4075d3488f29b56dc42ba69e3b58529448c943ecfd98b3784a39d0b8609a8fb945e757f4569f53bd2cf80f7f638acf5b67fe9c560a3b7b0cf7e0398f31aa8b03cf9c62b24296b6d8596b694469a02686c38daa16a1ef86e012d61a2f7de1693a5c00b3685175caec3c67146477eba54830f1d546cb18a553779aa46adb4f2010e33f3def847c7d89b51a8462b227605f6c920fd558a6daf64bc98682e508ae960c0c571870e603ba1fce0c13d53176f353fd319959e13db93eae1359f06e3dd4767c04f824cf34ec7bf8f60161ba1a615db82852eca9e3869afa711ab9a090660b0dc6cfbea310dda77e02310fbaeacd2636f975838c2dbcdbe9ac2cd85cee28f5e3f0c73abf62f9fa02cd79a7606b7ba855db68a07848b057c3aaf38f1a70086e14616f6f88305a1f9ce6b41378a620d4db3e0e7e1d421590dccaeff86212e232eeb5eb8a8d33a8c9b25ae88f3a7bd5032b4efa68f8af3186a02ffcbf5456f12beccace94c81c360cc4a0dcc642b59f991eec68c59af78139ca60b96d6a18e9535f8995e89bd2cf6a0aef3acffd33d1c0c1b79b66414a91d9f65b2b4ec65844b96f725d2b4b0c309f3eb9d714e9dd939bbdfd85ce8fb43679aeab13f6c29549949503c9466dbd337c4cdde46d6eacd15f21f4d8fdeaa627a47884c88a9c85f0b731d271a8ea7cb9e04a4a149c23c10f56b3a0476dc77a999d6e4f813e4b0f805e2a693e2ae4ae0ecc423c9ba5d17b42e691abf83784a582f2b1fd85d1e0a27ba38a500963568b2450363d2c5e3f7b8ba3e5b56e4e9f745a3a710bf2ae233c303068c532ce78ff031e6ab28b705dd94d7db4500909edb5626b8c9bd5ff4f0b4741388f0b91563ee516934c013e901572cba005ac5c535f4f107903be9af7b2793dfb61b5070facbe71eefe1b5600f975c8c38c3a2350d78beadfecb78e981164ae8bc866e732972d3ceef4aac68e15861f9b881d9b51b4edece150bc124b07645defb4202ef5d0e0962db98cae6ed459561c93c74c20bd64362e4f4fffc389a6cd80514604ff22eecc10c9cbc7981d19a8102b24146354c463107c9dc070e29e70df3578022acf72289ef071ab9f9402a544d0399f1b1e5f206b6d46d445f6d612a490e72918e00c853eda8493bef511149e80c9ab56e8b4b8cba3987249f77d060e61760e5792ac321c987c03c2606e9393a7970212992cdbd16448078d5039d4c2c3199714f53278f4f7b1d2e514cf95bdfc078b8bb0db659cb2c3f5cc02890ea84f05d414c88d2db9e9f8455659b9fa6254405317245fa070d6970cafb4dadb2522b490a5c8e02fe973a8cdbfbfbdbfb01535099ffba3d3896bc4d1189fc570c3e6fdc6469265b8da912772e75dd62ab71be507f700d56cac5e68fd6b57ec166168ab5258a69625c142a5b1b3519f94be1bde5e51d3bd8ea0c12d5af2fe4615b1b7bd4a96628a4fabc65925ff09718f63bbebaad98f89bd9543a27b3ff3b5d8bfa89f941a5eb8cc005ccd4a705190e1c9dc6a9f4264e5ee658520a4438e92de854bffc39f8dc7dfbb5de4f14ba63ea16a37d14a7b4610f95b6cffd55e4679b29cedbdf20e7bd16da822fad910c359ee3a68e48aae6e769b0e291d5d3aa3e2ca9d8d23abe8a1d5349f4991e9300852cc0befb20c2fc0d169306b260763344024f8092cbcc24c6807363e9fc548a30d5faab3a94b2af0782a2942be80c45d8b0587efd587394ef33c33022436e285806ddffdd32fe36345c3c38ed8d680abeb7a028b44ee6f94d060a14c7019bb6af1f1b5f0a562957d19826d8cc216f9b908c989ccd5415e3525dfe9422ffb5b50b7cc3083dc325544751e5683535d7439d3da2b0bb73bea551dd99e04e0e793804f4774eb6b1daf781d9caa5128274e599e847862fe309027813d3e4eda0bbeb7201856a5c5d8370e44dabff0bb229c723ba0a6bcf29c44536147de11b7835991018100105bd4329217f7386903fe8e7363cd7b3e893244e245e0a187467664c05b0be1fd429722b9b9a5e3198147fad72776e8a63aab9054fa9d259af0198d088d71d132e6068676a8e9ebb0f616b51ee34aac39c2c2221c71124017270d75ff4a048363c389e04e9b440ad2032a381ac2cfc54f409caa791e65ee4f5d6cd035008f219b88a803a7382ae447bf65a3df2176b25b3b7b67dabe34decd9a1384dc7a003916ca8fbcb29b3ad6fd8eac5bbbaa3bdfa6c6a3ad9427c4f3ed79fea26e14c8ce5fa3b4f82c5f7b6d2125916753a7b92ce9b46d45 diff --git a/numpy/random/src/dsfmt/96-bit-jump.poly.txt b/numpy/random/src/dsfmt/96-bit-jump.poly.txt deleted file mode 100644 index 15c68d155..000000000 --- a/numpy/random/src/dsfmt/96-bit-jump.poly.txt +++ /dev/null @@ -1,2 +0,0 @@ -jump polynomial: -288da521f7244e5f62bf26692bdd1fcdfd38a850addb02d98bd358367cb78c71348f3e163522e0e30e4feb90aa210dd793c94d151fa89aa319911aa42b511ea568a503d595c6d9bcd37317a37ef5679700a5b67f29df72451770fc1eb8c97427cdd9825c23f32dcd5c4fb117a4f5982a3bee8f16595d021165cd9688db342e360e222c9855c8306fd7b5fc82e62e3b1765e7f3319da9da66c325b030bd6175876efc70636306cd2de31a299ca20e9eb1d5063bcbff0ba282aff4737a5b1585cd940ae9cd45fda222308341e0d5588e81b42c4e0574deeb2d80b84c00cb3f8a7ae6278462e1994b83a25b33aa0dc74d5d3d057dabfd6a8a82d7dfb6bb66a223bc46dca2b5fb1885e6ab80fddcd6578b32c21c4a9d761cb9798800c921d56ee356c491454e15956e68ef566c1706fcdfb6a6828ec1fb93db455525828e8741a371c14959658b99bbd358a162230ee451a8432df279e4ba0d3a493954359a5390b16475540578270b168054fefb1e20948d4d20c88005ed09e671b6a94b8ea929f72e7b2f85af4098a92d742b64964ea6b7773b2c20b22a0ff35bd9367c3160b549411230e15a987f361e04daac49d2fe4c7c9371d84bf270d8f33a62680b2ee014bf5be691aa0d82e66e885eaa832a241aff8a09c435ac2b0698bc3865c5125d498a4ffadd31d5f2c6aee6496fdc6c13055b53e7f65a683ef539b6e8ea6e21429a11ff74ccef09ee83eac1b5ddaf1b77fed786fd20e8cbb3e8877b7f80a24fef31a9f8d8108099c50abc886f7ab20c4396bf51af1b806003185eaf2061f55036e26f498b92aabadfb6b5bed2d116b32ae387a692058e6160a9508dc44c971454d9a357ba115278861be0aeaa0926d773c5d4563e37dffcfed8bbf44b79e384650b7eff30aae73154a2ef130cee1eaf32d944e5472ae217789c03276deb8290c73dd5cde0b6dce9b28cbb73776e3e52260768f37a38db3d1c26c3c065b641c7a825edc155d947118d8b6ff8c8818440088724261ca83fa866aa4159fbffac8c28c8a7ca5f1e2fde74b4908c8215cbde20190bdf0de1d5a05a2c116a66eeadcafd643098e74ec3e82b3658c0c4fd7c7797d567b8db3d6b67ca262d713dbf45cc80b89f279be0991f276a4501d2ea6222026caa7e6fbcf4d02fdf65d8f439f88cfb1121d1b0f4dd670d146b93e099a32869448d837e347229745e5c30f1521b0c477b2062c9c8f631dcd29664eec7f28bdcac2a1ca2deabbbc89b21824ba92a61eeb4c5dd62b20c346134d842bcfc189f0e2244bfb8596c38c88d5bd4447fcd30890a4acf71801a6bcf5d806073b9ca730db53e160a79516333748708dd5e5be37d75e90e64d14ddf5ccc9390ae67cbba39916ce9b3b6b1d19378e4bd36ef0c9e62570394051cc273122e0790e381b20e083beca6e88bc2fa8bde22c89689b4b710c775cd9065158b48bf855fc3a3e80693908046ea1da9c558f024ea5ea69d65f40317fc3c8bab7606bf7edf17fcaeb706756c4de38319a51fc24c80a2baccef40f4354f5147fb91c9b1b91011d146da7eeb426d25de17d7e39ee53735ef28b64d5e6e5444676f679a8e4e91314377c7606531b90dc1cd8cf2d929ed9137fdc0d6b6db62e764ef200a439d742b51425b818231ed799a53768119466cc42296ce36f52507411709cd9d622c1f899291db27104589a5e4509d9818cef983d6a13ce1247184c4551c38bd319aa068cd9c0b96f9e08b4a7bd7852c129d4126676cbcb30ae029b0e2cec3c58c110fecae7967fca0752874e2fcc077084dd4d87b4dee632b621f35cb9f22639ab4de86089c56cabb1aa8a4fedbc5d8673cca12b4479dca5dc6f3048bb654fd59c464b033960177a4d6c2ee38b124d193cd5da3cbc5aa5ebdf7197f5d3f3008f01effb599b6d238044f2ee204bf372685256813278ca7a7d145445f5d5eb5490d99ee89d587fe446e1600d7daf9553b7d709bd796c59757e2f7c26cb71990a51ffc49120f358ef4927729b7e8c2cf9ad35a8017667625a39e2d12c8b0dd5de3d3797d9167ac9302a122e0f066a2552a7278a632b043089a1f5a127ce0bc8e688c545f20bca467fd58d9f9b8234f2be7a28152ab4d39ba8d6c4471d574571aa1a4a3aca16f46ac74e664899cf24502334aec637a9c392ba1618340080bfaed493abaa2f684ffb2bc1da86d804305772e30893f67235d5ce8180ef60490e46f131465d249a39df1aaed30621169c0f7db0b6a6adcab975ec00ca68b2fc06f443cfb8933b326f106670e0e528f22ff96d06b2a6d917258d29a87cf637f37c3661b42462c11c73c1cd0a6774e4e10157b02c0cfd9148ad8a23775653db3dec41fd6d1d5eb54a3e5e144a489a18412f21eb96a72b6751482882d636a1cd0057ea48d1a985472b0c301c4a5b24b0152bdc50a47126a01a1d0665270cdbf2ed852e0f61515bad6e58973329d269bf057ffa52331dde4700b926f635cdf49234f4aaabbabca5386526568fc3a80b1d8a9e1566e21bf889546379289263d978e95de390c4bbdb5a813535b7186f661f5c283400adb3bcf9365d45abb6088b729a98789265f1e8e684e2b2c15b4ce53230abc5e5bf6895827c95842e0849fc7fe56b7c65f075baded0f2e172c8e1088219615b8697ff4a3c6f5f708e498e6c7312680f214a877061511d3b85087545fc26708d039e977a0157b95ceba40497cc2dd1b1b1394eb98f651d701dfbc3583c159da8bae76a25db213211d6191d83c5d7a3d4b2320b8a305b5d90e04d6e3de161fff5dae7e3d4f6c9e1cf55cb5ac1677d9cfd560db2209be2b9566a267aad9cf4b9e03c221ba5b0f02cabb50cef19180ba329691d114da670d7b85e36c0b6b7d81613bd31350dfe225050861e90043ac2334478f52584a1a8809f76d40af36da02549c54da164487f0b7f823cff797db1c90f2f1c431eca97fc8bcdfb44c30cd1643c893d5e33aa56cbc0a0c38f5c8f6bb37483d13b85b659ac51ce05311bba19c97772e81c2315a009e80f591c82445d493dc3b5fb12c52e8c50c6260200b0d77092bf19aabce491b2c511fca2a4ebd99b446e55f453314297723894f0b223868ef80f5964468afa3a5e6aa41f2128e6de893bba2cbde9bea91ba97bda18a01905ce8d2e85e6011cc0550f5ae9121361fdec1ec97a6e6892a68732a69147476d54babaa564b883baad7100eb1092a1aa28a29f67e6b53deab511e53eada87cfe1bb6e3c6a215fd8d729840a5b5ac452cfd8acb9be7818d2c806c3e0cedd0847ddf9a5906bf1a0fa4da44ccea829a1a5350d5db0241a221b97e5cd5ba15e58b402529317c854fbcda86a562d4ee44a34193513647af0a3bc9f90ababc1dbbfd9aba8d3dcc39463473ca6bc0e1dc736ba712eef42dee80e31e7d8abe23f98e91ab875d0553bc24be9cb1d9484812c0b038cb177ad52064328e17f8ca7c8737902d964017e3aaae66161270dac21de42a6f60d10d89c1556916a249a130752bb7c7783b93a59d9f5456745ecc512f497b5a31be2678b9587628cb45dae2f5f6bde7ea4500c1ba961e2 diff --git a/numpy/random/src/dsfmt/LICENSE.md b/numpy/random/src/dsfmt/LICENSE.md deleted file mode 100644 index d59568f6b..000000000 --- a/numpy/random/src/dsfmt/LICENSE.md +++ /dev/null @@ -1,34 +0,0 @@ -# DSFMT - -Copyright (c) 2007, 2008, 2009 Mutsuo Saito, Makoto Matsumoto -and Hiroshima University. -Copyright (c) 2011, 2002 Mutsuo Saito, Makoto Matsumoto, Hiroshima -University and The University of Tokyo. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - -* Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -* Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. -* Neither the name of the Hiroshima University nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written - permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/numpy/random/src/dsfmt/calc-jump.cpp b/numpy/random/src/dsfmt/calc-jump.cpp deleted file mode 100644 index 495b2797c..000000000 --- a/numpy/random/src/dsfmt/calc-jump.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/** - * @file calc-jump.cpp - * - * @brief calc jump function. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (The University of Tokyo) - * - * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, - * Hiroshima University and The University of Tokyo. - * All rights reserved. - * - * The 3-clause BSD License is applied to this software, see - * LICENSE.txt - * - * Compile: - * g++ calc-jump.cpp -o calc-jump -lntl - * - * Compute polynomial for 2^128 steps: - * ./calc-jump 340282366920938463463374607431768211456 poly.19937.txt - * - */ -#include <iostream> -#include <fstream> -#include <iomanip> -#include <sstream> -#include <string> -#include <inttypes.h> -#include <stdint.h> -#include <time.h> -#include <NTL/GF2X.h> -#include <NTL/vec_GF2.h> -#include <NTL/ZZ.h> -#include "dSFMT-calc-jump.hpp" - -using namespace NTL; -using namespace std; -using namespace dsfmt; - -static void read_file(GF2X& lcmpoly, long line_no, const string& file); - -int main(int argc, char * argv[]) { - if (argc <= 2) { - cout << argv[0] << " jump-step poly-file" << endl; - cout << " jump-step: a number between zero and 2^{DSFMT_MEXP}-1.\n" - << " large decimal number is allowed." << endl; - cout << " poly-file: one of poly.{MEXP}.txt " - << "file" << endl; - return -1; - } - string step_string = argv[1]; - string filename = argv[2]; - long no = 0; - GF2X lcmpoly; - read_file(lcmpoly, no, filename); - ZZ step; - stringstream ss(step_string); - ss >> step; - string jump_str; - calc_jump(jump_str, step, lcmpoly); - cout << "jump polynomial:" << endl; - cout << jump_str << endl; - return 0; -} - - -static void read_file(GF2X& lcmpoly, long line_no, const string& file) -{ - ifstream ifs(file.c_str()); - string line; - for (int i = 0; i < line_no; i++) { - ifs >> line; - ifs >> line; - } - if (ifs) { - ifs >> line; - line = ""; - ifs >> line; - } - stringtopoly(lcmpoly, line); -} diff --git a/numpy/random/src/dsfmt/dSFMT-benchmark.c b/numpy/random/src/dsfmt/dSFMT-benchmark.c deleted file mode 100644 index af29d0e1f..000000000 --- a/numpy/random/src/dsfmt/dSFMT-benchmark.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * - * cl dsfmt-benchmark.c dSFMT.c /Ox -DHAVE_SSE2 - * - * gcc dSFMT-benchmark.c dSFMT.c -O3 -DHAVE_SSE2 -DDSFMT_MEXP=19937 -o - * dSFMT-benchmark - */ -#include <inttypes.h> -#include <time.h> - -#include "dSFMT.h" - - -#define N 1000000000 - -int main() { - int i, j; - uint32_t seed = 0xDEADBEAF; - uint64_t count = 0, sum = 0; - dsfmt_t state; - double buffer[DSFMT_N64]; - - uint64_t out; - uint64_t *tmp; - dsfmt_init_gen_rand(&state, seed); - clock_t begin = clock(); - for (i = 0; i < N / (DSFMT_N64 / 2); i++) { - dsfmt_fill_array_close_open(&state, &buffer[0], DSFMT_N64); - for (j = 0; j < DSFMT_N64; j += 2) { - tmp = (uint64_t *)&buffer[j]; - out = (*tmp >> 16) << 32; - tmp = (uint64_t *)&buffer[j + 1]; - out |= (*tmp >> 16) & 0xffffffff; - sum += out; - count++; - } - } - clock_t end = clock(); - double time_spent = (double)(end - begin) / CLOCKS_PER_SEC; - printf("0x%" PRIx64 "\ncount: %" PRIu64 "\n", sum, count); - printf("%" PRIu64 " randoms per second\n", - (uint64_t)(N / time_spent) / 1000000 * 1000000); -} diff --git a/numpy/random/src/dsfmt/dSFMT-calc-jump.hpp b/numpy/random/src/dsfmt/dSFMT-calc-jump.hpp deleted file mode 100644 index b960826be..000000000 --- a/numpy/random/src/dsfmt/dSFMT-calc-jump.hpp +++ /dev/null @@ -1,106 +0,0 @@ -#pragma once -#ifndef DSFMT_CALC_JUMP_HPP -#define DSFMT_CALC_JUMP_HPP -/** - * @file dSFMT-calc-jump.hpp - * - * @brief functions for calculating jump polynomial. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (The University of Tokyo) - * - * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, - * Hiroshima University and The University of Tokyo. - * All rights reserved. - * - * The 3-clause BSD License is applied to this software, see - * LICENSE.txt - */ -#include <iostream> -#include <iomanip> -#include <sstream> -#include <NTL/GF2X.h> - -namespace dsfmt { -/** - * converts polynomial to string for convenient use in C language. - * @param x output string - * @param polynomial input polynomial - */ - static inline void polytostring(std::string& x, NTL::GF2X& polynomial) - { - using namespace NTL; - using namespace std; - - long degree = deg(polynomial); - int buff; - stringstream ss; - for (int i = 0; i <= degree; i+=4) { - buff = 0; - for (int j = 0; j < 4; j++) { - if (IsOne(coeff(polynomial, i + j))) { - buff |= 1 << j; - } else { - buff &= (0x0f ^ (1 << j)); - } - } - ss << hex << buff; - } - ss << flush; - x = ss.str(); - } - -/** - * converts string to polynomial - * @param str string - * @param poly output polynomial - */ - static inline void stringtopoly(NTL::GF2X& poly, std::string& str) - { - using namespace NTL; - using namespace std; - - stringstream ss(str); - char c; - long p = 0; - clear(poly); - while(ss) { - ss >> c; - if (!ss) { - break; - } - if (c >= 'a') { - c = c - 'a' + 10; - } else { - c = c - '0'; - } - for (int j = 0; j < 4; j++) { - if (c & (1 << j)) { - SetCoeff(poly, p, 1); - } else { - SetCoeff(poly, p, 0); - } - p++; - } - } - } - -/** - * calculate the jump polynomial. - * SFMT generates 4 32-bit integers from one internal state. - * @param jump_str output string which represents jump polynomial. - * @param step jump step of internal state - * @param characteristic polynomial - */ - static inline void calc_jump(std::string& jump_str, - NTL::ZZ& step, - NTL::GF2X& characteristic) - { - using namespace NTL; - using namespace std; - GF2X jump; - PowerXMod(jump, step, characteristic); - polytostring(jump_str, jump); - } -} -#endif diff --git a/numpy/random/src/dsfmt/dSFMT-common.h b/numpy/random/src/dsfmt/dSFMT-common.h deleted file mode 100644 index 30c26c08b..000000000 --- a/numpy/random/src/dsfmt/dSFMT-common.h +++ /dev/null @@ -1,115 +0,0 @@ -#pragma once -/** - * @file dSFMT-common.h - * - * @brief SIMD oriented Fast Mersenne Twister(SFMT) pseudorandom - * number generator with jump function. This file includes common functions - * used in random number generation and jump. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (The University of Tokyo) - * - * Copyright (C) 2006, 2007 Mutsuo Saito, Makoto Matsumoto and Hiroshima - * University. - * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, Hiroshima - * University and The University of Tokyo. - * All rights reserved. - * - * The 3-clause BSD License is applied to this software, see - * LICENSE.txt - */ -#ifndef DSFMT_COMMON_H -#define DSFMT_COMMON_H - -#include "dSFMT.h" - -#if defined(HAVE_SSE2) -# include <emmintrin.h> -union X128I_T { - uint64_t u[2]; - __m128i i128; -}; -union X128D_T { - double d[2]; - __m128d d128; -}; -/** mask data for sse2 */ -static const union X128I_T sse2_param_mask = {{DSFMT_MSK1, DSFMT_MSK2}}; -#endif - -#if defined(HAVE_ALTIVEC) -inline static void do_recursion(w128_t *r, w128_t *a, w128_t * b, - w128_t *lung) { - const vector unsigned char sl1 = ALTI_SL1; - const vector unsigned char sl1_perm = ALTI_SL1_PERM; - const vector unsigned int sl1_msk = ALTI_SL1_MSK; - const vector unsigned char sr1 = ALTI_SR; - const vector unsigned char sr1_perm = ALTI_SR_PERM; - const vector unsigned int sr1_msk = ALTI_SR_MSK; - const vector unsigned char perm = ALTI_PERM; - const vector unsigned int msk1 = ALTI_MSK; - vector unsigned int w, x, y, z; - - z = a->s; - w = lung->s; - x = vec_perm(w, (vector unsigned int)perm, perm); - y = vec_perm(z, (vector unsigned int)sl1_perm, sl1_perm); - y = vec_sll(y, sl1); - y = vec_and(y, sl1_msk); - w = vec_xor(x, b->s); - w = vec_xor(w, y); - x = vec_perm(w, (vector unsigned int)sr1_perm, sr1_perm); - x = vec_srl(x, sr1); - x = vec_and(x, sr1_msk); - y = vec_and(w, msk1); - z = vec_xor(z, y); - r->s = vec_xor(z, x); - lung->s = w; -} -#elif defined(HAVE_SSE2) -/** - * This function represents the recursion formula. - * @param r output 128-bit - * @param a a 128-bit part of the internal state array - * @param b a 128-bit part of the internal state array - * @param d a 128-bit part of the internal state array (I/O) - */ -inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *u) { - __m128i v, w, x, y, z; - - x = a->si; - z = _mm_slli_epi64(x, DSFMT_SL1); - y = _mm_shuffle_epi32(u->si, SSE2_SHUFF); - z = _mm_xor_si128(z, b->si); - y = _mm_xor_si128(y, z); - - v = _mm_srli_epi64(y, DSFMT_SR); - w = _mm_and_si128(y, sse2_param_mask.i128); - v = _mm_xor_si128(v, x); - v = _mm_xor_si128(v, w); - r->si = v; - u->si = y; -} -#else -/** - * This function represents the recursion formula. - * @param r output 128-bit - * @param a a 128-bit part of the internal state array - * @param b a 128-bit part of the internal state array - * @param lung a 128-bit part of the internal state array (I/O) - */ -inline static void do_recursion(w128_t *r, w128_t *a, w128_t * b, - w128_t *lung) { - uint64_t t0, t1, L0, L1; - - t0 = a->u[0]; - t1 = a->u[1]; - L0 = lung->u[0]; - L1 = lung->u[1]; - lung->u[0] = (t0 << DSFMT_SL1) ^ (L1 >> 32) ^ (L1 << 32) ^ b->u[0]; - lung->u[1] = (t1 << DSFMT_SL1) ^ (L0 >> 32) ^ (L0 << 32) ^ b->u[1]; - r->u[0] = (lung->u[0] >> DSFMT_SR) ^ (lung->u[0] & DSFMT_MSK1) ^ t0; - r->u[1] = (lung->u[1] >> DSFMT_SR) ^ (lung->u[1] & DSFMT_MSK2) ^ t1; -} -#endif -#endif diff --git a/numpy/random/src/dsfmt/dSFMT-jump.c b/numpy/random/src/dsfmt/dSFMT-jump.c deleted file mode 100644 index 1832bb885..000000000 --- a/numpy/random/src/dsfmt/dSFMT-jump.c +++ /dev/null @@ -1,184 +0,0 @@ -/** - * @file dSFMT-jump.c - * - * @brief do jump using jump polynomial. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (The University of Tokyo) - * - * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, - * Hiroshima University and The University of Tokyo. - * All rights reserved. - * - * The 3-clause BSD License is applied to this software, see - * LICENSE.txt - */ - -#include <assert.h> -#include <stdlib.h> -#include <ctype.h> -#include <string.h> -#include "dSFMT-params.h" -#include "dSFMT.h" -#include "dSFMT-jump.h" -#include "dSFMT-common.h" - -#if defined(__cplusplus) -extern "C" { -#endif - - struct FIX_T { - int mexp; - uint64_t fix[4]; - }; - - struct FIX_T fix_table[] = { - {521, {UINT64_C(0x3fff56977f035125), - UINT64_C(0x3ff553857b015035), - UINT64_C(0x4034434434434434), - UINT64_C(0x0140151151351371)}}, - {1279, {UINT64_C(0x3ff87befce70e89f), - UINT64_C(0x3ff5f6afa3c60868), - UINT64_C(0xa4ca4caccaccacdb), - UINT64_C(0x40444444444c44c4)}}, - {4253, {UINT64_C(0x3ff85a66da51a81a), - UINT64_C(0x3ff4f4aeab9688eb), - UINT64_C(0x20524524534d34d3), - UINT64_C(0xc9cc9cc9cc9ccdcf)}}, - {216091, {UINT64_C(0x3ff096d54a871071), - UINT64_C(0x3ffafa9bfbd5d55d), - UINT64_C(0x0470470470573573), - UINT64_C(0x0250250251259259)}}, - {0} - }; - - inline static void next_state(dsfmt_t * dsfmt); - -#if defined(HAVE_SSE2) -/** - * add internal state of src to dest as F2-vector. - * @param dest destination state - * @param src source state - */ - inline static void add(dsfmt_t *dest, dsfmt_t *src) { - int dp = dest->idx / 2; - int sp = src->idx / 2; - int diff = (sp - dp + DSFMT_N) % DSFMT_N; - int p; - int i; - for (i = 0; i < DSFMT_N - diff; i++) { - p = i + diff; - dest->status[i].si - = _mm_xor_si128(dest->status[i].si, src->status[p].si); - } - for (i = DSFMT_N - diff; i < DSFMT_N; i++) { - p = i + diff - DSFMT_N; - dest->status[i].si - = _mm_xor_si128(dest->status[i].si, src->status[p].si); - } - dest->status[DSFMT_N].si - = _mm_xor_si128(dest->status[DSFMT_N].si, - src->status[DSFMT_N].si); - } -#else - inline static void add(dsfmt_t *dest, dsfmt_t *src) { - int dp = dest->idx / 2; - int sp = src->idx / 2; - int diff = (sp - dp + DSFMT_N) % DSFMT_N; - int p; - int i; - for (i = 0; i < DSFMT_N - diff; i++) { - p = i + diff; - dest->status[i].u[0] ^= src->status[p].u[0]; - dest->status[i].u[1] ^= src->status[p].u[1]; - } - for (; i < DSFMT_N; i++) { - p = i + diff - DSFMT_N; - dest->status[i].u[0] ^= src->status[p].u[0]; - dest->status[i].u[1] ^= src->status[p].u[1]; - } - dest->status[DSFMT_N].u[0] ^= src->status[DSFMT_N].u[0]; - dest->status[DSFMT_N].u[1] ^= src->status[DSFMT_N].u[1]; - } -#endif - -/** - * calculate next state - * @param dsfmt dSFMT internal state - */ - inline static void next_state(dsfmt_t * dsfmt) { - int idx = (dsfmt->idx / 2) % DSFMT_N; - w128_t * lung; - w128_t * pstate = &dsfmt->status[0]; - - lung = &pstate[DSFMT_N]; - do_recursion(&pstate[idx], - &pstate[idx], - &pstate[(idx + DSFMT_POS1) % DSFMT_N], - lung); - dsfmt->idx = (dsfmt->idx + 2) % DSFMT_N64; - } - - inline static void add_fix(dsfmt_t * dsfmt) { - int i; - int index = -1; - for (i = 0; fix_table[i].mexp != 0; i++) { - if (fix_table[i].mexp == DSFMT_MEXP) { - index = i; - } - if (fix_table[i].mexp > DSFMT_MEXP) { - break; - } - } - if (index < 0) { - return; - } - for (i = 0; i < DSFMT_N; i++) { - dsfmt->status[i].u[0] ^= fix_table[index].fix[0]; - dsfmt->status[i].u[1] ^= fix_table[index].fix[1]; - } - dsfmt->status[DSFMT_N].u[0] ^= fix_table[index].fix[2]; - dsfmt->status[DSFMT_N].u[1] ^= fix_table[index].fix[3]; - } - -/** - * jump ahead using jump_string - * @param dsfmt dSFMT internal state input and output. - * @param jump_string string which represents jump polynomial. - */ - void dSFMT_jump(dsfmt_t * dsfmt, const char * jump_string) { - dsfmt_t work; - int index = dsfmt->idx; - int bits; - int i; - int j; - memset(&work, 0, sizeof(dsfmt_t)); - add_fix(dsfmt); - dsfmt->idx = DSFMT_N64; - - for (i = 0; jump_string[i] != '\0'; i++) { - bits = jump_string[i]; - assert(isxdigit(bits)); - bits = tolower(bits); - if (bits >= 'a' && bits <= 'f') { - bits = bits - 'a' + 10; - } else { - bits = bits - '0'; - } - bits = bits & 0x0f; - for (j = 0; j < 4; j++) { - if ((bits & 1) != 0) { - add(&work, dsfmt); - } - next_state(dsfmt); - bits = bits >> 1; - } - } - *dsfmt = work; - add_fix(dsfmt); - dsfmt->idx = index; - } - -#if defined(__cplusplus) -} -#endif diff --git a/numpy/random/src/dsfmt/dSFMT-jump.h b/numpy/random/src/dsfmt/dSFMT-jump.h deleted file mode 100644 index 689f9499a..000000000 --- a/numpy/random/src/dsfmt/dSFMT-jump.h +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once -#ifndef DSFMT_JUMP_H -#define DSFMT_JUMP_H -/** - * @file SFMT-jump.h - * - * @brief jump header file. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (The University of Tokyo) - * - * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, - * Hiroshima University and The University of Tokyo. - * All rights reserved. - * - * The 3-clause BSD License is applied to this software, see - * LICENSE.txt - */ -#if defined(__cplusplus) -extern "C" { -#endif - -#include "dSFMT.h" -void dSFMT_jump(dsfmt_t *dsfmt, const char *jump_str); - -#if defined(__cplusplus) -} -#endif -#endif diff --git a/numpy/random/src/dsfmt/dSFMT-params.h b/numpy/random/src/dsfmt/dSFMT-params.h deleted file mode 100644 index aa0247800..000000000 --- a/numpy/random/src/dsfmt/dSFMT-params.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef DSFMT_PARAMS_H -#define DSFMT_PARAMS_H - -#include "dSFMT.h" - -/*---------------------- - the parameters of DSFMT - following definitions are in dSFMT-paramsXXXX.h file. - ----------------------*/ -/** the pick up position of the array. -#define DSFMT_POS1 122 -*/ - -/** the parameter of shift left as four 32-bit registers. -#define DSFMT_SL1 18 - */ - -/** the parameter of shift right as four 32-bit registers. -#define DSFMT_SR1 12 -*/ - -/** A bitmask, used in the recursion. These parameters are introduced - * to break symmetry of SIMD. -#define DSFMT_MSK1 (uint64_t)0xdfffffefULL -#define DSFMT_MSK2 (uint64_t)0xddfecb7fULL -*/ - -/** These definitions are part of a 128-bit period certification vector. -#define DSFMT_PCV1 UINT64_C(0x00000001) -#define DSFMT_PCV2 UINT64_C(0x00000000) -*/ - -#define DSFMT_LOW_MASK UINT64_C(0x000FFFFFFFFFFFFF) -#define DSFMT_HIGH_CONST UINT64_C(0x3FF0000000000000) -#define DSFMT_SR 12 - -/* for sse2 */ -#if defined(HAVE_SSE2) - #define SSE2_SHUFF 0x1b -#elif defined(HAVE_ALTIVEC) - #if defined(__APPLE__) /* For OSX */ - #define ALTI_SR (vector unsigned char)(4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4) - #define ALTI_SR_PERM \ - (vector unsigned char)(15,0,1,2,3,4,5,6,15,8,9,10,11,12,13,14) - #define ALTI_SR_MSK \ - (vector unsigned int)(0x000fffffU,0xffffffffU,0x000fffffU,0xffffffffU) - #define ALTI_PERM \ - (vector unsigned char)(12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3) - #else - #define ALTI_SR {4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4} - #define ALTI_SR_PERM {15,0,1,2,3,4,5,6,15,8,9,10,11,12,13,14} - #define ALTI_SR_MSK {0x000fffffU,0xffffffffU,0x000fffffU,0xffffffffU} - #define ALTI_PERM {12,13,14,15,8,9,10,11,4,5,6,7,0,1,2,3} - #endif -#endif - -#if DSFMT_MEXP == 521 - #include "dSFMT-params521.h" -#elif DSFMT_MEXP == 1279 - #include "dSFMT-params1279.h" -#elif DSFMT_MEXP == 2203 - #include "dSFMT-params2203.h" -#elif DSFMT_MEXP == 4253 - #include "dSFMT-params4253.h" -#elif DSFMT_MEXP == 11213 - #include "dSFMT-params11213.h" -#elif DSFMT_MEXP == 19937 - #include "dSFMT-params19937.h" -#elif DSFMT_MEXP == 44497 - #include "dSFMT-params44497.h" -#elif DSFMT_MEXP == 86243 - #include "dSFMT-params86243.h" -#elif DSFMT_MEXP == 132049 - #include "dSFMT-params132049.h" -#elif DSFMT_MEXP == 216091 - #include "dSFMT-params216091.h" -#else -#ifdef __GNUC__ - #error "DSFMT_MEXP is not valid." - #undef DSFMT_MEXP -#else - #undef DSFMT_MEXP -#endif - -#endif - -#endif /* DSFMT_PARAMS_H */ diff --git a/numpy/random/src/dsfmt/dSFMT-params19937.h b/numpy/random/src/dsfmt/dSFMT-params19937.h deleted file mode 100644 index a600b0dbc..000000000 --- a/numpy/random/src/dsfmt/dSFMT-params19937.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef DSFMT_PARAMS19937_H -#define DSFMT_PARAMS19937_H - -/* #define DSFMT_N 191 */ -/* #define DSFMT_MAXDEGREE 19992 */ -#define DSFMT_POS1 117 -#define DSFMT_SL1 19 -#define DSFMT_MSK1 UINT64_C(0x000ffafffffffb3f) -#define DSFMT_MSK2 UINT64_C(0x000ffdfffc90fffd) -#define DSFMT_MSK32_1 0x000ffaffU -#define DSFMT_MSK32_2 0xfffffb3fU -#define DSFMT_MSK32_3 0x000ffdffU -#define DSFMT_MSK32_4 0xfc90fffdU -#define DSFMT_FIX1 UINT64_C(0x90014964b32f4329) -#define DSFMT_FIX2 UINT64_C(0x3b8d12ac548a7c7a) -#define DSFMT_PCV1 UINT64_C(0x3d84e1ac0dc82880) -#define DSFMT_PCV2 UINT64_C(0x0000000000000001) -#define DSFMT_IDSTR "dSFMT2-19937:117-19:ffafffffffb3f-ffdfffc90fffd" - - -/* PARAMETERS FOR ALTIVEC */ -#if defined(__APPLE__) /* For OSX */ - #define ALTI_SL1 (vector unsigned char)(3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3) - #define ALTI_SL1_PERM \ - (vector unsigned char)(2,3,4,5,6,7,30,30,10,11,12,13,14,15,0,1) - #define ALTI_SL1_MSK \ - (vector unsigned int)(0xffffffffU,0xfff80000U,0xffffffffU,0xfff80000U) - #define ALTI_MSK (vector unsigned int)(DSFMT_MSK32_1, \ - DSFMT_MSK32_2, DSFMT_MSK32_3, DSFMT_MSK32_4) -#else /* For OTHER OSs(Linux?) */ - #define ALTI_SL1 {3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3} - #define ALTI_SL1_PERM \ - {2,3,4,5,6,7,30,30,10,11,12,13,14,15,0,1} - #define ALTI_SL1_MSK \ - {0xffffffffU,0xfff80000U,0xffffffffU,0xfff80000U} - #define ALTI_MSK \ - {DSFMT_MSK32_1, DSFMT_MSK32_2, DSFMT_MSK32_3, DSFMT_MSK32_4} -#endif - -#endif /* DSFMT_PARAMS19937_H */ diff --git a/numpy/random/src/dsfmt/dSFMT-poly.h b/numpy/random/src/dsfmt/dSFMT-poly.h deleted file mode 100644 index f8e15c3eb..000000000 --- a/numpy/random/src/dsfmt/dSFMT-poly.h +++ /dev/null @@ -1,53 +0,0 @@ -static const char * poly_128 = -"f4dfa6c62049d0776e0bf6f1e953f3aa38abb113df86be024eab3773ad5f2b82ead936022e656dff7e562691c59dd5f7d2" -"566b78d9669002503c4ddb1888a49f32333f515e6c60c4ecd221078ec6f26f0a90f4875067ca1f399a99775037adf90556" -"6e2c7e6b42131420f8f04f112c92621c9b1502f2a8aefad6c667904af62f0d55e02d396902d3b89450103c5ce5fe0408d9" -"7cbb864861b49e4e42048ff3310b48faac55095a7f422eea4aade752f947f947c6be0a0c665bdea099246ab9eff658ea8c" -"a468bf49d0227748367878de06d7bd86ea6708fcac6e252f5f00f04309b2aac3036b64afb39d990427c6c9f03477cc7e93" -"5c43c0e61bc161db8eb15516eee8cb377ecbc1849207990fb6778721b29bfe0d89bfda1b3772fa5b0b1f7ec3daf3605203" -"2285898c6f6396f55010c31f8201b7e2e51d94f920bfe57684c5415cc342cb39a0045d9793d13cf8646096daeb8bb9bfc2" -"0a90de8f2426da8733267a9b9674f32154e8f84a9932223a2ca3c787d0b66df6675febbdfcba2f9cef09c621c57e11098b" -"3289c77397aaae8b104642ffe0c4b75598efbc53745984d68b4d6656cae299ae2be55217a9a02b009ca7be32f47fbe434b" -"ce4914a34d0c9b0085bede9b8a99319c34660d66f0124b5a7714c4bf3cbfec3ee43ed817087168bad80133bebaeeb68cf7" -"929a24d1bb3de831a8340d220906ab04159cf94b21d5ee813bd7c80f10f01b43052af530917513b169254c25d6fcfe6cb4" -"20d6ce92f54886ef6eaf9a5ba35e893ff593834d05ddf28899e42d729c7df3d21ef036020789739366f0c11ec52ff92a0b" -"fd8ba69508e27b20fabb8217bd36b90e5aa918159ac87913bc7b46c04e366c23c92807fbe9c6a407e6a4db0b4fc23c3b6c" -"706b5ca058fe8c190f849f18d16d6b48b5ed760eb202fd566291a799420b9654e08b8118bcbfead8e9dd2fdb9b053e9bdf" -"b665285c78718f726d0b3d6c37e116428ec9ac9db2637259e4e8d6402bbada46c6bdb03985e19a82e9b4e57de1b025a3cb" -"1f850beae7e8da9941655825bce0e89d536b6ee9064865b1a85c185e9fc9cb7f435de13d44773c00eed442a286e4ab807e" -"3cab4dc3441d1b7d2af693812ae8b39652bb8c835fc895d13d6da93541afeadeee450475c29f3b2dfa8ef1c1e2547463b2" -"cc2f0ff7a42ac4dd35e25c4fa030d2d2766fbe9f2d04c1304671747bace2f7dd55142bfa60f8cbc968bfc3d7a342152dc6" -"84a0fb5a32c0962a62b5220ac0f72add9d8b84d6cc76b97d03245e01fc8da3414a49bb4075d3488f29b56dc42ba69e3b58" -"529448c943ecfd98b3784a39d0b8609a8fb945e757f4569f53bd2cf80f7f638acf5b67fe9c560a3b7b0cf7e0398f31aa8b" -"03cf9c62b24296b6d8596b694469a02686c38daa16a1ef86e012d61a2f7de1693a5c00b3685175caec3c67146477eba548" -"30f1d546cb18a553779aa46adb4f2010e33f3def847c7d89b51a8462b227605f6c920fd558a6daf64bc98682e508ae960c" -"0c571870e603ba1fce0c13d53176f353fd319959e13db93eae1359f06e3dd4767c04f824cf34ec7bf8f60161ba1a615db8" -"2852eca9e3869afa711ab9a090660b0dc6cfbea310dda77e02310fbaeacd2636f975838c2dbcdbe9ac2cd85cee28f5e3f0" -"c73abf62f9fa02cd79a7606b7ba855db68a07848b057c3aaf38f1a70086e14616f6f88305a1f9ce6b41378a620d4db3e0e" -"7e1d421590dccaeff86212e232eeb5eb8a8d33a8c9b25ae88f3a7bd5032b4efa68f8af3186a02ffcbf5456f12beccace94" -"c81c360cc4a0dcc642b59f991eec68c59af78139ca60b96d6a18e9535f8995e89bd2cf6a0aef3acffd33d1c0c1b79b6641" -"4a91d9f65b2b4ec65844b96f725d2b4b0c309f3eb9d714e9dd939bbdfd85ce8fb43679aeab13f6c29549949503c9466dbd" -"337c4cdde46d6eacd15f21f4d8fdeaa627a47884c88a9c85f0b731d271a8ea7cb9e04a4a149c23c10f56b3a0476dc77a99" -"9d6e4f813e4b0f805e2a693e2ae4ae0ecc423c9ba5d17b42e691abf83784a582f2b1fd85d1e0a27ba38a500963568b2450" -"363d2c5e3f7b8ba3e5b56e4e9f745a3a710bf2ae233c303068c532ce78ff031e6ab28b705dd94d7db4500909edb5626b8c" -"9bd5ff4f0b4741388f0b91563ee516934c013e901572cba005ac5c535f4f107903be9af7b2793dfb61b5070facbe71eefe" -"1b5600f975c8c38c3a2350d78beadfecb78e981164ae8bc866e732972d3ceef4aac68e15861f9b881d9b51b4edece150bc" -"124b07645defb4202ef5d0e0962db98cae6ed459561c93c74c20bd64362e4f4fffc389a6cd80514604ff22eecc10c9cbc7" -"981d19a8102b24146354c463107c9dc070e29e70df3578022acf72289ef071ab9f9402a544d0399f1b1e5f206b6d46d445" -"f6d612a490e72918e00c853eda8493bef511149e80c9ab56e8b4b8cba3987249f77d060e61760e5792ac321c987c03c260" -"6e9393a7970212992cdbd16448078d5039d4c2c3199714f53278f4f7b1d2e514cf95bdfc078b8bb0db659cb2c3f5cc0289" -"0ea84f05d414c88d2db9e9f8455659b9fa6254405317245fa070d6970cafb4dadb2522b490a5c8e02fe973a8cdbfbfbdbf" -"b01535099ffba3d3896bc4d1189fc570c3e6fdc6469265b8da912772e75dd62ab71be507f700d56cac5e68fd6b57ec1661" -"68ab5258a69625c142a5b1b3519f94be1bde5e51d3bd8ea0c12d5af2fe4615b1b7bd4a96628a4fabc65925ff09718f63bb" -"ebaad98f89bd9543a27b3ff3b5d8bfa89f941a5eb8cc005ccd4a705190e1c9dc6a9f4264e5ee658520a4438e92de854bff" -"c39f8dc7dfbb5de4f14ba63ea16a37d14a7b4610f95b6cffd55e4679b29cedbdf20e7bd16da822fad910c359ee3a68e48a" -"ae6e769b0e291d5d3aa3e2ca9d8d23abe8a1d5349f4991e9300852cc0befb20c2fc0d169306b260763344024f8092cbcc2" -"4c6807363e9fc548a30d5faab3a94b2af0782a2942be80c45d8b0587efd587394ef33c33022436e285806ddffdd32fe363" -"45c3c38ed8d680abeb7a028b44ee6f94d060a14c7019bb6af1f1b5f0a562957d19826d8cc216f9b908c989ccd5415e3525" -"dfe9422ffb5b50b7cc3083dc325544751e5683535d7439d3da2b0bb73bea551dd99e04e0e793804f4774eb6b1daf781d9c" -"aa5128274e599e847862fe309027813d3e4eda0bbeb7201856a5c5d8370e44dabff0bb229c723ba0a6bcf29c44536147de" -"11b7835991018100105bd4329217f7386903fe8e7363cd7b3e893244e245e0a187467664c05b0be1fd429722b9b9a5e319" -"8147fad72776e8a63aab9054fa9d259af0198d088d71d132e6068676a8e9ebb0f616b51ee34aac39c2c2221c7112401727" -"0d75ff4a048363c389e04e9b440ad2032a381ac2cfc54f409caa791e65ee4f5d6cd035008f219b88a803a7382ae447bf65" -"a3df2176b25b3b7b67dabe34decd9a1384dc7a003916ca8fbcb29b3ad6fd8eac5bbbaa3bdfa6c6a3ad9427c4f3ed79fea2" -"6e14c8ce5fa3b4f82c5f7b6d2125916753a7b92ce9b46d45";
\ No newline at end of file diff --git a/numpy/random/src/dsfmt/dSFMT-test-gen.c b/numpy/random/src/dsfmt/dSFMT-test-gen.c deleted file mode 100644 index 697a3010a..000000000 --- a/numpy/random/src/dsfmt/dSFMT-test-gen.c +++ /dev/null @@ -1,58 +0,0 @@ -/* - * cl dSFMT-test-gen.c dSFMT.c -DHAVE_SSE2 -DDSFMT_MEXP=19937 /Ox - * - * gcc dSFMT-test-gen.c dSFMT.c -DHAVE_SSE2 -DDSFMT_MEXP=19937 -o dSFMT - */ - -#include <inttypes.h> -#include <stdio.h> - -#include "dSFMT.h" - - -int main(void) { - int i; - double d; - uint64_t *temp; - uint32_t seed = 1UL; - dsfmt_t state; - dsfmt_init_gen_rand(&state, seed); - double out[1000]; - dsfmt_fill_array_close1_open2(&state, out, 1000); - - FILE *fp; - fp = fopen("dSFMT-testset-1.csv", "w"); - if (fp == NULL) { - printf("Couldn't open file\n"); - return -1; - } - fprintf(fp, "seed, %" PRIu32 "\n", seed); - for (i = 0; i < 1000; i++) { - d = out[i]; - temp = (uint64_t *)&d; - fprintf(fp, "%d, %" PRIu64 "\n", i, *temp); - if (i==999) { - printf("%d, %" PRIu64 "\n", i, *temp); - } - } - fclose(fp); - - seed = 123456789UL; - dsfmt_init_gen_rand(&state, seed); - dsfmt_fill_array_close1_open2(&state, out, 1000); - fp = fopen("dSFMT-testset-2.csv", "w"); - if (fp == NULL) { - printf("Couldn't open file\n"); - return -1; - } - fprintf(fp, "seed, %" PRIu32 "\n", seed); - for (i = 0; i < 1000; i++) { - d = out[i]; - temp = (uint64_t *)&d; - fprintf(fp, "%d, %" PRIu64 "\n", i, *temp); - if (i==999) { - printf("%d, %" PRIu64 "\n", i, *temp); - } - } - fclose(fp); -} diff --git a/numpy/random/src/dsfmt/dSFMT.c b/numpy/random/src/dsfmt/dSFMT.c deleted file mode 100644 index 0f122c26c..000000000 --- a/numpy/random/src/dsfmt/dSFMT.c +++ /dev/null @@ -1,626 +0,0 @@ -/** - * @file dSFMT.c - * @brief double precision SIMD-oriented Fast Mersenne Twister (dSFMT) - * based on IEEE 754 format. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (Hiroshima University) - * - * Copyright (C) 2007,2008 Mutsuo Saito, Makoto Matsumoto and Hiroshima - * University. All rights reserved. - * - * The new BSD License is applied to this software, see LICENSE.txt - */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "dSFMT-params.h" - -#include "dSFMT-common.h" -#include "dSFMT-jump.h" -#include "dSFMT-poly.h" - -#if defined(__cplusplus) -extern "C" { -#endif - -/** dsfmt internal state vector */ -dsfmt_t dsfmt_global_data; -/** dsfmt mexp for check */ -static const int dsfmt_mexp = DSFMT_MEXP; - -/*---------------- - STATIC FUNCTIONS - ----------------*/ -inline static uint32_t ini_func1(uint32_t x); -inline static uint32_t ini_func2(uint32_t x); -inline static void gen_rand_array_c1o2(dsfmt_t *dsfmt, w128_t *array, int size); -inline static void gen_rand_array_c0o1(dsfmt_t *dsfmt, w128_t *array, int size); -inline static void gen_rand_array_o0c1(dsfmt_t *dsfmt, w128_t *array, int size); -inline static void gen_rand_array_o0o1(dsfmt_t *dsfmt, w128_t *array, int size); -inline static int idxof(int i); -static void initial_mask(dsfmt_t *dsfmt); -static void period_certification(dsfmt_t *dsfmt); - -#if defined(HAVE_SSE2) -/** 1 in 64bit for sse2 */ -static const union X128I_T sse2_int_one = {{1, 1}}; -/** 2.0 double for sse2 */ -static const union X128D_T sse2_double_two = {{2.0, 2.0}}; -/** -1.0 double for sse2 */ -static const union X128D_T sse2_double_m_one = {{-1.0, -1.0}}; -#endif - -/** - * This function simulate a 32-bit array index overlapped to 64-bit - * array of LITTLE ENDIAN in BIG ENDIAN machine. - */ -#if defined(DSFMT_BIG_ENDIAN) -inline static int idxof(int i) { return i ^ 1; } -#else -inline static int idxof(int i) { return i; } -#endif - -#if defined(HAVE_SSE2) -/** - * This function converts the double precision floating point numbers which - * distribute uniformly in the range [1, 2) to those which distribute uniformly - * in the range [0, 1). - * @param w 128bit stracture of double precision floating point numbers (I/O) - */ -inline static void convert_c0o1(w128_t *w) { - w->sd = _mm_add_pd(w->sd, sse2_double_m_one.d128); -} - -/** - * This function converts the double precision floating point numbers which - * distribute uniformly in the range [1, 2) to those which distribute uniformly - * in the range (0, 1]. - * @param w 128bit stracture of double precision floating point numbers (I/O) - */ -inline static void convert_o0c1(w128_t *w) { - w->sd = _mm_sub_pd(sse2_double_two.d128, w->sd); -} - -/** - * This function converts the double precision floating point numbers which - * distribute uniformly in the range [1, 2) to those which distribute uniformly - * in the range (0, 1). - * @param w 128bit stracture of double precision floating point numbers (I/O) - */ -inline static void convert_o0o1(w128_t *w) { - w->si = _mm_or_si128(w->si, sse2_int_one.i128); - w->sd = _mm_add_pd(w->sd, sse2_double_m_one.d128); -} -#else /* standard C and altivec */ -/** - * This function converts the double precision floating point numbers which - * distribute uniformly in the range [1, 2) to those which distribute uniformly - * in the range [0, 1). - * @param w 128bit stracture of double precision floating point numbers (I/O) - */ -inline static void convert_c0o1(w128_t *w) { - w->d[0] -= 1.0; - w->d[1] -= 1.0; -} - -/** - * This function converts the double precision floating point numbers which - * distribute uniformly in the range [1, 2) to those which distribute uniformly - * in the range (0, 1]. - * @param w 128bit stracture of double precision floating point numbers (I/O) - */ -inline static void convert_o0c1(w128_t *w) { - w->d[0] = 2.0 - w->d[0]; - w->d[1] = 2.0 - w->d[1]; -} - -/** - * This function converts the double precision floating point numbers which - * distribute uniformly in the range [1, 2) to those which distribute uniformly - * in the range (0, 1). - * @param w 128bit stracture of double precision floating point numbers (I/O) - */ -inline static void convert_o0o1(w128_t *w) { - w->u[0] |= 1; - w->u[1] |= 1; - w->d[0] -= 1.0; - w->d[1] -= 1.0; -} -#endif - -/** - * This function fills the user-specified array with double precision - * floating point pseudorandom numbers of the IEEE 754 format. - * @param dsfmt dsfmt state vector. - * @param array an 128-bit array to be filled by pseudorandom numbers. - * @param size number of 128-bit pseudorandom numbers to be generated. - */ -inline static void gen_rand_array_c1o2(dsfmt_t *dsfmt, w128_t *array, - int size) { - int i, j; - w128_t lung; - - lung = dsfmt->status[DSFMT_N]; - do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); - for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { - do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], - &lung); - } - for (; i < DSFMT_N; i++) { - do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], - &lung); - } - for (; i < size - DSFMT_N; i++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - } - for (j = 0; j < 2 * DSFMT_N - size; j++) { - dsfmt->status[j] = array[j + size - DSFMT_N]; - } - for (; i < size; i++, j++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - dsfmt->status[j] = array[i]; - } - dsfmt->status[DSFMT_N] = lung; -} - -/** - * This function fills the user-specified array with double precision - * floating point pseudorandom numbers of the IEEE 754 format. - * @param dsfmt dsfmt state vector. - * @param array an 128-bit array to be filled by pseudorandom numbers. - * @param size number of 128-bit pseudorandom numbers to be generated. - */ -inline static void gen_rand_array_c0o1(dsfmt_t *dsfmt, w128_t *array, - int size) { - int i, j; - w128_t lung; - - lung = dsfmt->status[DSFMT_N]; - do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); - for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { - do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], - &lung); - } - for (; i < DSFMT_N; i++) { - do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], - &lung); - } - for (; i < size - DSFMT_N; i++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - convert_c0o1(&array[i - DSFMT_N]); - } - for (j = 0; j < 2 * DSFMT_N - size; j++) { - dsfmt->status[j] = array[j + size - DSFMT_N]; - } - for (; i < size; i++, j++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - dsfmt->status[j] = array[i]; - convert_c0o1(&array[i - DSFMT_N]); - } - for (i = size - DSFMT_N; i < size; i++) { - convert_c0o1(&array[i]); - } - dsfmt->status[DSFMT_N] = lung; -} - -/** - * This function fills the user-specified array with double precision - * floating point pseudorandom numbers of the IEEE 754 format. - * @param dsfmt dsfmt state vector. - * @param array an 128-bit array to be filled by pseudorandom numbers. - * @param size number of 128-bit pseudorandom numbers to be generated. - */ -inline static void gen_rand_array_o0o1(dsfmt_t *dsfmt, w128_t *array, - int size) { - int i, j; - w128_t lung; - - lung = dsfmt->status[DSFMT_N]; - do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); - for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { - do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], - &lung); - } - for (; i < DSFMT_N; i++) { - do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], - &lung); - } - for (; i < size - DSFMT_N; i++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - convert_o0o1(&array[i - DSFMT_N]); - } - for (j = 0; j < 2 * DSFMT_N - size; j++) { - dsfmt->status[j] = array[j + size - DSFMT_N]; - } - for (; i < size; i++, j++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - dsfmt->status[j] = array[i]; - convert_o0o1(&array[i - DSFMT_N]); - } - for (i = size - DSFMT_N; i < size; i++) { - convert_o0o1(&array[i]); - } - dsfmt->status[DSFMT_N] = lung; -} - -/** - * This function fills the user-specified array with double precision - * floating point pseudorandom numbers of the IEEE 754 format. - * @param dsfmt dsfmt state vector. - * @param array an 128-bit array to be filled by pseudorandom numbers. - * @param size number of 128-bit pseudorandom numbers to be generated. - */ -inline static void gen_rand_array_o0c1(dsfmt_t *dsfmt, w128_t *array, - int size) { - int i, j; - w128_t lung; - - lung = dsfmt->status[DSFMT_N]; - do_recursion(&array[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], &lung); - for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { - do_recursion(&array[i], &dsfmt->status[i], &dsfmt->status[i + DSFMT_POS1], - &lung); - } - for (; i < DSFMT_N; i++) { - do_recursion(&array[i], &dsfmt->status[i], &array[i + DSFMT_POS1 - DSFMT_N], - &lung); - } - for (; i < size - DSFMT_N; i++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - convert_o0c1(&array[i - DSFMT_N]); - } - for (j = 0; j < 2 * DSFMT_N - size; j++) { - dsfmt->status[j] = array[j + size - DSFMT_N]; - } - for (; i < size; i++, j++) { - do_recursion(&array[i], &array[i - DSFMT_N], - &array[i + DSFMT_POS1 - DSFMT_N], &lung); - dsfmt->status[j] = array[i]; - convert_o0c1(&array[i - DSFMT_N]); - } - for (i = size - DSFMT_N; i < size; i++) { - convert_o0c1(&array[i]); - } - dsfmt->status[DSFMT_N] = lung; -} - -/** - * This function represents a function used in the initialization - * by init_by_array - * @param x 32-bit integer - * @return 32-bit integer - */ -static uint32_t ini_func1(uint32_t x) { - return (x ^ (x >> 27)) * (uint32_t)1664525UL; -} - -/** - * This function represents a function used in the initialization - * by init_by_array - * @param x 32-bit integer - * @return 32-bit integer - */ -static uint32_t ini_func2(uint32_t x) { - return (x ^ (x >> 27)) * (uint32_t)1566083941UL; -} - -/** - * This function initializes the internal state array to fit the IEEE - * 754 format. - * @param dsfmt dsfmt state vector. - */ -static void initial_mask(dsfmt_t *dsfmt) { - int i; - uint64_t *psfmt; - - psfmt = &dsfmt->status[0].u[0]; - for (i = 0; i < DSFMT_N * 2; i++) { - psfmt[i] = (psfmt[i] & DSFMT_LOW_MASK) | DSFMT_HIGH_CONST; - } -} - -/** - * This function certificate the period of 2^{SFMT_MEXP}-1. - * @param dsfmt dsfmt state vector. - */ -static void period_certification(dsfmt_t *dsfmt) { - uint64_t pcv[2] = {DSFMT_PCV1, DSFMT_PCV2}; - uint64_t tmp[2]; - uint64_t inner; - int i; -#if (DSFMT_PCV2 & 1) != 1 - int j; - uint64_t work; -#endif - - tmp[0] = (dsfmt->status[DSFMT_N].u[0] ^ DSFMT_FIX1); - tmp[1] = (dsfmt->status[DSFMT_N].u[1] ^ DSFMT_FIX2); - - inner = tmp[0] & pcv[0]; - inner ^= tmp[1] & pcv[1]; - for (i = 32; i > 0; i >>= 1) { - inner ^= inner >> i; - } - inner &= 1; - /* check OK */ - if (inner == 1) { - return; - } - /* check NG, and modification */ -#if (DSFMT_PCV2 & 1) == 1 - dsfmt->status[DSFMT_N].u[1] ^= 1; -#else - for (i = 1; i >= 0; i--) { - work = 1; - for (j = 0; j < 64; j++) { - if ((work & pcv[i]) != 0) { - dsfmt->status[DSFMT_N].u[i] ^= work; - return; - } - work = work << 1; - } - } -#endif - return; -} - -/*---------------- - PUBLIC FUNCTIONS - ----------------*/ -/** - * This function returns the identification string. The string shows - * the Mersenne exponent, and all parameters of this generator. - * @return id string. - */ -const char *dsfmt_get_idstring(void) { return DSFMT_IDSTR; } - -/** - * This function returns the minimum size of array used for \b - * fill_array functions. - * @return minimum size of array used for fill_array functions. - */ -int dsfmt_get_min_array_size(void) { return DSFMT_N64; } - -/** - * This function fills the internal state array with double precision - * floating point pseudorandom numbers of the IEEE 754 format. - * @param dsfmt dsfmt state vector. - */ -void dsfmt_gen_rand_all(dsfmt_t *dsfmt) { - int i; - w128_t lung; - - lung = dsfmt->status[DSFMT_N]; - do_recursion(&dsfmt->status[0], &dsfmt->status[0], &dsfmt->status[DSFMT_POS1], - &lung); - for (i = 1; i < DSFMT_N - DSFMT_POS1; i++) { - do_recursion(&dsfmt->status[i], &dsfmt->status[i], - &dsfmt->status[i + DSFMT_POS1], &lung); - } - for (; i < DSFMT_N; i++) { - do_recursion(&dsfmt->status[i], &dsfmt->status[i], - &dsfmt->status[i + DSFMT_POS1 - DSFMT_N], &lung); - } - dsfmt->status[DSFMT_N] = lung; -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range [1, 2) to the - * specified array[] by one call. The number of pseudorandom numbers - * is specified by the argument \b size, which must be at least (SFMT_MEXP - * / 128) * 2 and a multiple of two. The function - * get_min_array_size() returns this minimum size. The generation by - * this function is much faster than the following fill_array_xxx functions. - * - * For initialization, init_gen_rand() or init_by_array() must be called - * before the first call of this function. This function can not be - * used after calling genrand_xxx functions, without initialization. - * - * @param dsfmt dsfmt state vector. - * @param array an array where pseudorandom numbers are filled - * by this function. The pointer to the array must be "aligned" - * (namely, must be a multiple of 16) in the SIMD version, since it - * refers to the address of a 128-bit integer. In the standard C - * version, the pointer is arbitrary. - * - * @param size the number of 64-bit pseudorandom integers to be - * generated. size must be a multiple of 2, and greater than or equal - * to (SFMT_MEXP / 128) * 2. - * - * @note \b memalign or \b posix_memalign is available to get aligned - * memory. Mac OSX doesn't have these functions, but \b malloc of OSX - * returns the pointer to the aligned memory block. - */ -void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], int size) { - assert(size % 2 == 0); - assert(size >= DSFMT_N64); - gen_rand_array_c1o2(dsfmt, (w128_t *)array, size / 2); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range (0, 1] to the - * specified array[] by one call. This function is the same as - * fill_array_close1_open2() except the distribution range. - * - * @param dsfmt dsfmt state vector. - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa fill_array_close1_open2() - */ -void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], int size) { - assert(size % 2 == 0); - assert(size >= DSFMT_N64); - gen_rand_array_o0c1(dsfmt, (w128_t *)array, size / 2); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range [0, 1) to the - * specified array[] by one call. This function is the same as - * fill_array_close1_open2() except the distribution range. - * - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param dsfmt dsfmt state vector. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa fill_array_close1_open2() - */ -void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], int size) { - assert(size % 2 == 0); - assert(size >= DSFMT_N64); - gen_rand_array_c0o1(dsfmt, (w128_t *)array, size / 2); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range (0, 1) to the - * specified array[] by one call. This function is the same as - * fill_array_close1_open2() except the distribution range. - * - * @param dsfmt dsfmt state vector. - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa fill_array_close1_open2() - */ -void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], int size) { - assert(size % 2 == 0); - assert(size >= DSFMT_N64); - gen_rand_array_o0o1(dsfmt, (w128_t *)array, size / 2); -} - -#if defined(__INTEL_COMPILER) -#pragma warning(disable : 981) -#endif -/** - * This function initializes the internal state array with a 32-bit - * integer seed. - * @param dsfmt dsfmt state vector. - * @param seed a 32-bit integer used as the seed. - * @param mexp caller's mersenne expornent - */ -void dsfmt_chk_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed, int mexp) { - int i; - uint32_t *psfmt; - - /* make sure caller program is compiled with the same MEXP */ - if (mexp != dsfmt_mexp) { - fprintf(stderr, "DSFMT_MEXP doesn't match with dSFMT.c\n"); - exit(1); - } - psfmt = &dsfmt->status[0].u32[0]; - psfmt[idxof(0)] = seed; - for (i = 1; i < (DSFMT_N + 1) * 4; i++) { - psfmt[idxof(i)] = - 1812433253UL * (psfmt[idxof(i - 1)] ^ (psfmt[idxof(i - 1)] >> 30)) + i; - } - initial_mask(dsfmt); - period_certification(dsfmt); - dsfmt->idx = DSFMT_N64; -} - -/** - * This function initializes the internal state array, - * with an array of 32-bit integers used as the seeds - * @param dsfmt dsfmt state vector. - * @param init_key the array of 32-bit integers, used as a seed. - * @param key_length the length of init_key. - * @param mexp caller's mersenne expornent - */ -void dsfmt_chk_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[], - int key_length, int mexp) { - int i, j, count; - uint32_t r; - uint32_t *psfmt32; - int lag; - int mid; - int size = (DSFMT_N + 1) * 4; /* pulmonary */ - - /* make sure caller program is compiled with the same MEXP */ - if (mexp != dsfmt_mexp) { - fprintf(stderr, "DSFMT_MEXP doesn't match with dSFMT.c\n"); - exit(1); - } - if (size >= 623) { - lag = 11; - } else if (size >= 68) { - lag = 7; - } else if (size >= 39) { - lag = 5; - } else { - lag = 3; - } - mid = (size - lag) / 2; - - psfmt32 = &dsfmt->status[0].u32[0]; - memset(dsfmt->status, 0x8b, sizeof(dsfmt->status)); - if (key_length + 1 > size) { - count = key_length + 1; - } else { - count = size; - } - r = ini_func1(psfmt32[idxof(0)] ^ psfmt32[idxof(mid % size)] ^ - psfmt32[idxof((size - 1) % size)]); - psfmt32[idxof(mid % size)] += r; - r += key_length; - psfmt32[idxof((mid + lag) % size)] += r; - psfmt32[idxof(0)] = r; - count--; - for (i = 1, j = 0; (j < count) && (j < key_length); j++) { - r = ini_func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % size)] ^ - psfmt32[idxof((i + size - 1) % size)]); - psfmt32[idxof((i + mid) % size)] += r; - r += init_key[j] + i; - psfmt32[idxof((i + mid + lag) % size)] += r; - psfmt32[idxof(i)] = r; - i = (i + 1) % size; - } - for (; j < count; j++) { - r = ini_func1(psfmt32[idxof(i)] ^ psfmt32[idxof((i + mid) % size)] ^ - psfmt32[idxof((i + size - 1) % size)]); - psfmt32[idxof((i + mid) % size)] += r; - r += i; - psfmt32[idxof((i + mid + lag) % size)] += r; - psfmt32[idxof(i)] = r; - i = (i + 1) % size; - } - for (j = 0; j < size; j++) { - r = ini_func2(psfmt32[idxof(i)] + psfmt32[idxof((i + mid) % size)] + - psfmt32[idxof((i + size - 1) % size)]); - psfmt32[idxof((i + mid) % size)] ^= r; - r -= i; - psfmt32[idxof((i + mid + lag) % size)] ^= r; - psfmt32[idxof(i)] = r; - i = (i + 1) % size; - } - initial_mask(dsfmt); - period_certification(dsfmt); - dsfmt->idx = DSFMT_N64; -} -#if defined(__INTEL_COMPILER) -#pragma warning(default : 981) -#endif - -#if defined(__cplusplus) -} -#endif - -extern inline double dsfmt_next_double(dsfmt_state *state); - -extern inline uint64_t dsfmt_next64(dsfmt_state *state); - -extern inline uint32_t dsfmt_next32(dsfmt_state *state); - -void dsfmt_jump(dsfmt_state *state) { dSFMT_jump(state->state, poly_128); };
\ No newline at end of file diff --git a/numpy/random/src/dsfmt/dSFMT.h b/numpy/random/src/dsfmt/dSFMT.h deleted file mode 100644 index 75ef5746f..000000000 --- a/numpy/random/src/dsfmt/dSFMT.h +++ /dev/null @@ -1,697 +0,0 @@ -#pragma once -/** - * @file dSFMT.h - * - * @brief double precision SIMD oriented Fast Mersenne Twister(dSFMT) - * pseudorandom number generator based on IEEE 754 format. - * - * @author Mutsuo Saito (Hiroshima University) - * @author Makoto Matsumoto (Hiroshima University) - * - * Copyright (C) 2007, 2008 Mutsuo Saito, Makoto Matsumoto and - * Hiroshima University. All rights reserved. - * Copyright (C) 2012 Mutsuo Saito, Makoto Matsumoto, - * Hiroshima University and The University of Tokyo. - * All rights reserved. - * - * The new BSD License is applied to this software. - * see LICENSE.txt - * - * @note We assume that your system has inttypes.h. If your system - * doesn't have inttypes.h, you have to typedef uint32_t and uint64_t, - * and you have to define PRIu64 and PRIx64 in this file as follows: - * @verbatim - typedef unsigned int uint32_t - typedef unsigned long long uint64_t - #define PRIu64 "llu" - #define PRIx64 "llx" -@endverbatim - * uint32_t must be exactly 32-bit unsigned integer type (no more, no - * less), and uint64_t must be exactly 64-bit unsigned integer type. - * PRIu64 and PRIx64 are used for printf function to print 64-bit - * unsigned int and 64-bit unsigned int in hexadecimal format. - */ - -#ifndef DSFMT_H -#define DSFMT_H -#if defined(__cplusplus) -extern "C" { -#endif - -#include <assert.h> -#include <stdio.h> - -/* Use NumPy config to determine if SSE2 is present */ -#include "numpy/npy_common.h" -#if defined NPY_HAVE_SSE2_INTRINSICS -#define HAVE_SSE2 1 -#endif - -#if !defined(DSFMT_MEXP) -#ifdef __GNUC__ -#warning "DSFMT_MEXP is not defined. I assume DSFMT_MEXP is 19937." -#endif -#define DSFMT_MEXP 19937 -#endif -/*----------------- - BASIC DEFINITIONS - -----------------*/ -/* Mersenne Exponent. The period of the sequence - * is a multiple of 2^DSFMT_MEXP-1. - * #define DSFMT_MEXP 19937 */ -/** DSFMT generator has an internal state array of 128-bit integers, - * and N is its size. */ -#define DSFMT_N ((DSFMT_MEXP - 128) / 104 + 1) -/** N32 is the size of internal state array when regarded as an array - * of 32-bit integers.*/ -#define DSFMT_N32 (DSFMT_N * 4) -/** N64 is the size of internal state array when regarded as an array - * of 64-bit integers.*/ -#define DSFMT_N64 (DSFMT_N * 2) - -#if !defined(DSFMT_BIG_ENDIAN) -#if defined(__BYTE_ORDER) && defined(__BIG_ENDIAN) -#if __BYTE_ORDER == __BIG_ENDIAN -#define DSFMT_BIG_ENDIAN 1 -#endif -#elif defined(_BYTE_ORDER) && defined(_BIG_ENDIAN) -#if _BYTE_ORDER == _BIG_ENDIAN -#define DSFMT_BIG_ENDIAN 1 -#endif -#elif defined(__BYTE_ORDER__) && defined(__BIG_ENDIAN__) -#if __BYTE_ORDER__ == __BIG_ENDIAN__ -#define DSFMT_BIG_ENDIAN 1 -#endif -#elif defined(BYTE_ORDER) && defined(BIG_ENDIAN) -#if BYTE_ORDER == BIG_ENDIAN -#define DSFMT_BIG_ENDIAN 1 -#endif -#elif defined(__BIG_ENDIAN) || defined(_BIG_ENDIAN) || \ - defined(__BIG_ENDIAN__) || defined(BIG_ENDIAN) -#define DSFMT_BIG_ENDIAN 1 -#endif -#endif - -#if defined(DSFMT_BIG_ENDIAN) && defined(__amd64) -#undef DSFMT_BIG_ENDIAN -#endif - -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -#include <inttypes.h> -#elif defined(_MSC_VER) || defined(__BORLANDC__) -#if !defined(DSFMT_UINT32_DEFINED) && !defined(SFMT_UINT32_DEFINED) -typedef unsigned int uint32_t; -typedef unsigned __int64 uint64_t; -#ifndef UINT64_C -#define UINT64_C(v) (v##ui64) -#endif -#define DSFMT_UINT32_DEFINED -#if !defined(inline) && !defined(__cplusplus) -#define inline __forceinline -#endif -#endif -#else -#include <inttypes.h> -#if !defined(inline) && !defined(__cplusplus) -#if defined(__GNUC__) -#define inline __forceinline__ -#else -#define inline -#endif -#endif -#endif - -#ifndef PRIu64 -#if defined(_MSC_VER) || defined(__BORLANDC__) -#define PRIu64 "I64u" -#define PRIx64 "I64x" -#else -#define PRIu64 "llu" -#define PRIx64 "llx" -#endif -#endif - -#ifndef UINT64_C -#define UINT64_C(v) (v##ULL) -#endif - -/*------------------------------------------ - 128-bit SIMD like data type for standard C - ------------------------------------------*/ -#if defined(HAVE_ALTIVEC) -#if !defined(__APPLE__) -#include <altivec.h> -#endif -/** 128-bit data structure */ -union W128_T { - vector unsigned int s; - uint64_t u[2]; - uint32_t u32[4]; - double d[2]; -}; - -#elif defined(HAVE_SSE2) -#include <emmintrin.h> - -/** 128-bit data structure */ -union W128_T { - __m128i si; - __m128d sd; - uint64_t u[2]; - uint32_t u32[4]; - double d[2]; -}; -#else /* standard C */ -/** 128-bit data structure */ -union W128_T { - uint64_t u[2]; - uint32_t u32[4]; - double d[2]; -}; -#endif - -/** 128-bit data type */ -typedef union W128_T w128_t; - -/** the 128-bit internal state array */ -struct DSFMT_T { - w128_t status[DSFMT_N + 1]; - int idx; -}; -typedef struct DSFMT_T dsfmt_t; - -/** dsfmt internal state vector */ -extern dsfmt_t dsfmt_global_data; -/** dsfmt mexp for check */ -extern const int dsfmt_global_mexp; - -void dsfmt_gen_rand_all(dsfmt_t *dsfmt); -void dsfmt_fill_array_open_close(dsfmt_t *dsfmt, double array[], int size); -void dsfmt_fill_array_close_open(dsfmt_t *dsfmt, double array[], int size); -void dsfmt_fill_array_open_open(dsfmt_t *dsfmt, double array[], int size); -void dsfmt_fill_array_close1_open2(dsfmt_t *dsfmt, double array[], int size); -void dsfmt_chk_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed, int mexp); -void dsfmt_chk_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[], - int key_length, int mexp); -const char *dsfmt_get_idstring(void); -int dsfmt_get_min_array_size(void); - -#if defined(__GNUC__) -#define DSFMT_PRE_INLINE inline static -#define DSFMT_PST_INLINE __attribute__((always_inline)) -#elif defined(_MSC_VER) && _MSC_VER >= 1200 -#define DSFMT_PRE_INLINE __forceinline static -#define DSFMT_PST_INLINE -#else -#define DSFMT_PRE_INLINE inline static -#define DSFMT_PST_INLINE -#endif -DSFMT_PRE_INLINE uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double -dsfmt_genrand_close1_open2(dsfmt_t *dsfmt) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double -dsfmt_genrand_close_open(dsfmt_t *dsfmt) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double -dsfmt_genrand_open_close(dsfmt_t *dsfmt) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double -dsfmt_genrand_open_open(dsfmt_t *dsfmt) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE uint32_t dsfmt_gv_genrand_uint32(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double dsfmt_gv_genrand_close1_open2(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double dsfmt_gv_genrand_close_open(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double dsfmt_gv_genrand_open_close(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double dsfmt_gv_genrand_open_open(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_close(double array[], - int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_gv_fill_array_close_open(double array[], - int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_gv_fill_array_open_open(double array[], - int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void -dsfmt_gv_fill_array_close1_open2(double array[], int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_gv_init_gen_rand(uint32_t seed) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_gv_init_by_array(uint32_t init_key[], - int key_length) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_init_gen_rand(dsfmt_t *dsfmt, - uint32_t seed) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void dsfmt_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[], - int key_length) DSFMT_PST_INLINE; - -/** - * This function generates and returns unsigned 32-bit integer. - * This is slower than SFMT, only for convenience usage. - * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called - * before this function. - * @param dsfmt dsfmt internal state date - * @return double precision floating point pseudorandom number - */ -inline static uint32_t dsfmt_genrand_uint32(dsfmt_t *dsfmt) { - uint32_t r; - uint64_t *psfmt64 = &dsfmt->status[0].u[0]; - - if (dsfmt->idx >= DSFMT_N64) { - dsfmt_gen_rand_all(dsfmt); - dsfmt->idx = 0; - } - r = psfmt64[dsfmt->idx++] & 0xffffffffU; - return r; -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range [1, 2). This is - * the primitive and faster than generating numbers in other ranges. - * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called - * before this function. - * @param dsfmt dsfmt internal state date - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_genrand_close1_open2(dsfmt_t *dsfmt) { - double r; - double *psfmt64 = &dsfmt->status[0].d[0]; - - if (dsfmt->idx >= DSFMT_N64) { - dsfmt_gen_rand_all(dsfmt); - dsfmt->idx = 0; - } - r = psfmt64[dsfmt->idx++]; - return r; -} - -/** - * This function generates and returns unsigned 32-bit integer. - * This is slower than SFMT, only for convenience usage. - * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called - * before this function. This function uses \b global variables. - * @return double precision floating point pseudorandom number - */ -inline static uint32_t dsfmt_gv_genrand_uint32(void) { - return dsfmt_genrand_uint32(&dsfmt_global_data); -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range [1, 2). - * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called - * before this function. This function uses \b global variables. - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_gv_genrand_close1_open2(void) { - return dsfmt_genrand_close1_open2(&dsfmt_global_data); -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range [0, 1). - * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called - * before this function. - * @param dsfmt dsfmt internal state date - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_genrand_close_open(dsfmt_t *dsfmt) { - return dsfmt_genrand_close1_open2(dsfmt) - 1.0; -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range [0, 1). - * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called - * before this function. This function uses \b global variables. - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_gv_genrand_close_open(void) { - return dsfmt_gv_genrand_close1_open2() - 1.0; -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range (0, 1]. - * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called - * before this function. - * @param dsfmt dsfmt internal state date - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_genrand_open_close(dsfmt_t *dsfmt) { - return 2.0 - dsfmt_genrand_close1_open2(dsfmt); -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range (0, 1]. - * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called - * before this function. This function uses \b global variables. - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_gv_genrand_open_close(void) { - return 2.0 - dsfmt_gv_genrand_close1_open2(); -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range (0, 1). - * dsfmt_init_gen_rand() or dsfmt_init_by_array() must be called - * before this function. - * @param dsfmt dsfmt internal state date - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_genrand_open_open(dsfmt_t *dsfmt) { - double *dsfmt64 = &dsfmt->status[0].d[0]; - union { - double d; - uint64_t u; - } r; - - if (dsfmt->idx >= DSFMT_N64) { - dsfmt_gen_rand_all(dsfmt); - dsfmt->idx = 0; - } - r.d = dsfmt64[dsfmt->idx++]; - r.u |= 1; - return r.d - 1.0; -} - -/** - * This function generates and returns double precision pseudorandom - * number which distributes uniformly in the range (0, 1). - * dsfmt_gv_init_gen_rand() or dsfmt_gv_init_by_array() must be called - * before this function. This function uses \b global variables. - * @return double precision floating point pseudorandom number - */ -inline static double dsfmt_gv_genrand_open_open(void) { - return dsfmt_genrand_open_open(&dsfmt_global_data); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range [1, 2) to the - * specified array[] by one call. This function is the same as - * dsfmt_fill_array_close1_open2() except that this function uses - * \b global variables. - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_fill_array_close1_open2() - */ -inline static void dsfmt_gv_fill_array_close1_open2(double array[], int size) { - dsfmt_fill_array_close1_open2(&dsfmt_global_data, array, size); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range (0, 1] to the - * specified array[] by one call. This function is the same as - * dsfmt_gv_fill_array_close1_open2() except the distribution range. - * This function uses \b global variables. - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_fill_array_close1_open2() and \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void dsfmt_gv_fill_array_open_close(double array[], int size) { - dsfmt_fill_array_open_close(&dsfmt_global_data, array, size); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range [0, 1) to the - * specified array[] by one call. This function is the same as - * dsfmt_gv_fill_array_close1_open2() except the distribution range. - * This function uses \b global variables. - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_fill_array_close1_open2() \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void dsfmt_gv_fill_array_close_open(double array[], int size) { - dsfmt_fill_array_close_open(&dsfmt_global_data, array, size); -} - -/** - * This function generates double precision floating point - * pseudorandom numbers which distribute in the range (0, 1) to the - * specified array[] by one call. This function is the same as - * dsfmt_gv_fill_array_close1_open2() except the distribution range. - * This function uses \b global variables. - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_fill_array_close1_open2() \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void dsfmt_gv_fill_array_open_open(double array[], int size) { - dsfmt_fill_array_open_open(&dsfmt_global_data, array, size); -} - -/** - * This function initializes the internal state array with a 32-bit - * integer seed. - * @param dsfmt dsfmt state vector. - * @param seed a 32-bit integer used as the seed. - */ -inline static void dsfmt_init_gen_rand(dsfmt_t *dsfmt, uint32_t seed) { - dsfmt_chk_init_gen_rand(dsfmt, seed, DSFMT_MEXP); -} - -/** - * This function initializes the internal state array with a 32-bit - * integer seed. This function uses \b global variables. - * @param seed a 32-bit integer used as the seed. - * see also \sa dsfmt_init_gen_rand() - */ -inline static void dsfmt_gv_init_gen_rand(uint32_t seed) { - dsfmt_init_gen_rand(&dsfmt_global_data, seed); -} - -/** - * This function initializes the internal state array, - * with an array of 32-bit integers used as the seeds. - * @param dsfmt dsfmt state vector - * @param init_key the array of 32-bit integers, used as a seed. - * @param key_length the length of init_key. - */ -inline static void dsfmt_init_by_array(dsfmt_t *dsfmt, uint32_t init_key[], - int key_length) { - dsfmt_chk_init_by_array(dsfmt, init_key, key_length, DSFMT_MEXP); -} - -/** - * This function initializes the internal state array, - * with an array of 32-bit integers used as the seeds. - * This function uses \b global variables. - * @param init_key the array of 32-bit integers, used as a seed. - * @param key_length the length of init_key. - * see also \sa dsfmt_init_by_array() - */ -inline static void dsfmt_gv_init_by_array(uint32_t init_key[], int key_length) { - dsfmt_init_by_array(&dsfmt_global_data, init_key, key_length); -} - -#if !defined(DSFMT_DO_NOT_USE_OLD_NAMES) -DSFMT_PRE_INLINE const char *get_idstring(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE int get_min_array_size(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void init_gen_rand(uint32_t seed) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void init_by_array(uint32_t init_key[], - int key_length) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double genrand_close1_open2(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double genrand_close_open(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double genrand_open_close(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE double genrand_open_open(void) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void fill_array_open_close(double array[], - int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void fill_array_close_open(double array[], - int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void fill_array_open_open(double array[], - int size) DSFMT_PST_INLINE; -DSFMT_PRE_INLINE void fill_array_close1_open2(double array[], - int size) DSFMT_PST_INLINE; - -/** - * This function is just the same as dsfmt_get_idstring(). - * @return id string. - * see also \sa dsfmt_get_idstring() - */ -inline static const char *get_idstring(void) { return dsfmt_get_idstring(); } - -/** - * This function is just the same as dsfmt_get_min_array_size(). - * @return minimum size of array used for fill_array functions. - * see also \sa dsfmt_get_min_array_size() - */ -inline static int get_min_array_size(void) { - return dsfmt_get_min_array_size(); -} - -/** - * This function is just the same as dsfmt_gv_init_gen_rand(). - * @param seed a 32-bit integer used as the seed. - * see also \sa dsfmt_gv_init_gen_rand(), \sa dsfmt_init_gen_rand(). - */ -inline static void init_gen_rand(uint32_t seed) { - dsfmt_gv_init_gen_rand(seed); -} - -/** - * This function is just the same as dsfmt_gv_init_by_array(). - * @param init_key the array of 32-bit integers, used as a seed. - * @param key_length the length of init_key. - * see also \sa dsfmt_gv_init_by_array(), \sa dsfmt_init_by_array(). - */ -inline static void init_by_array(uint32_t init_key[], int key_length) { - dsfmt_gv_init_by_array(init_key, key_length); -} - -/** - * This function is just the same as dsfmt_gv_genrand_close1_open2(). - * @return double precision floating point number. - * see also \sa dsfmt_genrand_close1_open2() \sa - * dsfmt_gv_genrand_close1_open2() - */ -inline static double genrand_close1_open2(void) { - return dsfmt_gv_genrand_close1_open2(); -} - -/** - * This function is just the same as dsfmt_gv_genrand_close_open(). - * @return double precision floating point number. - * see also \sa dsfmt_genrand_close_open() \sa - * dsfmt_gv_genrand_close_open() - */ -inline static double genrand_close_open(void) { - return dsfmt_gv_genrand_close_open(); -} - -/** - * This function is just the same as dsfmt_gv_genrand_open_close(). - * @return double precision floating point number. - * see also \sa dsfmt_genrand_open_close() \sa - * dsfmt_gv_genrand_open_close() - */ -inline static double genrand_open_close(void) { - return dsfmt_gv_genrand_open_close(); -} - -/** - * This function is just the same as dsfmt_gv_genrand_open_open(). - * @return double precision floating point number. - * see also \sa dsfmt_genrand_open_open() \sa - * dsfmt_gv_genrand_open_open() - */ -inline static double genrand_open_open(void) { - return dsfmt_gv_genrand_open_open(); -} - -/** - * This function is juset the same as dsfmt_gv_fill_array_open_close(). - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_gv_fill_array_open_close(), \sa - * dsfmt_fill_array_close1_open2(), \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void fill_array_open_close(double array[], int size) { - dsfmt_gv_fill_array_open_close(array, size); -} - -/** - * This function is juset the same as dsfmt_gv_fill_array_close_open(). - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_gv_fill_array_close_open(), \sa - * dsfmt_fill_array_close1_open2(), \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void fill_array_close_open(double array[], int size) { - dsfmt_gv_fill_array_close_open(array, size); -} - -/** - * This function is juset the same as dsfmt_gv_fill_array_open_open(). - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_gv_fill_array_open_open(), \sa - * dsfmt_fill_array_close1_open2(), \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void fill_array_open_open(double array[], int size) { - dsfmt_gv_fill_array_open_open(array, size); -} - -/** - * This function is juset the same as dsfmt_gv_fill_array_close1_open2(). - * @param array an array where pseudorandom numbers are filled - * by this function. - * @param size the number of pseudorandom numbers to be generated. - * see also \sa dsfmt_fill_array_close1_open2(), \sa - * dsfmt_gv_fill_array_close1_open2() - */ -inline static void fill_array_close1_open2(double array[], int size) { - dsfmt_gv_fill_array_close1_open2(array, size); -} -#endif /* DSFMT_DO_NOT_USE_OLD_NAMES */ - -#if defined(__cplusplus) -} -#endif - -#endif /* DSFMT_H */ - -union random_val_t { - double d; - uint64_t u64; -}; - -typedef struct s_dsfmt_state { - dsfmt_t *state; - int has_uint32; - uint32_t uinteger; - - double *buffered_uniforms; - int buffer_loc; -} dsfmt_state; - -static inline double dsfmt_next_buffer(dsfmt_state *state) { - if (state->buffer_loc < DSFMT_N64) { - double out = state->buffered_uniforms[state->buffer_loc]; - state->buffer_loc++; - return out; - } - dsfmt_fill_array_close1_open2(state->state, state->buffered_uniforms, - DSFMT_N64); - state->buffer_loc = 1; - return state->buffered_uniforms[0]; -} - -static inline double dsfmt_next_double(dsfmt_state *state) { - return dsfmt_next_buffer(state) - 1.0; -} - -static inline uint64_t dsfmt_next64(dsfmt_state *state) { - /* Discard bottom 16 bits */ - uint64_t out; - union random_val_t rv; - rv.d = dsfmt_next_buffer(state); - out = (rv.u64 >> 16) << 32; - rv.d = dsfmt_next_buffer(state); - out |= (rv.u64 >> 16) & 0xffffffff; - return out; -} - -static inline uint32_t dsfmt_next32(dsfmt_state *state) { - /* Discard bottom 16 bits */ - union random_val_t rv; - rv.d = dsfmt_next_buffer(state); - // uint64_t *out = (uint64_t *)&d; - return (uint32_t)((rv.u64 >> 16) & 0xffffffff); -} - -static inline uint64_t dsfmt_next_raw(dsfmt_state *state) { - union random_val_t rv; - rv.d = dsfmt_next_buffer(state); - return rv.u64; -} - -void dsfmt_jump(dsfmt_state *state);
\ No newline at end of file |