I'm not following you here. IIUC a range is a single scalar value?  Are you 
suggesting I want an Array{range}?

Chris Rackauckas wrote:

> Do you need to use an array? That sounds better suited for a range.
> 
> On Tuesday, September 13, 2016 at 10:24:15 AM UTC-7, Neal Becker wrote:
>>
>> Steven G. Johnson wrote:
>>
>> > 
>> > 
>> > 
>> > On Monday, September 12, 2016 at 7:32:48 AM UTC-4, Neal Becker wrote:
>> >> 
>> >> PnSeq.jl calls rand() to get a Int64, caching the result and then
>> >> providing
>> >> N bits at a time to fill an Array.  It's supposed to be a fast way to
>> get
>> >> an
>> >> Array of small-width random integers.
>> >> 
>> > 
>> > rand(T, n) already does this for small integer types T.  (In fact, it
>> > generates 128 random bits at a time.)  See base/random.jl
>> > 
>> <
>> 
https://github.com/JuliaLang/julia/blob/d0e7684dd0ce867e1add2b88bb91f1c4574100e0/base/random.jl#L507-L515>
>>
>> > for how it does it.
>> > 
>> > In a quick test, rand(UInt16, 10^6) was more than 6x faster than
>> > pnseq(16)(10^6, UInt16).
>>
>> Thanks for the ideas.  Here, though, the generated values need to be
>> Uniform([0...2^N]), where N could be any number.  For example [0...2^3].
>> So the output array itself would be Array{Int64} for example, but the
>> values
>> in the array are [0 ... 7].  Do you know a better way to do this?
>>
>> > 
>> > (In a performance-critical situation where you are calling this lots of
>> > times to generate random arrays, I would pre-allocate the array A and
>> call
>> > rand!(A) instead to fill it with random numbers in-place.)
>>
>>
>>


Reply via email to