3

I was over on stack overflow when I came across an algorithm based questions asking for help. I started working on it, but once I got the poster's example working the poster deleted the question.

Thinking about it a little more, I wondered what this type of matrix operation this is actually called, what it can be used for, and if there is a better way to calculate it.

Operation Assumptions: - Two matrices are required. - Both matrices have the same dimensions. - They do no need to be square matrices. - Each dimension of a matrix is an odd number greater than 1

Operation Explanation: You have two matrices. I'll call them A and B. You start by overlaying matrix A over matrix B in such a way that the center cell of matrix A overlaps the top left most cell of matrix B. You proceed to multiply the values in overlapping cells between the two matrices and add the resulting multiplications together. This result gets placed in matrix C at the same coordinates that matrix A's center cell is overlapping in matrix B.

You then slide matrix A to the right one cell so that matrix A's center cell now overlaps matrix B's topmost cell in column 2. You perform the above calculation and record the result in matrix C.

Once the center cell of matrix A reaches the rightmost cell of matrix B, you wrap around to the second row of matrix B and start again.

You finish when the center cell of matrix A overlaps the bottom right most cell of matrix B.

Below is a graphical example of the first few steps and a complete matrix C.

enter image description here

Edit:

Ok so after a few comments came in and provided some terms, I did a little research reading here: https://en.wikipedia.org/wiki/Convolution https://en.wikipedia.org/wiki/Correlation_and_dependence http://www.sthda.com/english/wiki/correlation-matrix-a-quick-start-guide-to-analyze-format-and-visualize-a-correlation-matrix-using-r-software

I'm still not sold that this is either a correlation calculation or a convolution calculation. (To be fair, I might just be missing some key point)

The convolution operation sounds interestingly related since integrals of point multiplications of each function seems close to summation of the multiplicative result of cells in a set of matrices, but in the function example all combinations are operated on. In my above matrix operation there are cells that are never multiplied together (i.e. A[0,0] and B[2,2]).

Correlation could be involved, but in that case what would the matrices be? Two correlation matrices? What would the result matrix represent?

MrJman006
  • 131
  • 2

0 Answers0