MCPcopy Create free account
hub / github.com/creatale/node-dv / next

Method next

deps/opencv/modules/core/src/rand.cpp:972–1012  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

970}
971
972unsigned cv::RNG_MT19937::next()
973{
974 /* mag01[x] = x * MATRIX_A for x=0,1 */
975 static unsigned mag01[2] = { 0x0U, /*MATRIX_A*/ 0x9908b0dfU};
976
977 const unsigned UPPER_MASK = 0x80000000U;
978 const unsigned LOWER_MASK = 0x7fffffffU;
979
980 /* generate N words at one time */
981 if (mti >= N)
982 {
983 int kk = 0;
984
985 for (; kk < N - M; ++kk)
986 {
987 unsigned y = (state[kk] & UPPER_MASK) | (state[kk + 1] & LOWER_MASK);
988 state[kk] = state[kk + M] ^ (y >> 1) ^ mag01[y & 0x1U];
989 }
990
991 for (; kk < N - 1; ++kk)
992 {
993 unsigned y = (state[kk] & UPPER_MASK) | (state[kk + 1] & LOWER_MASK);
994 state[kk] = state[kk + (M - N)] ^ (y >> 1) ^ mag01[y & 0x1U];
995 }
996
997 unsigned y = (state[N - 1] & UPPER_MASK) | (state[0] & LOWER_MASK);
998 state[N - 1] = state[M - 1] ^ (y >> 1) ^ mag01[y & 0x1U];
999
1000 mti = 0;
1001 }
1002
1003 unsigned y = state[mti++];
1004
1005 /* Tempering */
1006 y ^= (y >> 11);
1007 y ^= (y << 7) & 0x9d2c5680U;
1008 y ^= (y << 15) & 0xefc60000U;
1009 y ^= (y >> 18);
1010
1011 return y;
1012}
1013
1014cv::RNG_MT19937::operator unsigned() { return next(); }
1015

Callers 2

JacobiSVDImpl_Function · 0.45
capi.cppFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected