chg begin end type

This commit is contained in:
tqchen 2014-11-10 17:24:44 -08:00
parent 9855a90142
commit b426eef527
2 changed files with 7 additions and 5 deletions

View File

@ -165,15 +165,16 @@ struct WQSummary {
if (src.size <= maxsize) { if (src.size <= maxsize) {
this->CopyFrom(src); return; this->CopyFrom(src); return;
} }
const RType max_rank = src.MaxRank(); const RType begin = src.data[0].rmax;
const RType range = src.data[src.size - 1].rmin - src.data[0].rmax;
const size_t n = maxsize - 1; const size_t n = maxsize - 1;
data[0] = src.data[0]; data[0] = src.data[0];
this->size = 1; this->size = 1;
// lastidx is used to avoid duplicated records // lastidx is used to avoid duplicated records
size_t i = 0, lastidx = 0; size_t i = 1, lastidx = 0;
for (RType k = 1; k < n; ++k) { for (RType k = 1; k < n; ++k) {
RType dx2 = (2 * k * max_rank) / n; RType dx2 = 2 * ((k * range) / n + begin);
// find first i such that d < (rmax[i+1] + rmin[i+1]) / 2 // find first i such that d < (rmax[i+1] + rmin[i+1]) / 2
while (i < src.size - 1 && while (i < src.size - 1 &&
dx2 >= src.data[i + 1].rmax + src.data[i + 1].rmin) ++i; dx2 >= src.data[i + 1].rmax + src.data[i + 1].rmin) ++i;
if (i == src.size - 1) break; if (i == src.size - 1) break;

View File

@ -6,7 +6,8 @@ import subprocess
funcs = { funcs = {
'seq': 'lambda n: sorted([(x,1) for x in range(1,n+1)], key = lambda x:random.random())', 'seq': 'lambda n: sorted([(x,1) for x in range(1,n+1)], key = lambda x:random.random())',
'seqlogw': 'lambda n: sorted([(x, math.log(x)) for x in range(1,n+1)], key = lambda x:random.random())' 'seqlogw': 'lambda n: sorted([(x, math.log(x)) for x in range(1,n+1)], key = lambda x:random.random())',
'lots0': 'lambda n: sorted([(max(x - n*3/4,0), 1) for x in range(1,n+1)], key = lambda x:random.random())'
} }
if len(sys.argv) < 3: if len(sys.argv) < 3: