RAM: cross-power-spectrum (for Phase Correlation). https://en.wikipedia.org/wiki/Phase_correlation
| 1670 | // RAM: cross-power-spectrum (for Phase Correlation). |
| 1671 | // https://en.wikipedia.org/wiki/Phase_correlation |
| 1672 | static void |
| 1673 | nc_crosspower(npy_intp n, npy_complex64 *a, npy_intp sb1, npy_complex64 *b, npy_intp sb2, npy_complex64 *r) { |
| 1674 | npy_float32 mag; |
| 1675 | npy_complex64 prod; // Not-inlining this into r should improve SIMD performance. |
| 1676 | |
| 1677 | if( sb1 == sizeof(npy_complex64) && sb2 == sizeof(npy_complex64) ) { // Aligned |
| 1678 | for( npy_intp I = 0; I < n; I++ ) { |
| 1679 | // Take product of A and complex conjugate of B |
| 1680 | prod.real = a[I].real*b[I].real + a[I].imag*b[I].imag; |
| 1681 | prod.imag = -a[I].real*b[I].imag + a[I].imag*b[I].real; |
| 1682 | // Compute magnitude |
| 1683 | mag = 1.0f/sqrtf(prod.real*prod.real + prod.imag*prod.imag); |
| 1684 | // Normalize |
| 1685 | r[I].real = prod.real*mag; |
| 1686 | r[I].imag = prod.imag*mag; |
| 1687 | } |
| 1688 | } |
| 1689 | else { |
| 1690 | sb1 /= sizeof(npy_complex64); |
| 1691 | sb2 /= sizeof(npy_complex64); |
| 1692 | for( npy_intp I = 0; I < n; I++ ) { |
| 1693 | // Take product of A and complex conjugate of B |
| 1694 | prod.real = a[I*sb1].real*b[I*sb2].real + a[I*sb1].imag*b[I*sb2].imag; |
| 1695 | prod.imag = -a[I*sb1].real*b[I*sb2].imag + a[I*sb1].imag*b[I*sb2].real; |
| 1696 | // Compute magnitude |
| 1697 | mag = 1.0f/sqrtf(prod.real*prod.real + prod.imag*prod.imag); |
| 1698 | // Normalize |
| 1699 | r[I].real = prod.real*mag; |
| 1700 | r[I].imag = prod.imag*mag; |
| 1701 | } |
| 1702 | } |
| 1703 | } |
| 1704 | |
| 1705 | static void |
| 1706 | nc_crosspower(npy_intp n, npy_complex128 *a, npy_intp sb1, npy_complex128 *b, npy_intp sb2, npy_complex128 *r) { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…