The problem I'm in the midst of is [Maximum subarray], as detailed here: http://rosettacode.org/rosettacode/w/index.php?title=Maximum_subarray
I want to handle this by applying the technique Roger used in his solution to "all possible additions of every subset of n numbers" http://www.jsoftware.com/pipermail/general/2007-August/030686.html (The obvious alternative approach would involve scanning. Roger's use of inner product appeals to me much more.) The set of all subarrays (as defined for this problem) is the subset of the boolean table where items are omitted if any zero occurs between two ones. So, in the simple example where b=: #: i. 2^3 (-.@(ix01icolon > ix10idot) # ]) b 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 1 0 1 1 1 The inner product of this and the value-vector of length b gives all subarray totals. The maximum of these indicates the subarray to be returned as the answer to the overall problem. Excluding the disqualified bit combinations turned out to be a lot messier than I thought it would be. The messiest part is dealing with the no-instance results of E. (which I handled by negation, thus the _3 values the result from indexing verb ix01icolon when applied to this three-column table). So, my main curiosity is how this messiness can be reduced. Tracy ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
