Complex division using Fixed Point

817 views Asked by At

I'm working on writing a C program to perform division of 2 complex numbers in Fixed Point. I'm not able to get the fractional part from it. Below is more details on it.

I have 2 complex numbers:

N = a + ib
M = c + jd

I need to do N/M in fixed point (not using floating point)

Example values for the above complex numbers can be:

a = 1.55, b = 1.44, c = 1.24, d = 0.55

N = 1.55 + i(1.44)
M = 1.24 + j(0.55)

For converting to Fixed Point, I multiply these a, b, c and d with 2^14. After that they become:

a = 0x6333, b = 0x5c28, c = 0x4f5c and d = 0x2333

Then to perform the N/M operation I do:

N/M = (a + ib)/(c + jd) = ((a + ib) * (c - jd)) / ((c + jd) * (c - jd))

Then for the real part alone:

(ac + bd) / (c^2 + d^2)

and so on..

The issue I'm facing is that I'm not understanding how to get the fractional part from the division. I'm getting only the decimal part which is mostly either 1 or 0.

What is the correct way to get the fractional part? In the above example, the real part should be something like 1.47490. But I'm only able to get 1.

Can anyone please help me with the right way in doing the complex division for Fixed Point?

Thank you very much.

2

There are 2 answers

0
Aki Suihkonen On

In fixed point division and multiplication one must notice that the result value must have also scaling factor K.

in addition / subtraction:
a * K  + b * K  =  K * ( a + b)

in multiplication:

(a * K) * (b * K)  =  K^2 * (a * b)   --> must compensate with 1/K
proper form:  (aK * bK) / K

in division:

(a * K) / (b * K) = a / b      --> must pre-multiply with K
proper form:   (aK * K) / (bK)
0
Robin Hsu On

For two complex X=a+jb, and Y=c+jd, where j=sqrt(-1), and a, b, c, d are real numbers, the division X/Y is given by

(ac+bd)/(c^2+d^2) + j(bc-ad)/(c^2+d^2)

Let K = 2^14, the binary digit for saving the fraction, as you mentioned. Let A is the fixed number representation of a, i.e. A = a * K, and similarly let B = b*K, C=c*K, and lastly D=d*K. Assume your number is not big enough to overflow the integer of your computer, in the following calculations:

You should first calculate U = A * C + B * D, V = C * C + D * D, W = B * C - A * D Then, you should calculate V' = V >> 14. Then, the real part of X/Y is U/V', and the imaginary part of X/Y is W/V', with both parts represented in your fixed point form.