Struggling to learn, I think that if you wrote an explicit form such as
hh=: 3 :'(y+/ .* 1|.y)% */y'
which, while easier to follow, does suffer in terms of execution time
with respect to g and h
10000 (6!:2)'g 2 3 5'
3.17658e_6
10000 (6!:2)'h 2 3 5'
3.30612e_6
10000 (6!:2)'hh 2 3 5'
7.0461e_6
Here are some comparisons:
zij =:3j1.5 5j1.5 7j_1.5
deltoy=:3 : '(y*_1|. y)%+/y' NB. original explicit form
d2y2=:+/ %~ ] * _1&|. NB.Jasmin Pascal
del2y=:(] * _1 |. ]) % +/ NB. From R.Boss using 13: vs 3: in the
explicit definition
deltoya=:(* _1&|.)% +/ NB. Day
---------------
ytodel =:3 : '(+/(y*_1|. y))% 2 0 1{y' NB. Original
y2d =: (2 0 1&{ %~ ] +/@:* _1&|.) NB. Pascal
y2del=:([: +/ ] * _1 |. ]) % 2 0 1{ ] NB. Boss based on ytodel =: 13:
'(+/(y*_1|.y))% 2 0 1{y'
y2dela=: ([: +/ ] * _1 |. ])% _1|.] NB. Boss modified
ytodela=: ( +/@:* %] ) _1&|. NB. Mike Day
-----------------
]s=:d2y2 zij
1.57426j0.242574 0.920792j0.707921 2.47855j_0.0478548
y2d d2y2 zij
3j1.5 5j1.5 7j_1.5
---------
_Function_ _Timing_ _ Space_
deltoy 5.98284e_6 5248 Significantly slower and larger
del2y 2.96321e_6 2048 } These for timing are all fairly
close
d2y2 2.88758e_6 2048 }within random error but deltoya
has a slight edge
deltoya 2.79254e_6 2304 }
----------
ytodel 6.67191e_6 5376
y2d 3.54172e_6 2176
y2del 3.51222e_6 2048
y2dela 3.50303e_6 2048
ytodela 3.1952e_6 2304
My conclusion is- make it tacit for use and the use of 13: is easy to
do and is easy to read (thank you C. Boss),Going tacit from scratch may
be more fun and appears to have a slight edge.
Don
On 01/11/2013 6:19 PM, Linda Alvord wrote:
I'm not sure I understand the concept of dynamic execution, but I found a
tacit expression which helped me understand the result.
g=: 13 :'((+/ .* 1&|.)% */)y'
g 2 3 5
1.03333
h=: 13 :'(y+/ .* 1|.y)% */y'
h 2 3 5
1.03333
g
(+/ .* 1&|.) % */
h
(] +/ .* 1 |. ]) % */
h in not quite as nice as g, but I found it helpful.
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Dan Bronb
Sent: Friday, November 01, 2013 8:15 AM
To: [email protected]
Subject: Re: [Jprogramming] making this tacit
Because with f, you're asking that a NVV train be created dynamically based
on its argument: that is, you're changing syntax during execution.
There is no tacit way to express that - dynamic execution of code is the
definition of explicit.
-Dan
Please excuse typos; composed on a handheld device.
On Nov 1, 2013, at 4:30 AM, "Linda Alvord" <[email protected]>
wrote:
Why isn't f tacit, but g is?
f=: 13 :'(+/ .* (1|.y)% */)y'
f 2 3 5
1.03333
f
3 : '(+/ .* (1|.y)% */)y'
g=: 13 :'((+/ .* 1&|.)% */)y'
g 2 3 5
1.03333
g
(+/ .* 1&|.) % */
Linda
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Don
Kelly
Sent: Thursday, October 31, 2013 10:09 PM
To: [email protected]
Subject: Re: [Jprogramming] making this tacit
I made an error (BIG GOOF)and gave a problem other than what I wanted
so I sent you and Raul on a wild goose chase.
Your
(+/@(*/)@(,: 1&|.) % */) 2 3 5
and Raul's
((+/ .* 1&|.) % */) 2 3 5
Agree and are more material to study, Thanks
Don
On 30/10/2013 5:59 AM, Jan-Pieter Jacobs wrote:
I'd write it tacitly like this:
(+/@(*/)@(,: 1&|.) % */) a b c
This is mainly motivated by the fact that a * b + b* c + c*a can be
expressed as multiplying with a shifted version, then summing.
Jan-Pieter
2013/10/30 Raul Miller <[email protected]>
On Wed, Oct 30, 2013 at 2:51 AM, Don Kelly <[email protected]> wrote:
You are right but it is a bit of serendipity What I wanted is
(a*b+ b*c+c*a ) % c a b .
it doesn't matter how the pairs are formed in the numerator
ac+ba+cb is the same.
Like this?
F=: +/ .* (</~i.3) +/ .* ] % */
That's probably awful for speed, but it does express the idea.
Thanks,
--
Raul
--------------------------------------------------------------------
-
- 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
----------------------------------------------------------------------
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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm