performance between flip and \:

Hi everyone,for the non-recursive fft (fast fourier transformation) i need toselect every second element from a long 2 dimensional time series.I implemented it first using flip:\t value "flip flip[(cc#0f;til cc:int$xexp[2;c+1])] where raze (int$xexp[2;c:15])#enlist 10b"But this is the bottleneck in my implementation, so i switch it using: which is much faster than using flip.\t value "(cc#0f;til cc:int$xexp[2;c+1]) {[x;y] x where y}\\: raze(int$xexp[2;c:15])#enlist 10b"Can you give me hint why the second version is faster than the firstversion?Regards,Kim

To: personal-kdbplus@googlegroups.com
X-Mailer: Apple Mail (2.1251.1)

q)\t do[100;a:flip flip[(cc#0f;til cc:int$xexp[2;c+1])] where raze = (int $xexp[2;c:15])#enlist 10b]
7122
flip is expensive. just think about how much data you move

q)\t do[100;b:(cc#0f;til cc:int$xexp[2;c+1]) {[x;y] x where y}\: = raze(int$xexp[2;c:15])#enlist 10b]
252
this is better

rules of thumb: avoid complicated (and expensive) operations as long as =
you can (flip, where, floating point, each etc)

q)\t do[100;d:(cc#0f;til cc:2*c)@:2*til c:15(2*)/1]
81

Regards,
Attila