It's comparison tolerance that I think you would want to mess with, to
minimize the occurrences of this issue.

https://www.jsoftware.com/help/dictionary/dx009.htm

But you're not going to be able to set it higher than 9!:19]1e_12

If you are not concerned with floating point, though, you might want to try

runiform=: {{
  rnd=. ?@#&0
  relist=. (-/ , {:)@|.
  x:> (rnd y) #.each <relist x
}}

Also, testing this out, I noticed that my rephrasing of leftR and
rightR hit a length error.  Oops... I should have noticed that
earlier.

There's a variety of ways of fixing that, including:

runiform=: {{
  rnd=. ($~ $-.1:) ?@#&0
  relist=. (-/ , {:)@|.
  x:> (rnd y) #.each <relist x
}}

FYI,

-- 
Raul

On Mon, Jan 10, 2022 at 7:03 AM Pawel Jakubas <jakubas.pa...@gmail.com> wrote:
>
> Thanks Henry and Raul for your responses.
> Indeed, I have encountered limitations of floating point arithmetic.
>
> showmismatch is great idea to quickly detect cases validating property.
>
> Usually I will want to have something like this though (100 runs or so):
>       run=: 3 : 0
> shape=.1+?2#100
> m=.genUniformMatrix shape
> s=. _100 100 runiform 2
> s checkEqOfMatricesWithScalars m
> )
>    (+/)(run"0)100#0
> 100
>
> I will try to experiment also with digit precision and rounding as a
> measure to avoid those limitations.
>
> Cheers,
>
> Pawel Jakubas
> ----------------------------------------------------------------------
> 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