Published
Edited
Mar 20, 2019
1 fork
36 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
edt1d = (grid, offset, stride, length) => {
v[0] = 0;
z[0] = -INF;
z[1] = INF;
for (let q = 0; q < length; q++) f[q] = grid[offset + q * stride];

for (let q = 1, k = 0, s = 0; q < length; q++) {
do {
const r = v[k];
s = (f[q] - f[r] + q * q - r * r) / (q - r) / 2;
} while (s <= z[k--]);

k += 2;
v[k] = q;
z[k] = s;
z[k + 1] = INF;
}

for (let q = 0, k = 0; q < length; q++) {
while (z[k + 1] < q) k++;
const r = v[k];
grid[offset + q * stride] = f[r] + (q - r) * (q - r);
}
}

Insert cell
Insert cell
transformedGrid = {
replay;
const grid = originalGrid.slice();

for (let x = 0; x < width; x++) { // transform each column
edt1d(grid, x, width, height); yield grid;
}
for (let y = 0; y < height; y++) { // transform each row
edt1d(grid, y * width, 1, width); yield grid;
}
return grid;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more