Initial work of ESM transformation
This commit is contained in:
parent
2472c9cff2
commit
b8205a63aa
303 changed files with 1959 additions and 2450 deletions
|
@ -1,5 +1,3 @@
|
|||
"use strict";
|
||||
|
||||
function struct(leader, ...items) {
|
||||
return "" + leader + "(" + items.join(";") + ")";
|
||||
}
|
||||
|
@ -9,21 +7,18 @@ function tuple(...items) {
|
|||
function list(items) {
|
||||
return "{" + items.join(";") + "}";
|
||||
}
|
||||
|
||||
function n(x) {
|
||||
return String(Math.round(x * 0x10000));
|
||||
}
|
||||
|
||||
function typedPoint(z) {
|
||||
return tuple(z.type, n(z.x), n(z.y));
|
||||
}
|
||||
function gizmo(g) {
|
||||
return tuple(n(g.xx), n(g.xy), n(g.yx), n(g.yy), n(g.x), n(g.y));
|
||||
}
|
||||
|
||||
exports.struct = struct;
|
||||
exports.tuple = tuple;
|
||||
exports.list = list;
|
||||
exports.n = n;
|
||||
exports.typedPoint = typedPoint;
|
||||
exports.gizmo = gizmo;
|
||||
export { struct };
|
||||
export { tuple };
|
||||
export { list };
|
||||
export { n };
|
||||
export { typedPoint };
|
||||
export { gizmo };
|
|
@ -1,14 +1,10 @@
|
|||
"use strict";
|
||||
|
||||
exports.maskBit = function maskBit(x, y) {
|
||||
return x & (1 << y);
|
||||
};
|
||||
|
||||
exports.maskBits = function maskBits(x, y) {
|
||||
return x & y;
|
||||
};
|
||||
|
||||
const pcNibbleLookup = [0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4];
|
||||
exports.popCountByte = function (x) {
|
||||
export function maskBit(x, y) {
|
||||
return x & (1 << y);
|
||||
}
|
||||
export function maskBits(x, y) {
|
||||
return x & y;
|
||||
}
|
||||
export const popCountByte = function (x) {
|
||||
return pcNibbleLookup[x & 0x0f] + pcNibbleLookup[(x >>> 4) & 0x0f];
|
||||
};
|
|
@ -1,9 +1,6 @@
|
|||
"use strict";
|
||||
|
||||
exports.monotonicInterpolate = function (xs, ys) {
|
||||
export const monotonicInterpolate = function (xs, ys) {
|
||||
let i,
|
||||
length = xs.length;
|
||||
|
||||
// Deal with length issues
|
||||
if (length != ys.length) {
|
||||
throw "Need an equal count of xs and ys.";
|
||||
|
@ -21,7 +18,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
// Rearrange xs and ys so that xs is sorted
|
||||
let indexes = [];
|
||||
for (i = 0; i < length; i++) {
|
||||
|
@ -40,7 +36,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
xs.push(+oldXs[indexes[i]]);
|
||||
ys.push(+oldYs[indexes[i]]);
|
||||
}
|
||||
|
||||
// Get consecutive differences and slopes
|
||||
let dys = [],
|
||||
dxs = [],
|
||||
|
@ -52,7 +47,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
dys.push(dy);
|
||||
ms.push(dy / dx);
|
||||
}
|
||||
|
||||
// Get degree-1 coefficients
|
||||
let c1s = [ms[0]];
|
||||
for (i = 0; i < dxs.length - 1; i++) {
|
||||
|
@ -68,7 +62,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
}
|
||||
}
|
||||
c1s.push(ms[ms.length - 1]);
|
||||
|
||||
// Get degree-2 and degree-3 coefficients
|
||||
let c2s = [],
|
||||
c3s = [];
|
||||
|
@ -80,7 +73,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
c2s.push((m - c1 - common) * invDx);
|
||||
c3s.push(common * invDx * invDx);
|
||||
}
|
||||
|
||||
// Return interpolant function
|
||||
return function (x) {
|
||||
// The rightmost point in the dataset should give an exact result
|
||||
|
@ -88,7 +80,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
if (x == xs[i]) {
|
||||
return ys[i];
|
||||
}
|
||||
|
||||
// Search for the interval x is in, returning the corresponding y if x is one of the original xs
|
||||
let low = 0,
|
||||
mid,
|
||||
|
@ -105,7 +96,6 @@ exports.monotonicInterpolate = function (xs, ys) {
|
|||
}
|
||||
}
|
||||
i = Math.max(0, high);
|
||||
|
||||
// Interpolate
|
||||
let diff = x - xs[i],
|
||||
diffSq = diff * diff;
|
Loading…
Add table
Add a link
Reference in a new issue