I've pushed a fix. The essence is
https://github.com/jsoftware/jsource/blob/master/jsrc/vrand.c#L625

It's been a while since I've concerned myself with the details of
array allocation, so I'd like to verify that AT(z)= XNUM is valid when
z is a freshly allocated (and unpopulated) INT array. (The alternative
would be to free z and allocate a fresh array for z.)

Note also that J's estimate of the number of values which need to be
rolled here is a bit high. The value of h as calculated at
https://github.com/jsoftware/jsource/blob/master/jsrc/vrand.c#L803 is
20 for the example where I need to deal 5 XNUMs. This is not
incorrect, but it is an opportunity for an efficiency gain.

Thanks,

-- 
Raul


On Thu, Jun 15, 2023 at 9:21 AM Raul Miller <rauldmil...@gmail.com> wrote:
>
> Good eye, I had overlooked that problem.
>
> That said, it's worth noting that 5 ? 1e99 runs into the same issue.
> I'm not going to attempt a fix for that today. (But it's tempting to
> think about implementing that in a fashion which would provide a
> distribution which is equivalent to that which would be provided by
> (5 ?&.x: 1e99), once I have fixed this problem.)
>
> Anyways, I should have a fix up within a few hours.
>
> Thanks,
>
>
> --
> Raul
>
> On Thu, Jun 15, 2023 at 3:19 AM Henry Rich <henryhr...@gmail.com> wrote:
> >
> > That isn't sufficient, is it?  The random numbers will be drawn from i.
> > IMAX, won't they?  If not, it's OK.
> >
> > hhr
> >
> > On Wed, Jun 14, 2023, 11:28 PM Raul Miller <rauldmil...@gmail.com> wrote:
> >
> > > But that's not what i0() does:
> > >
> > > i0(1e99) returns IMAX
> > >
> > > Why should i0(x: 1e99) produce a domain error?
> > >
> > > Anyways, I've pushed a fix to jti0 for this issue.
> > >
> > > Please help me understand, if it's not acceptable.
> > >
> > > Thanks,
> > >
> > > --
> > > Raul
> > >
> > > On Wed, Jun 14, 2023 at 4:46 PM Henry Rich <henryhr...@gmail.com> wrote:
> > > >
> > > > The i0 gives domain error if the argument exceeds IMAX, which is what 
> > > > you
> > > > are seeing.   This looks like a bug to me.  I think the algorithm for
> > > deal
> > > > would work if you just called roll with the extended arguments. Raul,
> > > would
> > > > you like to take that on?
> > > >
> > > > Henry Rich
> > > >
> > > > On Wed, Jun 14, 2023, 6:53 PM Raul Miller <rauldmil...@gmail.com> wrote:
> > > >
> > > > > This error is coming from
> > > > >
> > > > > #0  jtjsignal (jt=0x7ffff7fc0200, e=3) at ../../../../jsrc/d.c:361
> > > > > #1  0x00007ffff34b131a in jtcvt () from
> > > > > /mnt/c/cygwin64/home/15712/jsoftware/jsource/bin/linux/j64avx2/libj.so
> > > > > #2  0x00007ffff350173e in jtvi (jt=0x7ffff7fc0200, w=0x4b4000) at
> > > > > ../../../../jsrc/u.c:570
> > > > > #3  0x00007ffff3501562 in jti0 (jt=0x7ffff7fc0200, w=0x4b4000) at
> > > > > ../../../../jsrc/u.c:238
> > > > > #4  0x00007ffff36fa6a1 in jtdeal (jt=0x7ffff7fc0200, a=0x7ffff3a3a680
> > > > > <Bnum+1088>, w=0x4b4000,
> > > > >     self=0x7ffff3a3b8c0 <primtab+2176>) at 
> > > > > ../../../../jsrc/vrand.c:794
> > > > >
> > > > > The issue seems to be the second i0 here
> > > > >
> > > > >  RE(m=i0(a)); RE(c=n=i0(w));  // c starts as max#+1
> > > > >
> > > > > In u.c, the comment on i0 is:
> > > > >
> > > > > // Extract the integer value from w, return it.  Set error if
> > > > > non-integral or non-atomic.  Values whose abs > IMAX are converted to
> > > > > IMAX/-IMAX
> > > > >
> > > > > I haven't yet figured out what's wrong with jti0 in this instance.
> > > > >
> > > > > FYI,
> > > > >
> > > > > --
> > > > > Raul
> > > > >
> > > > > On Wed, Jun 14, 2023 at 11:54 AM 'Veter Kamenev' via Beta
> > > > > <b...@jsoftware.com> wrote:
> > > > > >
> > > > > > Hi!
> > > > > >
> > > > > > 5 ? 2980293480239480239480239480239480239482039x
> > > > > >
> > > > > > |domain error, executing dyad ?
> > > > > > |y must be a positive integer
> > > > > >
> > > > > > I read in NuVoc:
> > > > > >
> > > > > > y       range of random number
> > > > > > 0       floating-point value in interval (0,1)
> > > > > > 1       0 (always)
> > > > > > 2       Boolean
> > > > > >  >1     integer or extended integer from list i.y
> > > > > >
> > > > > > https://code.jsoftware.com/wiki/Vocabulary/query#dyadic
> > > > > >
> > > > > > Best wishes,
> > > > > > Veter
> > > > > >
> > > ----------------------------------------------------------------------
> > > > > > For information about J forums see
> > > http://www.jsoftware.com/forums.htm
> > > > > ----------------------------------------------------------------------
> > > > > For information about J forums see http://www.jsoftware.com/forums.htm
> > > > >
> > > > ----------------------------------------------------------------------
> > > > For information about J forums see http://www.jsoftware.com/forums.htm
> > > ----------------------------------------------------------------------
> > > For information about J forums see http://www.jsoftware.com/forums.htm
> > >
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to