Integrated point product in CMSIS DSP LIBRARY

I recently looked at the CMSIS DSP mathematical function library, and I saw something that I cannot fully understand, thus, my first post on SO.

What I cannot understand is how he11 can use the complex point product function to get the correct result? Function can be found here: Dot Integrated Product

As far as I understand, part

for(n=0; n<numSamples; n++) { realResult += pSrcA[(2*n)+0]*pSrcB[(2*n)+0] - pSrcA[(2*n)+1]*pSrcB[(2*n)+1]; imagResult += pSrcA[(2*n)+0]*pSrcB[(2*n)+1] + pSrcA[(2*n)+1]*pSrcB[(2*n)+0]; } 

is A-okay, but like this:

 /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ real_sum += (*pSrcA++) * (*pSrcB++); /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ imag_sum += (*pSrcA++) * (*pSrcB++); 

should work because it misses the product of the real parts * of the sample samples?

It could - and most likely - really be a stupid question, but somehow I just don't see it working.

+4
source share
1 answer

It just looks wrong and the implementation is not as described.

Suppose that z = x + i*y and w = u + i*v with x, y, u, v real. Then

 z*w = (x + i*y)*(u + i*v) = (x*u - y*v) + i*(x*v + y*u) 

and

 z*conjugate(w) = (x + i*y)*(u - i*v) = (x*u + y*v) + i*(y*u - x*v) 

So with the loop

 while(blkCnt > 0u) { /* CReal = A[0]* B[0] + A[2]* B[2] + A[4]* B[4] + .....+ A[numSamples-2]* B[numSamples-2] */ real_sum += (*pSrcA++) * (*pSrcB++); /* CImag = A[1]* B[1] + A[3]* B[3] + A[5]* B[5] + .....+ A[numSamples-1]* B[numSamples-1] */ imag_sum += (*pSrcA++) * (*pSrcB++); /* Decrement the loop counter */ blkCnt--; } 

you will get real_sum + imag_sum = Real part of hermitian inner product finally.

Neither real_sum nor imag_sum in any way connected with the real / imaginary part of the scalar product or the bilinear product.

+1
source

Source: https://habr.com/ru/post/1444220/


All Articles