parent
2462bc6711
commit
10ea5549e5
@ -1,8 +0,0 @@
|
||||
all:
|
||||
g++ mmw.cpp --std=c++1z -shared -fPIC -Ofast -march=native -g0 -s -o mmw.so
|
||||
avx512:
|
||||
g++ mmw.cpp --std=c++1z -shared -fPIC -Ofast -mavx512f -g0 -s -o mmw.so
|
||||
debug:
|
||||
g++ mmw.cpp --std=c++1z -shared -fPIC -O0 -march=native -g3 -o mmw.so
|
||||
clean:
|
||||
rm mmw.so -rf
|
@ -1,68 +0,0 @@
|
||||
import`csv
|
||||
|
||||
md:{y-x*_y%x}
|
||||
|
||||
maxs:{[L]{max(x, y)}\L}
|
||||
mins:{[L]{min(x, y)}\L}
|
||||
sums:{[L]{(x + y)}\L}
|
||||
|
||||
avgsimpl:{[L;i] curr:L[i]%(i+1); $[i<(#L)-1;curr, avgsimpl[L;i+1];curr]}
|
||||
avgs:{[L] avgsimpl[sums[L];0]}
|
||||
|
||||
/ maxswimp:{[L;w;i] curr:max(L@(((i-w)+!w)|0)); $[i<#L;curr, maxswimp[L; w; i + 1];curr]}
|
||||
/ maxsw:{[w;L]maxswimp[L; w; 1]}
|
||||
|
||||
/ minswimp:{[L;w;i] curr:min(L@(((i-w)+!w)|0)); $[i<#L;curr, maxswimp[L; w; i + 1];curr]}
|
||||
/ minsw:{[w;L]minswimp[L;w;1]}
|
||||
|
||||
/ avgswimp:{[L;w;s;i] s:(s+L[i])-L[i-w];curr:s%((i+1)&w);$[i<(#L)-1; curr, avgswimp[L; w; s; i+1]; curr]}
|
||||
/ avgsw:{[w;L] avgswimp[L;w;0;0]}
|
||||
|
||||
/ sumswimp:{[L;w;s;i] s:(s+L[i])-L[i-w];$[i<(#L)-1; s, sumswimp[L; w; s; i+1]; s]}
|
||||
/ sumsw:{[w;L] sumswimp[L;w;0;0]}
|
||||
|
||||
|
||||
groupby0:{[L]
|
||||
{[x;y]
|
||||
x:$[(@x)=`i;(,(L[0]))!,(,0);x];
|
||||
k:(,(L[y]));gvk:x[k][0];
|
||||
found:$[(gvk[0]+gvk[1])>0;1;L[y] in !x];
|
||||
cg:(,L[y])!$[found;,gvk[0],y;,(,y)];
|
||||
(x,cg)}/!(#L)}
|
||||
|
||||
groupBy:{[x]groupBySingle:{[a;x]
|
||||
findAll:{[c;xx]
|
||||
f:{[i;c]$[(c[0])[i]~c[1];i+1;0]};
|
||||
@[!#xx;!#xx;f;(#xx)#,(xx;c)]};
|
||||
z:findAll[a;x];
|
||||
b:(findAll[0;z]_(!(1+#z)))-1;(a;b)};
|
||||
x:+x;y:?x;
|
||||
@[y;!#y;groupBySingle;(#y)#,x]}
|
||||
|
||||
groupby:{[L]
|
||||
L:^+L;
|
||||
dimy:(#(L[0]))-1;
|
||||
((({[L;dim;x;y]
|
||||
x:$[x~0;(,(dim#(L[0])),0);x];
|
||||
curr:dim#(L[y]);
|
||||
$[(dim#*x)~curr;x;((,curr,y),x)]}[L;dimy])/!(#L));(+L)[dimy]) }
|
||||
|
||||
lststr:{[L](+({[x;y] ($x,$y)}/L))[0]}
|
||||
delist:{[L] $[(@L)in(`LL`LC`LG`L);delist[(,/L)];L]}
|
||||
cntlist:{[L;i] $[(@L)in(`LL`LC`LG`L);cntlist[(,/L);i+1];i+1]}
|
||||
flatRO:{[x]x[0],/:x[1]}
|
||||
flatLO:{[x]x[0],\:x[1]}
|
||||
flatBOTH:{[x],/(x[0],/:\:x[1])}
|
||||
|
||||
|
||||
sumswkrl:{[L;w;x;y] ((x-L[y-w])+L[y])}
|
||||
sumsw:{[w;L] $[(#L)=0;L;(sumswkrl[L;w])\@[!#L;0;L[file 0]]]}
|
||||
avgswkrl:{[L;w;x;y] (x-(L[y-w]-L[y])%w)}
|
||||
avgsw:{[w;L] $[(#L)=0;L;(avgswkrl[L;w])\@[!#L;0;L[0]]]}
|
||||
|
||||
/ minsw:{[w;L] ({[L;w;x] min(L[$[x>w;(!w) + ((x-w)+1);!(x+1)]])}[L;w])'!#L}
|
||||
import`mmw
|
||||
minsw:{[w;L] ret:L; mmw[ret;((`g ($@ret)[0]), (#ret), w, 65536)];ret}
|
||||
maxsw:{[w;L] ret:L; mmw[ret;((`g ($@ret)[0]), (#ret), w, 65537)];ret}
|
||||
minswip:{[w;L] mmw[L;((`g ($@L)[0]), (#L), w, 65536)];}
|
||||
maxswip:{[w;L] mmw[L;((`g ($@L)[0]), (#L), w, 65537)];}
|
@ -1 +0,0 @@
|
||||
{[I;L;R;i] t:&(I[i]);d:(#t);$[d=0;!0;+(Aa[t];Ab[t];d#(Bb[i]))]}[(Aa {x>(y*10)}/: Ba); Aa; Ba]'!#Aa
|
@ -1,46 +0,0 @@
|
||||
#include "./server/libaquery.h"
|
||||
#include <cstdio>
|
||||
#include <threads.h>
|
||||
extern "C" int dllmain(Context *cxt)
|
||||
{
|
||||
auto stocks = new TableInfo<int, int>("stocks", 2);
|
||||
cxt->tables.insert(std::make_pair("stocks", stocks));
|
||||
stocks->colrefs[0].ty = types::AINT;
|
||||
stocks->colrefs[1].ty = types::AINT;
|
||||
auto &stocks_0 = *(ColRef<int> *)(&stocks->colrefs[0]);
|
||||
auto &stocks_1 = *(ColRef<int> *)(&stocks->colrefs[1]);
|
||||
stocks_0.emplace_back(1);
|
||||
stocks_1.emplace_back(15);
|
||||
stocks_0.emplace_back(2);
|
||||
stocks_1.emplace_back(19);
|
||||
stocks_0.emplace_back(3);
|
||||
stocks_1.emplace_back(16);
|
||||
stocks_0.emplace_back(4);
|
||||
stocks_1.emplace_back(17);
|
||||
stocks_0.emplace_back(5);
|
||||
stocks_1.emplace_back(15);
|
||||
stocks_0.emplace_back(6);
|
||||
stocks_1.emplace_back(13);
|
||||
stocks_0.emplace_back(7);
|
||||
stocks_1.emplace_back(5);
|
||||
stocks_0.emplace_back(8);
|
||||
stocks_1.emplace_back(8);
|
||||
stocks_0.emplace_back(9);
|
||||
stocks_1.emplace_back(7);
|
||||
stocks_0.emplace_back(10);
|
||||
stocks_1.emplace_back(13);
|
||||
stocks_0.emplace_back(11);
|
||||
stocks_1.emplace_back(11);
|
||||
stocks_0.emplace_back(12);
|
||||
stocks_1.emplace_back(14);
|
||||
stocks_0.emplace_back(13);
|
||||
stocks_1.emplace_back(10);
|
||||
stocks_0.emplace_back(14);
|
||||
stocks_1.emplace_back(5);
|
||||
stocks_0.emplace_back(15);
|
||||
stocks_1.emplace_back(2);
|
||||
stocks_0.emplace_back(16);
|
||||
stocks_1.emplace_back(5);
|
||||
printf("%d\n", max(stocks_0 - min(stocks_1)));
|
||||
return 0;
|
||||
}
|
Loading…
Reference in new issue