Is there a clever way of determining if one matrix is contained within another larger matrix? Iterating over the larger matrix to check each item until potential matches show up is straightforward but gets slow for large matrices.
Example, a smaller matrix:
$$\begin{pmatrix}4&3&2\\2&3&4\end{pmatrix}$$
which is "within" (I'm probably not using the right terminology) this larger matrix:
$$\begin{pmatrix}1&2&3&4&5\\5&\color{red}4&\color{red}3&\color{red}2&1\\1&\color{red}2&\color{red}3&\color{red}4&5\end{pmatrix}$$
It feels like a problem that could have a smart mathematics trick for determining if this is the case - is there one?
From a signal processing viewpoint, this problem can be tackled using 2D Fourier transform:
You take FFT of the "small" matrix, FFT of the large one, multiply the two together and perform IFFT on the result. Then the point with maximum intensity is the location.
The advantage of this approach is that you need to compute FFT of the large matrix only once and re-use it for different templates.
I am not sure about the actual implementation, but you can find it using keywords "correlation convolution FFT".