แก้ coding style ภาค 3

This commit is contained in:
Pitchaya Boonsarngsuk
2018-03-22 16:17:48 +00:00
parent 0cdd927444
commit f3a6656c8f
4 changed files with 75 additions and 76 deletions

View File

@@ -1,5 +1,5 @@
import {takeSampleFrom} from "./helpers";
import {placeNearToNearestNeighbour} from "./interpCommon";
import {takeSampleFrom} from './helpers';
import {placeNearToNearestNeighbour} from './interpCommon';
/**
* Perform interpolation where the "parent" node is found by brute-force.
@@ -18,19 +18,19 @@ import {placeNearToNearestNeighbour} from "./interpCommon";
* @param {number} endingIts - for phase 3, how many iterations to refine the
* placement of each interpolated point
*/
export default function(sampleSet, remainderSet, distanceFn, endingIts) {
export default function (sampleSet, remainderSet, distanceFn, endingIts) {
let
sampleSubset = takeSampleFrom(sampleSet, Math.sqrt(sampleSet.length)).sample,
sampleSubsetDistanceCache = [];
// For each datapoint "node" to be interpolated
for (let i = remainderSet.length-1; i>=0; i--) {
for (let i = remainderSet.length - 1; i >= 0; i--) {
let
node = remainderSet[i],
nearestSample, minDist, sample, dist, index;
// For each datapoint "sample" in the sample set
for (let j = sampleSet.length-1; j>=0; j--) {
for (let j = sampleSet.length - 1; j >= 0; j--) {
sample = sampleSet[j];
dist = distanceFn(node, sample);
if (nearestSample === undefined || dist < minDist) {