[Jprogramming] dyad ": rounding error
Dan Bron
jf at dbron.net
Tue Mar 20 02:02:14 HKT 2007
Roger wrote:
> The difference is that the dyad ": depends on the
> C library routines whereas 8!:x do the programming
> themselves
Is 8!:x fast? If so, is it feasible and desirable to implment m ": n for numeric n by calling 8!:x under the covers? Something along these lines:
fmt =: verb define"1 _
": y
:
'a b'=. <"_1 |: fmt&.> +. x
k =. , L: 0
;:^:_1 ('b< >' k (>a) k '.' k (>b)) 8!:0 y
)
I'm sure that's buggy and incomplete, but it gives the gist.
I will note that the ;:^:_1 part annoys me, and this isn't the first time. I wish I had a version of 8!:2 that put spaces between the formatted numbers. For example, as opposed to:
'0.3' (8!:2) 9 9
9.0009.000
I would like:
'0.3' (8!:3) 9 9
9.000 9.000
Actually, in the above case, ;:^:_1 probably isn't sufficient, due to layout and alignment, as in:
1000001 _14 ((<1;1;0),(<0;0;2)) } i. 3 3 3
0 1 _14
3 4 5
6 7 8
9 10 11
1000001 13 14
15 16 17
18 19 20
21 22 23
24 25 26
so maybe in the re-implementation of dyad ": only the individual scalar numbers should be formatted with 8!:0 . The the spacing and layout should be left to the current algorithm.
-Dan
More information about the Programming
mailing list