The discrete convolution of the two vectors
<A, B, C>
and
<X, Y, Z>
is
<A*X, B*X + A*Y, C*X + B*Y + A*Z>
.
Generally,
the convolution of f
and g
,
f*g
,
is
(with 0's understood for vector indices < 0 and ≥ the vectors's length).
We want to find the convolutions of vectors of complex numbers. Recall the multiplication of two complex numbers:
(a + bi)(c + di)
= (ac - bd) + (bc + ad)i
.
The input consists of pairs of lines of complex numbers. The real and imaginary component of each number is an integer. Each line of the pair represents a vector, and both vectors have equal length. Each pair will be separated by a blank line.
No line will be more than 12 complex numbers. Assume the convoluted terms can be represented by 32-bit integers.
The imaginary part never is written with a unary minus in front;
e.g., -1 + -2i
.
Rather, that would be written as -1-2i
.
Also the real and imaginary components
are always written even when zero;
e.g.,
-1+0i
and
0-2i
.
For 0i
,
always precede it with a plus;
e.g.,
-1+0i
,
not
-1-0i
.
Your output should be a single line of complex numbers (space separated) that is the convolution for the imput pair. There should be a blank line between cases.
4+4i 2-2i -7+3i 5-2i 11-13i -17+19i 5-4i 3+2i 7+0i 2+8i 9-13i 1-9i
16+0i -38+124i 91-271i 42+32i -17-73i 36-14i