Math::Random::MT benchmark

Posted on 8月 19, 2010
Filed Under perl |

randのばらつき方が均等になる、という理由でMath::Random::MTが使われているようです。(身近で

macにXS版を入れようとすると
In file included from _mt.c:1:
mt.h:17: error: expected specifier-qualifier-list before ‘uint32_t’
mt.h:21: error: expected ‘)’ before ‘seed’
mt.h:22: error: expected ‘)’ before ‘*’ token
_mt.c:17: error: expected declaration specifiers or ‘…’ before ‘uint32_t’
_mt.c: In function ‘mt_init_seed’:
_mt.c:20: error: ‘uint32_t’ undeclared (first use in this function)
_mt.c:20: error: (Each undeclared identifier is reported only once
_mt.c:20: error: for each function it appears in.)
_mt.c:20: error: ‘mt’ undeclared (first use in this function)
_mt.c:22: error: ‘struct mt’ has no member named ‘mt’
_mt.c:23: error: ‘seed’ undeclared (first use in this function)

っていうようなエラーがでてmakeがこけるところは、


#if defined(_MSC_VER) && (_MSC_VER < = 1300)
typedef unsigned __int32 uint32_t;
#elif defined(__linux__) || defined(__GLIBC__) || defined(__WIN32__)
#include
#elif defined(__osf__)
#include
#else
#include
#endif

このifdefがうまくいってないようだったのでとりあえず
#include <inttypes.h>
と手で書いてあげたりするとうまくmake && make testが通るようになりました
この辺はどう書くのが鉄板なんでしょうね?

ということでベンチマーク

ここがボトルネックになることはあまり無いとは思いますが。

Comments

2 Responses to “Math::Random::MT benchmark”

  1. Tokuhiro Matsuno on 8月 19th, 2010 13:46

    こんな風なパッチにするとよいかんじです!

    https://rt.cpan.org/Ticket/Display.html?id=59512&results=f77f90338ddc25b7de32501a6c869738

  2. mash on 8月 19th, 2010 14:37

    ありがとうございます!

Leave a Reply