functions - Ted's explanation for the 3rd argument of ListCorrelate doesn't apply to the {1, -1} case?
I was reading Ted Ersek's explanation for the usage of ListCorrelate
(.nb version can be found here) and noticed something confusing. It's the third example of Specifying the "overhang" using {$K_L$, $K_R$} section:
You may think that it's a typo at first glance, but the output is really correct. Just try it yourself:
{{a1, a2, a3, a4, 0, 0}, {0, a1, a2, a3, a4, 0}, {0, 0, a1, a2, a3,
a4}, {a4, 0, 0, a1, a2, a3}, {a3, a4, 0, 0, a1, a2}, {a2, a3, a4,
0, 0, a1}, {a1, a2, a3, a4, 0, 0}, {0, a1, a2, a3, a4, 0}, {0, 0,
a1, a2, a3, a4}}.{{b1}, {b2}, {b3}, {b4}, {b5}, {b6}}
Flatten[%] === ListCorrelate[{a1, a2, a3, a4}, {b1, b2, b3, b4, b5, b6}, {1, -1}]
False
The other 3 examples do follow the statement though.
So Ted's theory is simply incomplete but he didn't notice? Or there's some deeper reason (in compatible changes between versions etc.)?
Answer
The fact that False
is on his own web page indicates against this being a change between versions but rather something he failed to notice.
Following his equivalence we also have the last kernel element (a4
) in the last place in the third row of the left matrix, an indeed that matches the actual output:
m = NestList[RotateRight, {a1, a2, a3, a4, 0, 0}, 2]
$\left( \begin{array}{cccccc} \text{a1} & \text{a2} & \text{a3} & \text{a4} & 0 & 0 \\ 0 & \text{a1} & \text{a2} & \text{a3} & \text{a4} & 0 \\ 0 & 0 & \text{a1} & \text{a2} & \text{a3} & \text{a4} \\ \end{array} \right)$
ListCorrelate[{a1, a2, a3, a4}, {b1, b2, b3, b4, b5, b6}, {1, -1}]
% === m.{b1, b2, b3, b4, b5, b6}
{a1 b1 + a2 b2 + a3 b3 + a4 b4,
a1 b2 + a2 b3 + a3 b4 + a4 b5,
a1 b3 + a2 b4 + a3 b5 + a4 b6}
True
Comments
Post a Comment