You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Previously, calling e.g. rand(big(1:4)) caused a stack overflow,
because rand(mt::MersenneTwister, r::AbstractArray) was calling
itself recursively. This is fixed here, but a mecanism handling
not-implemented types should be added.
* RandIntGen is renamed to RangeGeneratorInt.
* A type RangeGeneratorBigInt similar to RangeGeneratorInt (both
subtypes of RangeGenerator) is introduced to handle rand on
BigInt ranges. RangeGenerator is the generic constructor of such
objects, taking a range as parameter.
Note: two different versions are implemented depending on the
GMP version (it is faster with version 6 on big ranges).
* BigInt tests from commit bf8c452 are re-added.
@evalRandIntGen(r::UnitRange{$T}) =isempty(r) ?error("range must be non-empty") :RandIntGen(first(r), convert($U, unsigned(last(r) -first(r)) +one($U))) # overflow ok
387
+
@evalRangeGenerator(r::UnitRange{$T}) =isempty(r) ?error("range must be non-empty") :RangeGeneratorInt(first(r), convert($U, unsigned(last(r) -first(r)) +one($U))) # overflow ok
388
+
end
389
+
390
+
if GMP_VERSION.major >=6
391
+
immutable RangeGeneratorBigInt <:RangeGenerator
392
+
a::BigInt# first
393
+
m::BigInt# range length - 1
394
+
nlimbs::Int# number of limbs in generated BigInt's
395
+
mask::Limb# applied to the highest limb
396
+
end
397
+
398
+
else
399
+
immutable RangeGeneratorBigInt <:RangeGenerator
400
+
a::BigInt# first
401
+
m::BigInt# range length - 1
402
+
limbs::Array{Limb}# buffer to be copied into generated BigInt's
403
+
mask::Limb# applied to the highest limb
404
+
405
+
RangeGeneratorBigInt(a, m, nlimbs, mask) =new(a, m, Array(Limb, nlimbs), mask)
0 commit comments