What does the convolution operator do? Is there an APL implementation?

Googled and checked out J fora, but couldn't find anything.

5 posts
• Page **1** of **1**

What does the convolution operator do? Is there an APL implementation?

Googled and checked out J fora, but couldn't find anything.

- seary
**Posts:**8**Joined:**Tue Jan 27, 2009 10:38 pm

seary wrote:

seary wrote: What does the convolution operator do? Is there an APL implementation?

Googled and checked out J fora, but couldn't find anything.

The convolution operator is a concept from mathematics (en.wikipedia.org/wiki/Convolution) from the first NARS system.

I seem to recall that I defined it as L f⍡g R for vectors where (⍴L)≥⍴R. Reverse R and drag it against L using g to compare the reversed R with the corresponding length subset of L, and reducing that by f to yield a vector of length 1+(⍴L)-⍴R.

For example, ∧⍡=∘⌽ is a string search function.

This would be a good candidate for a Magic Function.

- forummaster
**Posts:**567**Joined:**Wed Jan 23, 2013 1:00 pm

I would just add that the verb form is 'convolve'. I originally learned in optics that convolution is what a lens or filter does to light. It is very widely used in image processing and pattern recognition. For instance many of the effects in Photoshop are convolutions. I was deeply involved in using hardware-based binary and digital convolvers for character recognition at one time. I had not thought of convolution in the context of string searches, but I now will have to think about how Bayesian inference might be implemented as a convolution!

- gar37bic
**Posts:**5**Joined:**Sat Sep 04, 2010 11:59 am

This could be extremely useful in image processing (and the even documentation says so).

But you have prevented that by restricting the arguments to vectors.

Please support higher rank arrays -- at least matrices.

Also, the functions are apparently limited to scalar functions. It wouldn't let me try a ,⍡=

But you have prevented that by restricting the arguments to vectors.

Please support higher rank arrays -- at least matrices.

Also, the functions are apparently limited to scalar functions. It wouldn't let me try a ,⍡=

- drab
**Posts:**315**Joined:**Thu Oct 09, 2014 6:23 am

drab wrote:This could be extremely useful in image processing (and the even documentation says so).

But you have prevented that by restricting the arguments to vectors.

Please support higher rank arrays -- at least matrices.

Also, the functions are apparently limited to scalar functions. It wouldn't let me try a ,⍡=

Convolution could be defined on higher rank arrays, but its trivial to use the Rank operator for this purpose. For example,

- Code: Select all
`L←3 4⍴⍳12`

R←3 2⍴⍳6

L +⍡×⍤1 R

1 4 7 10 8

15 38 45 52 32

45 104 115 126 72

L[1;]+⍡×R[1;]

1 4 7 10 8

L[2;]+⍡×R[2;]

15 38 45 52 32

L[3;]+⍡×R[3;]

45 104 115 126 72

Try

- Code: Select all
`(⍳4),⍡⍴⍳3`

1 2 1 1 3 2 2 1 1 1 3 3 2 2 2 1 1 1 1 3 3 3 2 2 2 2 3 3 3 3

For reference, both Convolution and Rank operators are implemented as Magic Functions. Try ⎕VR '#DydConv' and ⎕VR '#DydRank'.

Having these definitions available is invaluable when some puzzling error occurs such as the error you encountered from ,⍡=.

Also, don't forget that polynomial multiplication (+⍡× -- see the examples above) is also a Convolution.

- forummaster
**Posts:**567**Joined:**Wed Jan 23, 2013 1:00 pm

5 posts
• Page **1** of **1**

Return to New Primitive Operators

Users browsing this forum: No registered users and 1 guest