# Matrix cross correlation in python

I'm currently performing matrix cross correlation in python using :

C = scipy.signal.correlate2d(A,A)


where A is a 2D matrix, typically a picture. As you can imagine, it gets very long for large array, such that I'm looking for something faster.

Any hint ? I also heard about scipy.signal.fftconvolve. Despite that it's much more rapid, it rarely give me the same result at the end.

• my incantation is to ask why do you want to form a large rank 1 matrix? – user28715 Jul 17 '18 at 14:36
• Could you say what's A? Is it a 1D signal? Is a Random Vector Process? – Royi Jul 17 '18 at 14:57
• A is a 2D - matrix. Typically, it can be an picture. – Liris Jul 17 '18 at 17:02

scipy.signal.correlate2d(A,A) and scipy.signal.fftconvolve(A,A[::-1, ::-1]) will give the same result. The second one is much, much faster.