[+] AuRNG::RngArrayI32RangeFast
[+] AuRNG::RngArrayU32RangeFast [+] AuRNG::RngArrayI64RangeFast [+] AuRNG::RngArrayU64RangeFast [+] IRandomDevice::NextArrayI32RangeFast [+] IRandomDevice::NextArrayU32RangeFast [+] IRandomDevice::NextArrayI64RangeFast [+] IRandomDevice::NextArrayU64RangeFast
This commit is contained in:
parent
5f9681c9e3
commit
442a5f31eb
@ -36,9 +36,13 @@ namespace Aurora::RNG
|
||||
virtual AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) = 0;
|
||||
virtual uuids::uuid NextUUID() = 0;
|
||||
virtual AuList<AuInt32> NextArrayI32Range(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax) = 0;
|
||||
virtual AuList<AuInt32> NextArrayI32RangeFast(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax) = 0;
|
||||
virtual AuList<AuUInt32> NextArrayU32Range(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax) = 0;
|
||||
virtual AuList<AuUInt32> NextArrayU32RangeFast(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax) = 0;
|
||||
virtual AuList<AuInt64> NextArrayI64Range(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax) = 0;
|
||||
virtual AuList<AuInt64> NextArrayI64RangeFast(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax) = 0;
|
||||
virtual AuList<AuUInt64> NextArrayU64Range(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax) = 0;
|
||||
virtual AuList<AuUInt64> NextArrayU64RangeFast(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax) = 0;
|
||||
virtual AuList<AuUInt32> NextArrayU32Mask(AuUInt32 uCount, AuUInt32 uMask) = 0;
|
||||
virtual AuList<AuUInt64> NextArrayU64Mask(AuUInt32 uCount, AuUInt64 uMask) = 0;
|
||||
virtual AuList<double> NextArrayDoubleRange(AuUInt32 uCount, double dMin, double dMax) = 0;
|
||||
|
@ -45,9 +45,13 @@ namespace Aurora::RNG
|
||||
AUKN_SYM AuUInt32 RngIndex(AuUInt32 uCount /* = max + 1*/);
|
||||
AUKN_SYM uuids::uuid RngUUID();
|
||||
AUKN_SYM AuList<AuInt32> RngArrayI32Range(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax);
|
||||
AUKN_SYM AuList<AuInt32> RngArrayI32RangeFast(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax);
|
||||
AUKN_SYM AuList<AuUInt32> RngArrayU32Range(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax);
|
||||
AUKN_SYM AuList<AuUInt32> RngArrayU32RangeFast(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax);
|
||||
AUKN_SYM AuList<AuInt64> RngArrayI64Range(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax);
|
||||
AUKN_SYM AuList<AuInt64> RngArrayI64RangeFast(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax);
|
||||
AUKN_SYM AuList<AuUInt64> RngArrayU64Range(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax);
|
||||
AUKN_SYM AuList<AuUInt64> RngArrayU64RangeFast(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax);
|
||||
AUKN_SYM AuList<AuUInt32> RngArrayU32Mask(AuUInt32 uCount, AuUInt32 uMask);
|
||||
AUKN_SYM AuList<AuUInt64> RngArrayU64Mask(AuUInt32 uCount, AuUInt64 uMask);
|
||||
AUKN_SYM AuList<double> RngArrayDoubleRange(AuUInt32 uCount, double dMin, double dMax);
|
||||
|
@ -237,4 +237,24 @@ namespace Aurora::RNG
|
||||
{
|
||||
return gFastDevice->NextArrayDecimalsFast(uCount);
|
||||
}
|
||||
|
||||
AUKN_SYM AuList<AuInt32> RngArrayI32RangeFast(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax)
|
||||
{
|
||||
return gFastDevice->NextArrayI32RangeFast(uCount, iMin, iMax);
|
||||
}
|
||||
|
||||
AUKN_SYM AuList<AuUInt32> RngArrayU32RangeFast(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax)
|
||||
{
|
||||
return gFastDevice->NextArrayU32RangeFast(uCount, uMin, uMax);
|
||||
}
|
||||
|
||||
AUKN_SYM AuList<AuInt64> RngArrayI64RangeFast(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax)
|
||||
{
|
||||
return gFastDevice->NextArrayI64RangeFast(uCount, iMin, iMax);
|
||||
}
|
||||
|
||||
AUKN_SYM AuList<AuUInt64> RngArrayU64RangeFast(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax)
|
||||
{
|
||||
return gFastDevice->NextArrayU64RangeFast(uCount, uMin, uMax);
|
||||
}
|
||||
}
|
@ -322,6 +322,32 @@ namespace Aurora::RNG
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuList<AuInt32> RandomDevice::NextArrayI32RangeFast(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax)
|
||||
{
|
||||
AuList<AuInt32> ret;
|
||||
|
||||
ret.resize(uCount);
|
||||
|
||||
auto uRange = AuUInt32(iMax - iMin);
|
||||
auto uUpperBound = AuRoundUpPow2(uRange + 1);
|
||||
auto uSeed = this->NextU32();
|
||||
|
||||
for (AU_ITERATE_N(uIndex, uCount))
|
||||
{
|
||||
AuUInt32 uNext {};
|
||||
|
||||
uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed));
|
||||
while ((uNext = (uSeed & (uUpperBound - 1))) > uRange)
|
||||
{
|
||||
uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed));
|
||||
}
|
||||
|
||||
ret[uIndex] = iMin + uNext;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuList<AuUInt32> RandomDevice::NextArrayU32Range(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax)
|
||||
{
|
||||
AuList<AuUInt32> ret;
|
||||
@ -349,6 +375,32 @@ namespace Aurora::RNG
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuList<AuUInt32> RandomDevice::NextArrayU32RangeFast(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax)
|
||||
{
|
||||
AuList<AuUInt32> ret;
|
||||
|
||||
ret.resize(uCount);
|
||||
|
||||
auto uRange = uMax - uMin;
|
||||
auto uUpperBound = AuRoundUpPow2(uRange + 1);
|
||||
auto uSeed = this->NextU32();
|
||||
|
||||
for (AU_ITERATE_N(uIndex, uCount))
|
||||
{
|
||||
AuUInt32 uNext {};
|
||||
|
||||
uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed));
|
||||
while ((uNext = (uSeed & (uUpperBound - 1))) > uRange)
|
||||
{
|
||||
uSeed = AuFnv1a32Runtime(&uSeed, sizeof(uSeed));
|
||||
}
|
||||
|
||||
ret[uIndex] = uMin + uNext;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuList<double> RandomDevice::NextArrayDoubleRange(AuUInt32 uCount, double dMin, double dMax)
|
||||
{
|
||||
#if defined(AURNG_USE_FAST_DECIMALS)
|
||||
@ -446,6 +498,58 @@ namespace Aurora::RNG
|
||||
return iMin + uNext;
|
||||
}
|
||||
|
||||
AuList<AuInt64> RandomDevice::NextArrayI64RangeFast(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax)
|
||||
{
|
||||
AuList<AuInt64> ret;
|
||||
|
||||
ret.resize(uCount);
|
||||
|
||||
auto uRange = AuUInt64(iMax - iMin);
|
||||
auto uUpperBound = AuRoundUpPow2(uRange + 1);
|
||||
auto uSeed = this->NextU64();
|
||||
|
||||
for (AU_ITERATE_N(uIndex, uCount))
|
||||
{
|
||||
AuUInt64 uNext {};
|
||||
|
||||
uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed));
|
||||
while ((uNext = (uSeed & (uUpperBound - 1))) > uRange)
|
||||
{
|
||||
uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed));
|
||||
}
|
||||
|
||||
ret[uIndex] = iMin + uNext;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuList<AuUInt64> RandomDevice::NextArrayU64RangeFast(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax)
|
||||
{
|
||||
AuList<AuUInt64> ret;
|
||||
|
||||
ret.resize(uCount);
|
||||
|
||||
auto uRange = uMax - uMin;
|
||||
auto uUpperBound = AuRoundUpPow2(uRange + 1);
|
||||
auto uSeed = this->NextU64();
|
||||
|
||||
for (AU_ITERATE_N(uIndex, uCount))
|
||||
{
|
||||
AuUInt64 uNext {};
|
||||
|
||||
uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed));
|
||||
while ((uNext = (uSeed & (uUpperBound - 1))) > uRange)
|
||||
{
|
||||
uSeed = AuFnv1a64Runtime(&uSeed, sizeof(uSeed));
|
||||
}
|
||||
|
||||
ret[uIndex] = uMin + uNext;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
AuVec2 RandomDevice::NextVec2(AuVec2 boundA, AuVec2 boundB)
|
||||
{
|
||||
AuVec2 mins, maxs;
|
||||
|
@ -62,6 +62,10 @@ namespace Aurora::RNG
|
||||
AuList<double> NextArrayDecimals(AuUInt32 uCount) override;
|
||||
AuList<double> NextArrayDecimalsFast(AuUInt32 uCount) override;
|
||||
AuList<uuids::uuid> NextArrayUUIDs(AuUInt32 uCount) override;
|
||||
AuList<AuInt32> NextArrayI32RangeFast(AuUInt32 uCount, AuInt32 iMin, AuInt32 iMax) override;
|
||||
AuList<AuUInt32> NextArrayU32RangeFast(AuUInt32 uCount, AuUInt32 uMin, AuUInt32 uMax) override;
|
||||
AuList<AuInt64> NextArrayI64RangeFast(AuUInt32 uCount, AuInt64 iMin, AuInt64 iMax) override;
|
||||
AuList<AuUInt64> NextArrayU64RangeFast(AuUInt32 uCount, AuUInt64 uMin, AuUInt64 uMax) override;
|
||||
|
||||
double NextDecimal() override;
|
||||
double NextNumber(double dMin, double dMax) override;
|
||||
|
Loading…
Reference in New Issue
Block a user