When the time for a sentence gets down to 1e_6, you are timing parsing
as much as execution. My version has more modifiers (including
invisible ones), and they take longer to parse. To test execution, do
the parsing elsewhere:
a =. (4 $. $.@:=)
b =. ($@] #: I.@(= ,))
r =. i. 3 4
100000 (6!:2) '6 a r'
1.16996e_6
100000 (6!:2) '6 b r'
6.25331e_7
Beauty is in the eye of the beholder, but an engineer sees beauty in a
solution well-matched to the problem. I think my Prius is beautiful,
BECAUSE I know that its shape has the lowest drag that has ever been
created. Non-engineers often say it's dumpy. If you think about what
has to be done to convert a matrix from dense to sparse, you will see
that (4 $. $.) does a lot more than this problem needs. To some it may
seem sleek, but it's a Hummer to me.
Henry Rich
On 11/13/2020 6:58 PM, 'robert therriault' via Programming wrote:
Ric,
Do you actually find your result faster and leaner? In j902 I find Henry's is
quicker and leaner even in higher dimensions.
1000 timespacex '6 (4 $. $.@:=) i. 3 4'
1.194e_6 4096
1000 timespacex '6 ($@] #: I.@(= ,)) i. 3 4'
8.57e_7 2496
1000 timespacex '6 (4 $. $.@:=) i. 2 3 4'
1.131e_6 4096
1000 timespacex '6 ($@] #: I.@(= ,)) i. 2 3 4'
9.95e_7 3008
1000 timespacex '6 (4 $. $.@:=) i. 6 2 3 4'
1.264e_6 4224
1000 timespacex '6 ($@] #: I.@(= ,)) i. 6 2 3 4'
1.08e_6 3008
1000 timespacex '6 (4 $. $.@:=) i. 5 5 6 2 3 4'
4.345e_6 41408
1000 timespacex '6 ($@] #: I.@(= ,)) i.5 5 6 2 3 4'
2.618e_6 39552
JVERSION
Engine: j902/j64avx2/darwin
Beta-l: commercial/2020-11-05T14:07:25
Library: 9.02.07
Qt IDE: 1.8.7/5.12.7(5.12.7)
Platform: Darwin 64
Installer: J902 install
InstallPath: /users/bobtherriault/j902
Contact: www.jsoftware.com
I know for certain my earlier approach is not in the running! And I do like
your approach in terms of getting the computer to do the work for you!
Cheers, bob
On Nov 13, 2020, at 15:12, Ric Sherlock <[email protected]> wrote:
I understand the sentiment, but when it's more concise, faster and leaner,
it is hard to ignore!
On Sat, 14 Nov 2020, 09:37 Henry Rich, <[email protected]> wrote:
/Et tu, R. E.?/
Using $. for this is using a sledgehammer to crack an egg.
Henry Rich
On 11/13/2020 3:00 PM, R.E. Boss wrote:
$.$.M
0 0 │ 1
0 1 │ 2
0 2 │ 3
0 3 │ 4
1 0 │ 5
1 1 │ 6
1 2 │ 7
1 3 │ 8
2 0 │ 9
2 1 │ 10
2 2 │ 11
2 3 │ 12
R.E. Boss
-----Original Message-----
From: Programming <[email protected]> On Behalf
Of thomas.bulka via Programming
Sent: vrijdag 13 november 2020 18:05
To: [email protected]
Subject: [Jprogramming] Getting indices of matrix elements
Hi everyone,
still learning J, I stumbled across a problem which should be easy to
solve, but somehow I have not been able to do so, yet. Say, I have defined
a matrix M:
M =: 3 4 $ >: i. 12
I now want to get the row and column index of 6 in M, which is 1 2. If M
was a vector, I could easily get the index of 6 with the help of I.:
I. 6 = , M
Applying I. to M in its original shape, however, returns a boolean
vector which indicates in which rows 6 has been found (at least that is my
interpretation).
Is it possible to apply I. to higher rank arrays in order to receive the
complete indices of the elements I'm looking for? Or should I approach that
problem in another way?
Thank you very much in advance for your help!
Kind regards,
Thomas
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
--
This email has been checked for viruses by AVG.
https://www.avg.com
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm