There is no value for m
tidot=: 1 : '#@[ - +/"1@:(+./\"1)@:(m teq"0/)~'
x=: 2 1 3
y=: 1+0.1*i.25
x 0.1 tidot y
so I took the 0.1 which I thought you must of intended to be in the
definition and got
x tidot y
|syntax error: tidot
| #@[-+/"1@:(+./\"1)@:( 0.1 teq"0/)~
I guess we also need teq
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Roger Hui
Sent: Monday, January 16, 2012 12:38 AM
To: Programming forum
Subject: Re: [Jprogramming] i.!.1e_7~
You can use the ideas and models in
http://www.jsoftware.com/jwiki/Essays/Tolerant_Comparison . Tolerant
index-of is not modeled there but obtains without much difficulty:
tidot=: 1 : '#@[ - +/"1@:(+./\"1)@:(m teq"0/)~'
x=: 2 1 3
y=: 1+0.1*i.25
x 0.1 tidot y
1 1 3 3 3 3 3 3 0 0 0 0 0 3 3 3 3 2 2 2 2 2 2 2 3
On Sun, Jan 15, 2012 at 9:11 PM, Raul Miller <[email protected]> wrote:
> Let's suppose that I have some low precision floating point numbers:
>
> require 'dll'
> PIs=: _1 fc a.{~ 219 15 73 64 220 15 73 64 218 15 73 64
> PIs
> 3.14159 3.14159 3.14159
>
> I would like to be able to recognize that some of these values are
> close to each other
> i.!.3e_7~ PIs
> |domain error
>
> I can't use comparison tolerance on i. for this purpose, because i.
> throws a domain error when I try to specify the precision I want to
> use.
>
> I also can't use ": because I can't rely on the numbers not being "off
> by one" when formatted -- but I can rely on them being close enough
> that if they were slightly different they would format the same.
>
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm