Hi everyone,is there a better way to create moving windows in a vectoriell way ?My version use scan which could be a bottle neck in my application:{1_{1_x,y} scan enlist[x#0#y],y }[3] til 10Thx for any suggestions or comments,Kim
Hi,
Does the following suit your problem?? Still uses scan but uses “flip” & “prev” instead of your lambda.
q){ flip reverse prev[x-1; til y]}[3;10]
??? 0
? 0 1
0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
5 6 7
6 7 8
7 8 9
Seems to scale well in comparison also;
q)\ts do[1000000; {1_{1_x,y} scan enlist[x#0#y],y? }[10] til 100]
32960 11728j
q)\ts do[1000000; { flip reverse prev[x-1; til y]}[10;100]]
11203 13344j
Thanks,
Stephen
Very cool,Thx,KimOn 11 Jul., 12:17, Stephen Dempsey <demps…> wrote:> Hi,> Does the following suit your problem? ?Still uses scan but uses “flip” &> “prev” instead of your lambda.>> q){ flip reverse prev[x-1; til y]}[3;10]> ? ? 0> ? 0 1> 0 1 2> 1 2 3> 2 3 4> 3 4 5> 4 5 6> 5 6 7> 6 7 8> 7 8 9>> Seems to scale well in comparison also;> q)\ts do[1000000; {1_{1_x,y} scan enlist[x#0#y],y ?}[10] til 100]> 32960 11728j> q)\ts do[1000000; { flip reverse prev[x-1; til y]}[10;100]]> 11203 13344j>> Thanks,> Stephen>>>> On Wed, Jul 11, 2012 at 10:23 AM, kuentang <kuent…> wrote:>> > Hi everyone,>> > is there a better way to create moving windows in a vectoriell way ?>> > My version use scan which could be a bottle neck in my application:>> > {1_{1_x,y} scan enlist[x#0#y],y ?}[3] til 10>> > Thx for any suggestions or comments,> > Kim>> > –> >
Submitted via Google Groups</kuent…></demps…>
Hi Stephen,your version is much better than mine because you scan over threenumbers whereas i scan over the whole vector.Very cool,KimOn 11 Jul., 12:17, Stephen Dempsey <demps…> wrote:> Hi,> Does the following suit your problem? ?Still uses scan but uses “flip” &> “prev” instead of your lambda.>> q){ flip reverse prev[x-1; til y]}[3;10]> ? ? 0> ? 0 1> 0 1 2> 1 2 3> 2 3 4> 3 4 5> 4 5 6> 5 6 7> 6 7 8> 7 8 9>> Seems to scale well in comparison also;> q)\ts do[1000000; {1_{1_x,y} scan enlist[x#0#y],y ?}[10] til 100]> 32960 11728j> q)\ts do[1000000; { flip reverse prev[x-1; til y]}[10;100]]> 11203 13344j>> Thanks,> Stephen>>>> On Wed, Jul 11, 2012 at 10:23 AM, kuentang <kuent…> wrote:>> > Hi everyone,>> > is there a better way to create moving windows in a vectoriell way ?>> > My version use scan which could be a bottle neck in my application:>> > {1_{1_x,y} scan enlist[x#0#y],y ?}[3] til 10>> > Thx for any suggestions or comments,> > Kim>> > –> >
Submitted via Google Groups</kuent…></demps…>
nice article. Learning