OK Roger - trapped by type the second time this week!
NB. as you say:
  (datatype@".;ts)'(**<.@:**)(100000$i:5)--:ct'
+--------+-------------------+
|floating|0.0105938 3.67232e6|
+--------+-------------------+
NB. the following forced integer is still quite nifty
  (datatype@".;ts)'(<[EMAIL PROTECTED]<.@:**)(100000$i:5)--:ct'
+-------+-------------------+
|integer|0.0309942 4.72128e6|
+-------+-------------------+
NB. but
  (datatype@".;ts)'(**<.@:|)(100000$i:5)--:ct'
+-------+-------------------+
|integer|0.0255591 4.19622e6|
+-------+-------------------+
... so the more natural way is preferable after all
if/when integer results are required.

Thanks
Mike

Roger Hui wrote:
  NB. there must be some optimisation here?!
  ts'(**<.@:**)(100000$i:5)--:ct'
0.0108771 3.67232e6

There are no optimizations.  The expression is fast
because it avoids the most expensive operation
executed by the other expressions -- the monad <. on floats.

BTW, the result of the expression is a float and
is not necessarily an exact integer:

   ] b=: (**<.@:**) 5+-:ct
5
   b-5
2.84217e_14



----- Original Message -----
From: Mike Day <[EMAIL PROTECTED]>
Date: Monday, October 23, 2006 11:12 am
Subject: Re: [Jprogramming] fuzzy <.0

... but the timings aren't so good - perhaps that
doesn't matter.

  ts'<.`0:@.(0=*)("0) (1000000$i:5)--:ct'
0.995482 5.82e7

NB. similar avoiding the "0 test: ts'(<.*0:~:*) (1000000$i:5)--:ct'
0.279156 3.04111e7

  NB. there must be some optimisation here?!
  ts'(**<.@:**)(100000$i:5)--:ct'
0.0108771 3.67232e6
M

bill lam wrote:
bill lam wrote:
I also try <.`0:@.(1:=>:)("0)
another candidate may be <.`0:@.(0:=*)("0) as monad * is
tolerant when comparing
with 0.


----------------------------------------------------------------------
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