coord0 and coord1 give different answers if the
argument is not a matrix. Benchmarking the
different solutions in time and space on a matrix:
f=: $ #: I.@,
g=: ;@:(i.@:}:@:$ ,.&.> <@I.)
h=: 4 $. $.
M=: 1e5 100 [EMAIL PROTECTED] 2
(f -: g) M
1
(f -: h) M
1
J6.02x J6.01c
f M 0.530783 1.00664e8 0.524774 1.00664e8
g M 0.637148 1.21485e8 0.658235 1.21533e8
h M 0.274866 7.54994e7 0.847815 2.43272e8
----- Original Message -----
From: Dan Bron <[EMAIL PROTECTED]>
Date: Monday, January 29, 2007 5:30 pm
Subject: RE: [Jprogramming] matrix to coordinates
> Actually, ;@:(i.@:}:@:$ ,.&.> <@I.) is little bit faster:
>
>
> coord0 =: $ #: I.@,
> coord1 =: ;@:(i.@:}:@:$ ,.&.> <@I.)
>
>
> b =: ?@:$&2
> ts =: 6!:2 , 7!:2@:]
> fmt =: [: ,.&:>/ [: }.@:, (<4 1 $ ' ') ,. (;:'Name
> Time Space') ,&.> '-' ,&.> [: <@:>"1@:|: [ ,. '0.3d' 8!:0 ] %"1 <./@:]
>
>
> M =: b 1000 10 10 100
>
> r =: 20 ts&> ' M' , L:0~ fn =. coord0`coord1
>
> fn fmt r
> Name Time Space
> ------ ----- -----
> coord0 1.414 1.380
> coord1 1.000 1.000
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm