Pivot cache number of pivots to a variable
This commit is contained in:
@@ -25,6 +25,7 @@ import {placeNearToNearestNeighbour} from "./interpCommon";
|
||||
export default function(sampleSet, remainderSet, numPivots, distanceFn, endingIts) {
|
||||
// Pivot based parent finding
|
||||
let numBuckets = Math.floor(Math.sqrt(sampleSet.length));
|
||||
let numNonPivots = sampleSet.length - numPivots;
|
||||
let sets = takeSampleFrom(sampleSet, numPivots);
|
||||
let pivots = sets.sample;
|
||||
let nonPivotSamples = sets.remainder;
|
||||
@@ -49,7 +50,7 @@ export default function(sampleSet, remainderSet, numPivots, distanceFn, endingIt
|
||||
let pivot = pivots[j];
|
||||
let maxDist = -1;
|
||||
|
||||
for (let i = 0; i < nonPivotSamples.length; i++) {
|
||||
for (let i = 0; i < numNonPivots; i++) {
|
||||
let sample = nonPivotSamples[i];
|
||||
distCache[i][j] = distanceFn(pivot, sample);
|
||||
if (distCache[i][j] > maxDist)
|
||||
@@ -62,7 +63,7 @@ export default function(sampleSet, remainderSet, numPivots, distanceFn, endingIt
|
||||
// Put samples (pivot not included) into buckets
|
||||
for (let j = 0; j < numPivots; j++) {
|
||||
let bucketWidth = bucketWidths[j];
|
||||
for (let i = 0; i < nonPivotSamples.length; i++) {
|
||||
for (let i = 0; i < numNonPivots; i++) {
|
||||
let sample = nonPivotSamples[i];
|
||||
let bucketNumber = Math.floor(distCache[i][j] / bucketWidth);
|
||||
if (bucketNumber >= numBuckets) {
|
||||
|
||||
Reference in New Issue
Block a user