I have a blind spot in making certain forms tacit.

Here is an example, similar to correlation.  I have a small vector
(probe) and I want to calculate its dot product with subarrays of some
data.

data=:(i.4),(i.3),(i.4),(i.5)
dot=:+/ .*
probe=:i.4
   (#probe) probe&dot\ data
14 8 6 8 5 5 8 14 8 6 8 14 20

This is the result I want. I can write an explicit verb

f1=:4 : '(#x) x&dot\ y'
   probe f1 data
14 8 6 8 5 5 8 14 8 6 8 14 20

but I cannot see how to make it tacit.

I can rewrite the tacitly verb using polynomial multiplication to give
essentially the same result:

ppr=:(+//.)@(*/)
f2=:|.@:(ppr |.)

   probe f2 data
0 3 8 14 8 6 8 5 5 8 14 8 6 8 14 20 11 4 0

but I would like to be able to take f1 as is and rewrite it tacitly.


Best wishes,

John


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

Reply via email to