@danielsimonjr/mathts-parallel 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -7
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export { Transfer } from '@danielsimonjr/mathts-workerpool';
|
|
|
24
24
|
* - Special / distribution functions (`erfc`, `besselJ`, `normalCDF`)
|
|
25
25
|
* - Additional ops exposed via the typed functions layer
|
|
26
26
|
*/
|
|
27
|
-
type OpName = 'add' | 'subtract' | 'multiply' | 'divide' | 'pow' | 'scale' | 'abs' | 'negate' | 'sqrt' | 'square' | 'exp' | 'log' | 'sin' | 'cos' | 'tan' | 'sign' | 'tensordot' | 'sum' | 'mean' | 'min' | 'max' | 'minMax' | 'variance' | 'std' | 'norm' | 'histogram' | 'dot' | 'prod' | 'distance' | 'parallelStatProd' | 'matmul' | 'outer' | 'matvec' | 'transpose' | 'matrixPower' | 'characteristicPolynomial' | 'parallelFFT' | 'parallelConv' | 'spectrogram' | 'fft2d' | 'distanceMatrix' | 'erfc' | 'besselJ' | 'normalCDF' | 'chiSquareTest' | 'kolmogorovSmirnovTest' | 'mannWhitneyTest' | 'shapiroWilkTest' | 'integrateChunk' | 'sampleChunk';
|
|
27
|
+
type OpName = 'add' | 'subtract' | 'multiply' | 'divide' | 'pow' | 'scale' | 'abs' | 'negate' | 'sqrt' | 'square' | 'bitAnd' | 'bitOr' | 'bitXor' | 'bitNot' | 'leftShift' | 'rightArithShift' | 'rightLogShift' | 'exp' | 'log' | 'sin' | 'cos' | 'tan' | 'sign' | 'tensordot' | 'sum' | 'mean' | 'min' | 'max' | 'minMax' | 'variance' | 'std' | 'norm' | 'histogram' | 'dot' | 'prod' | 'distance' | 'parallelStatProd' | 'matmul' | 'outer' | 'matvec' | 'transpose' | 'matrixPower' | 'characteristicPolynomial' | 'parallelFFT' | 'parallelConv' | 'spectrogram' | 'fft2d' | 'distanceMatrix' | 'erfc' | 'besselJ' | 'normalCDF' | 'chiSquareTest' | 'kolmogorovSmirnovTest' | 'mannWhitneyTest' | 'shapiroWilkTest' | 'integrateChunk' | 'sampleChunk';
|
|
28
28
|
/**
|
|
29
29
|
* Per-op threshold override. The value is the minimum element count required
|
|
30
30
|
* before parallelizing the named operation. Special string aliases:
|
package/dist/index.js
CHANGED
|
@@ -401,6 +401,20 @@ var DEFAULT_THRESHOLD_BY_OP = {
|
|
|
401
401
|
// no shouldParallelize call consults it. Expensive (ms-scale) integrands are the
|
|
402
402
|
// one case where the fan-out pays off.
|
|
403
403
|
integrateChunk: "never",
|
|
404
|
+
// Added 2026-07-05 (WS-2 addendum): the bitwise family gated via a NAMELESS
|
|
405
|
+
// shouldParallelize(len) -> the untested global 50k. Benchmarked
|
|
406
|
+
// (tools/benchmarks/ws2-bitwise-ops.mjs, medians of 9 interleaved reps):
|
|
407
|
+
// bitAnd 0.07-0.15x, bitNot 0.06-0.09x, leftShift 0.04-0.07x at every size up
|
|
408
|
+
// to 4M elements - Int32Array element-wise is maximally memory-bound; the
|
|
409
|
+
// worker path loses 7-25x. All seven -> 'never'; the methods now pass their
|
|
410
|
+
// op name so these entries actually govern.
|
|
411
|
+
bitAnd: "never",
|
|
412
|
+
bitOr: "never",
|
|
413
|
+
bitXor: "never",
|
|
414
|
+
bitNot: "never",
|
|
415
|
+
leftShift: "never",
|
|
416
|
+
rightArithShift: "never",
|
|
417
|
+
rightLogShift: "never",
|
|
404
418
|
// signal: overhead dominates or break-even never reached
|
|
405
419
|
parallelFFT: "never",
|
|
406
420
|
parallelConv: "never",
|
|
@@ -1281,7 +1295,7 @@ var ComputePool = class {
|
|
|
1281
1295
|
if (a.length !== b.length) {
|
|
1282
1296
|
throw new Error(`Array lengths must match: ${a.length} vs ${b.length}`);
|
|
1283
1297
|
}
|
|
1284
|
-
if (this.shouldParallelize(a.length)) {
|
|
1298
|
+
if (this.shouldParallelize(a.length, "bitAnd")) {
|
|
1285
1299
|
return toParallelResult(await this.workerPool.bitwiseBinary(a, b, "bitAnd"));
|
|
1286
1300
|
}
|
|
1287
1301
|
const start = performance.now();
|
|
@@ -1300,7 +1314,7 @@ var ComputePool = class {
|
|
|
1300
1314
|
if (a.length !== b.length) {
|
|
1301
1315
|
throw new Error(`Array lengths must match: ${a.length} vs ${b.length}`);
|
|
1302
1316
|
}
|
|
1303
|
-
if (this.shouldParallelize(a.length)) {
|
|
1317
|
+
if (this.shouldParallelize(a.length, "bitOr")) {
|
|
1304
1318
|
return toParallelResult(await this.workerPool.bitwiseBinary(a, b, "bitOr"));
|
|
1305
1319
|
}
|
|
1306
1320
|
const start = performance.now();
|
|
@@ -1319,7 +1333,7 @@ var ComputePool = class {
|
|
|
1319
1333
|
if (a.length !== b.length) {
|
|
1320
1334
|
throw new Error(`Array lengths must match: ${a.length} vs ${b.length}`);
|
|
1321
1335
|
}
|
|
1322
|
-
if (this.shouldParallelize(a.length)) {
|
|
1336
|
+
if (this.shouldParallelize(a.length, "bitXor")) {
|
|
1323
1337
|
return toParallelResult(await this.workerPool.bitwiseBinary(a, b, "bitXor"));
|
|
1324
1338
|
}
|
|
1325
1339
|
const start = performance.now();
|
|
@@ -1335,7 +1349,7 @@ var ComputePool = class {
|
|
|
1335
1349
|
* Unary bitwise NOT on an `Int32Array`.
|
|
1336
1350
|
*/
|
|
1337
1351
|
async bitNot(a) {
|
|
1338
|
-
if (this.shouldParallelize(a.length)) {
|
|
1352
|
+
if (this.shouldParallelize(a.length, "bitNot")) {
|
|
1339
1353
|
return toParallelResult(await this.workerPool.bitwiseNot(a));
|
|
1340
1354
|
}
|
|
1341
1355
|
const start = performance.now();
|
|
@@ -1355,7 +1369,7 @@ var ComputePool = class {
|
|
|
1355
1369
|
if (typeof b !== "number" && a.length !== b.length) {
|
|
1356
1370
|
throw new Error(`Array lengths must match: ${a.length} vs ${b.length}`);
|
|
1357
1371
|
}
|
|
1358
|
-
if (this.shouldParallelize(a.length)) {
|
|
1372
|
+
if (this.shouldParallelize(a.length, "leftShift")) {
|
|
1359
1373
|
const result2 = typeof b === "number" ? await this.workerPool.bitwiseScalar(a, b, "leftShift") : await this.workerPool.bitwiseBinary(a, b, "leftShift");
|
|
1360
1374
|
return toParallelResult(result2);
|
|
1361
1375
|
}
|
|
@@ -1375,7 +1389,7 @@ var ComputePool = class {
|
|
|
1375
1389
|
if (typeof b !== "number" && a.length !== b.length) {
|
|
1376
1390
|
throw new Error(`Array lengths must match: ${a.length} vs ${b.length}`);
|
|
1377
1391
|
}
|
|
1378
|
-
if (this.shouldParallelize(a.length)) {
|
|
1392
|
+
if (this.shouldParallelize(a.length, "rightArithShift")) {
|
|
1379
1393
|
const result2 = typeof b === "number" ? await this.workerPool.bitwiseScalar(a, b, "rightArithShift") : await this.workerPool.bitwiseBinary(a, b, "rightArithShift");
|
|
1380
1394
|
return toParallelResult(result2);
|
|
1381
1395
|
}
|
|
@@ -1397,7 +1411,7 @@ var ComputePool = class {
|
|
|
1397
1411
|
if (typeof b !== "number" && a.length !== b.length) {
|
|
1398
1412
|
throw new Error(`Array lengths must match: ${a.length} vs ${b.length}`);
|
|
1399
1413
|
}
|
|
1400
|
-
if (this.shouldParallelize(a.length)) {
|
|
1414
|
+
if (this.shouldParallelize(a.length, "rightLogShift")) {
|
|
1401
1415
|
const result2 = typeof b === "number" ? await this.workerPool.bitwiseScalar(a, b, "rightLogShift") : await this.workerPool.bitwiseBinary(a, b, "rightLogShift");
|
|
1402
1416
|
return toParallelResult(result2);
|
|
1403
1417
|
}
|