<begin ObservationOnRankOnly>

Frow will execute faster, but use more space, if infinite ranks
are used, as in FrowI.

Frow=: +/@ ((=<.)@%&>: i.)"0
FrowI=: +/@ ((=<.)@:%&:>: i.)"0

   (Frow-:FrowI)10 [EMAIL PROTECTED] 10000000
1

ts=: 6!:2,7!:2

   ts 'Frow ?. 10000000'
7.41913 7.55009e7
   
   ts 'FrowI ?. 10000000'
0.596567 3.43935e8

<end ObservationOnRankOnly>

Miller, Raul D wrote:
> bill lam wrote:
> BUT obviously processing the upper triangular (and diagonal) is 
> reducdant. The time and space cost for large matrix may be 
> significant.

This is not at all obvious in the context of time cost.

You'll get a factor of 2 in space and time this way.  The
introduction of added logic to avoid the extra elements
may or may not cost more than that.

Issues which are likely to be significant include the cost
of the function being evaluated and the size of the
intermediate array, and the design of the machine's caches.

The problem size threshold where space cost matters is going 
to be relatively small.  The threshold where time cost 
matters is going to be quite a bit larger (you'd need
to test to find out roughly where it is on your machine).

That said, Oleg's post demonstrates one easy approach to
this.  Conceptually: write a function which computes the 
answer for one row of the table, given the row's index, and 
sum the results of applying that function to a vector of
row indices.
  Frow=: +/@ ((=<.)@% >:@i.)@>:
  Fsize=: [: +/ Frow at i.

Or, for "just the lower triangle":
  Frow=: +/@ ((=<.)@%&>: i.)"0

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to