+/ and +/"_1 compute different things. x1=: 5 5e5 [EMAIL PROTECTED] 0 $ +/ x1 500000 $ +/"_1 x1 5
----- Original Message ----- From: Fraser Jackson <[EMAIL PROTECTED]> Date: Thursday, July 26, 2007 14:36 Subject: Re: [Jprogramming] (+/%#)"r To: Programming forum <[email protected]> > Note 'Roger''s Post' > Roger's post led me to consider applying "_1 > (the default) to +/ and I was surprised that > there could be substantial differences in relative > performance - is there more to be wrung out of > the performance of this classic computation in J? > > For large scale simulations the differences are large > enough to want to consider the detail of the code > for data objects of different shape. > ) > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] > > v =: 3 : 0 > d =. ts '(+/%#) y' > f =. ts '(+/"_1%#) y' > d,:f > ) > > x1=: 5 5e5 [EMAIL PROTECTED] 0 NB. wide > x2=: 5e5 5 [EMAIL PROTECTED] 0 NB. tall > x3=: 1580 1600 [EMAIL PROTECTED] 0 NB. squarish > > v x1 > 0.0450473 8.38982e6 > 0.00966296 1792 > v x2 > 0.0124485 1472 > 0.0334677 8.39014e6 > v x3 > 0.0105466 33984 > 0.00992556 34304 > > Note'' > Should we conclude the following: > > In wide cases use "_1 > In tall cases use without rank > In squarish cases it probably does not matter > > > ts is so widely used in this forum it should be > in the standard library! > > ) > > ----- Original Message ----- > From: "Roger Hui" <[EMAIL PROTECTED]> > To: "Programming forum" <[email protected]> > Sent: Thursday, July 26, 2007 7:09 PM > Subject: Re: [Jprogramming] (+/%#)"r > > > Sorry, the mailer made a hash of my msg. > > +/"r has integrated rank > support but (+/%#)"r does not. > Therein lies an opportunity for an > improvement in the > implementation. > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] > > x=: 5 5e5 > [EMAIL PROTECTED] 0 NB. wide > ts '(+/%#)"1 x' > 0.0777057 4.1961e6 > ts '(+/"1 > x)%{:$x' > 0.0110925 1792 > > x=: 5e5 5 [EMAIL PROTECTED] 0 NB. tall > ts > '(+/%#)"1 x' > 0.612025 4.1961e6 > ts '(+/"1 x)%{:$x'0.033295 8.39014e6 > > x=: 1580 1600 [EMAIL PROTECTED] 0 NB. squarish > ts '(+/%#)"1 x' > 0.0167924 34432 > > ts '(+/"1 x)%{:$x' > 0.0112939 34304 > > > > ----- Original Message ----- > From: Roger Hui <[EMAIL PROTECTED]> > Date: Thursday, July 26, 2007 0:04 > Subject: [Jprogramming] (+/%#)"r > To: Programming forum <[email protected]> > > > +/"r has integrated rank support but (+/%#)"r does not.Therein > > lies an opportunity for an improvement in the implementation. > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] x=: 5 5e5 [EMAIL PROTECTED] 0 NB. wide ts > > '(+/%#)"1 > > x'0.0777057 4.1961e6 ts '(+/"1 x)%{:$x'0.0110925 1792 > > x=: 5e5 5 [EMAIL PROTECTED] 0 NB. tall ts '(+/%#)"1 x'0.612025 > > 4.1961e6 ts '(+/"1 x)%{:$x'0.033295 8.39014e6 x=: 1580 > > 1600 [EMAIL PROTECTED] 0 NB. squarish ts '(+/%#)"1 x'0.0167924 34432 ts > > '(+/"1 x)%{:$x'0.0112939 34304 ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
