MCPcopy Create free account
hub / github.com/microsoft/SandDance / smoothing

Function smoothing

docs/app/js/sanddance-app.js:119210–119228  ·  view source on GitHub ↗
(v, thresh)

Source from the content-addressed store, hash-verified

119208// swap points between "adjacent" stacks
119209// Wilkinson defines adjacent as within step/4 units
119210function smoothing(v, thresh) {
119211 const n = v.length;
119212 let a = 0, b = 1, c, d; // get left stack
119213 while(v[a] === v[b])++b;
119214 while(b < n){
119215 // get right stack
119216 c = b + 1;
119217 while(v[b] === v[c])++c; // are stacks adjacent?
119218 // if so, compare sizes and swap as needed
119219 if (v[b] - v[b - 1] < thresh) {
119220 d = b + (a + c - b - b >> 1);
119221 while(d < b)v[d++] = v[b];
119222 while(d > b)v[d--] = v[a];
119223 } // update left stack indices
119224 a = b;
119225 b = c;
119226 }
119227 return v;
119228}
119229function lcg(seed) {
119230 // Random numbers using a Linear Congruential Generator with seed value
119231 // Uses glibc values from https://en.wikipedia.org/wiki/Linear_congruential_generator

Callers 1

dotbinFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected