diff --git a/.gitignore b/.gitignore index d0aaa7f..0bece75 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ logs results npm-debug.log +package-lock.json node_modules/* *.DS_Store *.asm diff --git a/index.js b/index.js index 11f3051..3646f9f 100644 --- a/index.js +++ b/index.js @@ -60,7 +60,7 @@ function boxIntersect(red, blue, visit, full) { //Special case: 1d complete sweep.init(n) retval = sweep.sweepComplete( - d, visit, + d, visit, 0, n, redList, redIds, 0, n, redList, redIds) } else { @@ -76,7 +76,7 @@ function boxIntersect(red, blue, visit, full) { if(d === 1) { //Special case: 1d bipartite retval = sweep.sweepBipartite( - d, visit, + d, visit, 0, n, redList, redIds, 0, m, blueList, blueIds) } else { @@ -120,7 +120,6 @@ function intersectBipartiteArray(x, y) { //User-friendly wrapper, handle full input and no-visitor cases function boxIntersectWrapper(arg0, arg1, arg2) { - var result switch(arguments.length) { case 1: return intersectFullArray(arg0) diff --git a/lib/brute.js b/lib/brute.js index 4a0bc8f..7803c45 100644 --- a/lib/brute.js +++ b/lib/brute.js @@ -1,144 +1,139 @@ 'use strict' -var DIMENSION = 'd' -var AXIS = 'ax' -var VISIT = 'vv' -var FLIP = 'fp' - -var ELEM_SIZE = 'es' - -var RED_START = 'rs' -var RED_END = 're' -var RED_BOXES = 'rb' -var RED_INDEX = 'ri' -var RED_PTR = 'rp' - -var BLUE_START = 'bs' -var BLUE_END = 'be' -var BLUE_BOXES = 'bb' -var BLUE_INDEX = 'bi' -var BLUE_PTR = 'bp' - -var RETVAL = 'rv' - -var INNER_LABEL = 'Q' - -var ARGS = [ - DIMENSION, - AXIS, - VISIT, - RED_START, - RED_END, - RED_BOXES, - RED_INDEX, - BLUE_START, - BLUE_END, - BLUE_BOXES, - BLUE_INDEX -] - -function generateBruteForce(redMajor, flip, full) { - var funcName = 'bruteForce' + - (redMajor ? 'Red' : 'Blue') + - (flip ? 'Flip' : '') + - (full ? 'Full' : '') - - var code = ['function ', funcName, '(', ARGS.join(), '){', - 'var ', ELEM_SIZE, '=2*', DIMENSION, ';'] - - var redLoop = - 'for(var i=' + RED_START + ',' + RED_PTR + '=' + ELEM_SIZE + '*' + RED_START + ';' + - 'i<' + RED_END +';' + - '++i,' + RED_PTR + '+=' + ELEM_SIZE + '){' + - 'var x0=' + RED_BOXES + '[' + AXIS + '+' + RED_PTR + '],' + - 'x1=' + RED_BOXES + '[' + AXIS + '+' + RED_PTR + '+' + DIMENSION + '],' + - 'xi=' + RED_INDEX + '[i];' - - var blueLoop = - 'for(var j=' + BLUE_START + ',' + BLUE_PTR + '=' + ELEM_SIZE + '*' + BLUE_START + ';' + - 'j<' + BLUE_END + ';' + - '++j,' + BLUE_PTR + '+=' + ELEM_SIZE + '){' + - 'var y0=' + BLUE_BOXES + '[' + AXIS + '+' + BLUE_PTR + '],' + - (full ? 'y1=' + BLUE_BOXES + '[' + AXIS + '+' + BLUE_PTR + '+' + DIMENSION + '],' : '') + - 'yi=' + BLUE_INDEX + '[j];' - - if(redMajor) { - code.push(redLoop, INNER_LABEL, ':', blueLoop) - } else { - code.push(blueLoop, INNER_LABEL, ':', redLoop) - } - - if(full) { - code.push('if(y1 be - bs) { + return bruteForceRedFull(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) + } + else { + return bruteForceBlueFull(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) + } } + return bruteForceFull } -function bruteForcePlanner(full) { - var funcName = 'bruteForce' + (full ? 'Full' : 'Partial') - var prefix = [] - var fargs = ARGS.slice() - if(!full) { - fargs.splice(3, 0, FLIP) +function partial() { + function bruteForceRedFlip(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) { + var es = 2 * d + for (var i = rs, rp = es * rs; i < re; ++i, rp += es) { + var x0 = rb[ax + rp], x1 = rb[ax + rp + d], xi = ri[i] + Q: for (var j = bs, bp = es * bs; j < be; ++j, bp += es) { + var y0 = bb[ax + bp], yi = bi[j] + if (y0 <= x0 || x1 < y0) continue + for (var k = ax + 1; k < d; ++k) { + var r0 = rb[k + rp], r1 = rb[k + d + rp], b0 = bb[k + bp], b1 = bb[k + d + bp] + if (r1 < b0 || b1 < r0) continue Q + } + var rv = vv(yi, xi) + if (rv !== void 0) return rv + } + } } - - var code = ['function ' + funcName + '(' + fargs.join() + '){'] - - function invoke(redMajor, flip) { - var res = generateBruteForce(redMajor, flip, full) - prefix.push(res.code) - code.push('return ' + res.name + '(' + ARGS.join() + ');') + function bruteForceRed(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) { + var es = 2 * d + for (var i = rs, rp = es * rs; i < re; ++i, rp += es) { + var x0 = rb[ax + rp], x1 = rb[ax + rp + d], xi = ri[i] + Q: for (var j = bs, bp = es * bs; j < be; ++j, bp += es) { + var y0 = bb[ax + bp], yi = bi[j] + if (y0 < x0 || x1 < y0) continue + for (var k = ax + 1; k < d; ++k) { + var r0 = rb[k + rp], r1 = rb[k + d + rp], b0 = bb[k + bp], b1 = bb[k + d + bp] + if (r1 < b0 || b1 < r0) continue Q + } + var rv = vv(xi, yi) + if (rv !== void 0) return rv + } + } } - - code.push('if(' + RED_END + '-' + RED_START + '>' + - BLUE_END + '-' + BLUE_START + '){') - - if(full) { - invoke(true, false) - code.push('}else{') - invoke(false, false) - } else { - code.push('if(' + FLIP + '){') - invoke(true, true) - code.push('}else{') - invoke(true, false) - code.push('}}else{if(' + FLIP + '){') - invoke(false, true) - code.push('}else{') - invoke(false, false) - code.push('}') + function bruteForceBlueFlip(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) { + var es = 2 * d + for (var j = bs, bp = es * bs; j < be; ++j, bp += es) { + var y0 = bb[ax + bp], yi = bi[j] + Q: for (var i = rs, rp = es * rs; i < re; ++i, rp += es) { + var x0 = rb[ax + rp], x1 = rb[ax + rp + d], xi = ri[i] + if (y0 <= x0 || x1 < y0) continue + for (var k = ax + 1; k < d; ++k) { + var r0 = rb[k + rp], r1 = rb[k + d + rp], b0 = bb[k + bp], b1 = bb[k + d + bp] + if (r1 < b0 || b1 < r0) continue Q + } + var rv = vv(yi, xi) + if (rv !== void 0) return rv + } + } } - code.push('}}return ' + funcName) - - var codeStr = prefix.join('') + code.join('') - var proc = new Function(codeStr) - return proc() + function bruteForceBlue(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) { + var es = 2 * d + for (var j = bs, bp = es * bs; j < be; ++j, bp += es) { + var y0 = bb[ax + bp], yi = bi[j] + Q: for (var i = rs, rp = es * rs; i < re; ++i, rp += es) { + var x0 = rb[ax + rp], x1 = rb[ax + rp + d], xi = ri[i] + if (y0 < x0 || x1 < y0) continue + for (var k = ax + 1; k < d; ++k) { + var r0 = rb[k + rp], r1 = rb[k + d + rp], b0 = bb[k + bp], b1 = bb[k + d + bp] + if (r1 < b0 || b1 < r0) continue Q + } + var rv = vv(xi, yi) + if (rv !== void 0) return rv + } + } + } + function bruteForcePartial(d, ax, vv, fp, rs, re, rb, ri, bs, be, bb, bi) { + if (re - rs > be - bs) { + if (fp) { + return bruteForceRedFlip(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) + } + else { + return bruteForceRed(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) + } + } + else { + if (fp) { + return bruteForceBlueFlip(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) + } + else { + return bruteForceBlue(d, ax, vv, rs, re, rb, ri, bs, be, bb, bi) + } + } + } + return bruteForcePartial } +function bruteForcePlanner(isFull) { + return isFull ? full() : partial() + +} exports.partial = bruteForcePlanner(false) exports.full = bruteForcePlanner(true) \ No newline at end of file diff --git a/lib/intersect.js b/lib/intersect.js index 38dfe71..1419cb4 100644 --- a/lib/intersect.js +++ b/lib/intersect.js @@ -14,32 +14,26 @@ var genPartition = require('./partition') //Twiddle parameters var BRUTE_FORCE_CUTOFF = 128 //Cut off for brute force search var SCAN_CUTOFF = (1<<22) //Cut off for two way scan -var SCAN_COMPLETE_CUTOFF = (1<<22) +var SCAN_COMPLETE_CUTOFF = (1<<22) //Partition functions var partitionInteriorContainsInterval = genPartition( - '!(lo>=p0)&&!(p1>=hi)', - ['p0', 'p1']) + '!(lo>=p0)&&!(p1>=hi)') var partitionStartEqual = genPartition( - 'lo===p0', - ['p0']) + 'lo===p0') var partitionStartLessThan = genPartition( - 'lo mid point // var blue0 = findMedian( - d, axis, + d, axis, blueStart, blueEnd, blue, blueIndex) var mid = blue[elemSize * blue0 + axis] var blue1 = partitionStartEqual( diff --git a/lib/median.js b/lib/median.js index b065f06..500ef22 100644 --- a/lib/median.js +++ b/lib/median.js @@ -4,7 +4,7 @@ module.exports = findMedian var genPartition = require('./partition') -var partitionStartLessThan = genPartition('lostart && boxes[ptr+axis] > x; + for(var j=i, ptr=elemSize*(i-1); + j>start && boxes[ptr+axis] > x; --j, ptr-=elemSize) { //Swap var aPtr = ptr @@ -45,14 +45,14 @@ function findMedian(d, axis, start, end, boxes, ids) { var elemSize = 2*d var pivot = mid var value = boxes[elemSize*mid+axis] - + while(lo < hi) { if(hi - lo < PARTITION_THRESHOLD) { insertionSort(d, axis, lo, hi, boxes, ids) value = boxes[elemSize*mid+axis] break } - + //Select pivot using median-of-3 var count = hi - lo var pivot0 = (Math.random()*count+lo)|0 @@ -99,7 +99,7 @@ function findMedian(d, axis, start, end, boxes, ids) { //Partition using pivot pivot = partitionStartLessThan( - d, axis, + d, axis, lo, hi-1, boxes, ids, value) @@ -118,7 +118,7 @@ function findMedian(d, axis, start, end, boxes, ids) { //Swap pivot to last pivot if(mid < pivot) { hi = pivot-1 - while(lo < hi && + while(lo < hi && boxes[elemSize*(hi-1)+axis] === value) { hi -= 1 } @@ -136,7 +136,7 @@ function findMedian(d, axis, start, end, boxes, ids) { //Make sure pivot is at start return partitionStartLessThan( - d, axis, + d, axis, start, mid, boxes, ids, boxes[elemSize*mid+axis]) } \ No newline at end of file diff --git a/lib/partition.js b/lib/partition.js index 1cc0640..ad53490 100644 --- a/lib/partition.js +++ b/lib/partition.js @@ -2,19 +2,111 @@ module.exports = genPartition -var code = 'for(var j=2*a,k=j*c,l=k,m=c,n=b,o=a+b,p=c;d>p;++p,k+=j){var _;if($)if(m===p)m+=1,l+=j;else{for(var s=0;j>s;++s){var t=e[k+s];e[k+s]=e[l],e[l++]=t}var u=f[p];f[p]=f[m],f[m++]=u}}return m' +var P2F = { + 'lo===p0': lo_equal_p0, + 'lo=p0)&&!(p1>=hi)': lo_lessThan_p0_and_p1_lessThan_hi +} -function genPartition(predicate, args) { - var fargs ='abcdef'.split('').concat(args) - var reads = [] - if(predicate.indexOf('lo') >= 0) { - reads.push('lo=e[k+n]') +function genPartition(predicate) { + return P2F[predicate] +} + +// lo===p0 +function lo_equal_p0(a, b, c, d, e, f, p0) { + for (var j = 2 * a, k = j * c, l = k, m = c, n = b, o = a + b, p = c; d > p; ++p, k += j) { + var lo = e[k + n]; + if (lo === p0) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } var u = f[p]; f[p] = f[m], f[m++] = u + } + } + return m +} + +// lo p; ++p, k += j) { + var lo = e[k + n]; + if (lo < p0) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } var u = f[p]; f[p] = f[m], f[m++] = u + } + } + return m +} + +// lo<=p0 +function lo_lessOrEqual_p0(a, b, c, d, e, f, p0) { + for (var j = 2 * a, k = j * c, l = k, m = c, n = b, o = a + b, p = c; d > p; ++p, k += j) { + var hi = e[k + o]; + if (hi <= p0) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } + var u = f[p]; f[p] = f[m], f[m++] = u + } + } return m +} + +// hi<=p0 +function hi_lessOrEqual_p0(a, b, c, d, e, f, p0) { + for (var j = 2 * a, k = j * c, l = k, m = c, n = b, o = a + b, p = c; d > p; ++p, k += j) { + var hi = e[k + o]; + if (hi <= p0) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } + var u = f[p]; f[p] = f[m], f[m++] = u + } } - if(predicate.indexOf('hi') >= 0) { - reads.push('hi=e[k+o]') + return m +} + +// lo<=p0&&p0<=hi +function lo_lassOrEqual_p0_and_p0_lessOrEqual_hi(a, b, c, d, e, f, p0) { + for (var j = 2 * a, k = j * c, l = k, m = c, n = b, o = a + b, p = c; d > p; ++p, k += j) { + var lo = e[k + n], hi = e[k + o]; + if (lo <= p0 && p0 <= hi) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } + var u = f[p]; f[p] = f[m], f[m++] = u + } + } + return m +} + +// lo p; ++p, k += j) { + var lo = e[k + n], hi = e[k + o]; + if (lo < p0 && p0 <= hi) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } + var u = f[p]; f[p] = f[m], f[m++] = u + } + } + return m +} + +// !(lo>=p0)&&!(p1>=hi) +function lo_lessThan_p0_and_p1_lessThan_hi(a, b, c, d, e, f, p0, p1) { + for (var j = 2 * a, k = j * c, l = k, m = c, n = b, o = a + b, p = c; d > p; ++p, k += j) { + var lo = e[k + n], hi = e[k + o]; + if (!(lo >= p0) && !(p1 >= hi)) if (m === p) m += 1, l += j; else { + for (var s = 0; j > s; ++s) { + var t = e[k + s]; e[k + s] = e[l], e[l++] = t + } + var u = f[p]; f[p] = f[m], f[m++] = u + } } - fargs.push( - code.replace('_', reads.join()) - .replace('$', predicate)) - return Function.apply(void 0, fargs) -} \ No newline at end of file + return m +} diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 1adfb17..0000000 --- a/package-lock.json +++ /dev/null @@ -1,143 +0,0 @@ -{ - "name": "box-intersect", - "version": "1.0.2", - "lockfileVersion": 1, - "requires": true, - "dependencies": { - "array-shuffle": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/array-shuffle/-/array-shuffle-1.0.0.tgz", - "integrity": "sha1-wTP6c1hwmb13rRfLdi3X7kTZQVs=", - "dev": true - }, - "bit-twiddle": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/bit-twiddle/-/bit-twiddle-1.0.2.tgz", - "integrity": "sha1-DGwfq+KyPRcXPZpht7cJPrnhdp4=" - }, - "dup": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/dup/-/dup-1.0.0.tgz", - "integrity": "sha1-UfxaxoX4GWRp3wuQXpNLIK9bQCk=" - }, - "guarded-array": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/guarded-array/-/guarded-array-1.0.0.tgz", - "integrity": "sha1-+bHcTp+Z3d4w1XjjgLodofBqHts=", - "dev": true - }, - "iota-array": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/iota-array/-/iota-array-1.0.0.tgz", - "integrity": "sha1-ge9X/l0FgUzVjCSDYyqZwwoOgIc=", - "dev": true - }, - "tape": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/tape/-/tape-3.5.0.tgz", - "integrity": "sha1-rrsGE4gQStDLQHvoQnggSdZGJPg=", - "dev": true, - "requires": { - "deep-equal": "0.2.2", - "defined": "0.0.0", - "glob": "3.2.11", - "inherits": "2.0.1", - "object-inspect": "0.4.0", - "resumer": "0.0.0", - "through": "2.3.7" - }, - "dependencies": { - "deep-equal": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-0.2.2.tgz", - "integrity": "sha1-hLdFiW80xoTpjyzg5Cq69Du6AX0=", - "dev": true - }, - "defined": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/defined/-/defined-0.0.0.tgz", - "integrity": "sha1-817qfXBekzuvE7LwOz+D2SFAOz4=", - "dev": true - }, - "glob": { - "version": "3.2.11", - "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", - "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", - "dev": true, - "requires": { - "inherits": "2.0.1", - "minimatch": "0.3.0" - }, - "dependencies": { - "minimatch": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", - "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", - "dev": true, - "requires": { - "lru-cache": "2.6.4", - "sigmund": "1.0.1" - }, - "dependencies": { - "lru-cache": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.6.4.tgz", - "integrity": "sha1-JnUZDM0bBwHsL2UqTQ09QA12wN0=", - "dev": true - }, - "sigmund": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", - "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", - "dev": true - } - } - } - } - }, - "inherits": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", - "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=", - "dev": true - }, - "object-inspect": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-0.4.0.tgz", - "integrity": "sha1-9RV8EWwUVbJDsG7pdwM5LFrYn+w=", - "dev": true - }, - "resumer": { - "version": "0.0.0", - "resolved": "https://registry.npmjs.org/resumer/-/resumer-0.0.0.tgz", - "integrity": "sha1-8ej0YeQGS6Oegq883CqMiT0HZ1k=", - "dev": true, - "requires": { - "through": "2.3.7" - } - }, - "through": { - "version": "2.3.7", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.7.tgz", - "integrity": "sha1-X8w2kP7S/fmMb8iLTSB6RiSsO4c=", - "dev": true - } - } - }, - "typedarray-pool": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/typedarray-pool/-/typedarray-pool-1.1.0.tgz", - "integrity": "sha1-0RT0hIAUifU+yrXoCIqiMET0mNk=", - "requires": { - "bit-twiddle": "1.0.2", - "dup": "1.0.0" - } - }, - "uniq": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz", - "integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8=", - "dev": true - } - } -} diff --git a/package.json b/package.json index bad4dbd..73960bc 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,21 @@ { "name": "box-intersect", - "version": "1.0.2", + "version": "1.1.0", "description": "Any dimensional box intersection", "main": "index.js", "directories": { "test": "test" }, "scripts": { + "test_bipartite": "tape test/bipartite.js", + "test_brute": "tape test/brute.js", + "test_full": "tape test/full.js", + "test_intersect-iter": "tape test/intersect-iter.js", + "test_median": "tape test/median.js", + "test_partition": "tape test/partition.js", + "test_scan": "tape test/scan.js", + "test_sweep-bipartite": "tape test/sweep-bipartite.js", + "test_sweep-complete": "tape test/sweep-complete.js", "test": "tape test/*.js" }, "repository": { diff --git a/test/brute.js b/test/brute.js index b6593e7..a464231 100644 --- a/test/brute.js +++ b/test/brute.js @@ -50,12 +50,12 @@ tape('bruteForcePartial', function(t) { } bruteForcePartial(d, axis, visit, flip, - redStart, - redEnd, - guard(red, 2*d*redStart, 2*d*redEnd), + redStart, + redEnd, + guard(red, 2*d*redStart, 2*d*redEnd), guard(redIds, redStart, redEnd), - blueStart, - blueEnd, + blueStart, + blueEnd, guard(blue, 2*d*blueStart, 2*d*blueEnd), guard(blueIds, blueStart, blueEnd)) @@ -121,6 +121,6 @@ tape('bruteForcePartial', function(t) { verify(2, 0, false, genBoxes.degenerate(2), genBoxes.degenerate(2)) //TODO: test early out - + t.end() }) \ No newline at end of file diff --git a/test/partition.js b/test/partition.js index 68e510a..085b8d8 100644 --- a/test/partition.js +++ b/test/partition.js @@ -9,12 +9,16 @@ var genPartition = require('../lib/partition') // Type signature: // // function partitionBoxes( -// d, axis, -// start, end, boxes, id, +// d, axis, +// start, end, boxes, id, // pred, a, b) // -var partition = genPartition('pred(lo,hi,a0,a1)', ['pred', 'a0', 'a1']) +var partition_eq = genPartition('lo===p0') +var partition_lt = genPartition('lo= mid') - } boxIds.sort(function(a, b) { return a-b }) @@ -73,20 +74,33 @@ tape('partitionBoxes', function(t) { } var dboxes = genBoxes.degenerate(2) + partition = partition_lt verifyPartition(2, dboxes, 0, dboxes.length, intervalStartLessThan, 0.1) for(var d=2; d<=4; ++d) { for(var i=0; i<4; ++i) { var boxes = genBoxes.random(32, d) var istart = Math.random() - + + partition = partition_in verifyPartition(d, boxes, 0, 32, intervalContainsPoint, Math.random(), Math.random()) - + + partition = partition_lt verifyPartition(d, boxes, 1, 2, intervalStartLessThan, 0.5, 0.5) + + partition = partition_eq verifyPartition(d, boxes, 0, 32, intervalContainsInterval, istart, istart+Math.random()) + + partition = partition_in verifyPartition(d, boxes, 0, 32, intervalContainsPoint, Math.random(), Math.random()) + + partition = partition_lt verifyPartition(d, boxes, 10, 30, intervalStartLessThan, Math.random(), Math.random()) + + partition = partition_le verifyPartition(d, boxes, 30, 32, intervalEndGreaterThanEqual, Math.random(), Math.random()) + + partition = partition_lt verifyPartition(d, boxes, 10, 20, intervalStartLessThan, Infinity) verifyPartition(d, boxes, 10, 20, intervalStartLessThan, -Infinity) }