@danielsimonjr/mathts-functions 0.16.1 → 0.17.0

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.
@@ -0,0 +1,60 @@
1
+ /**
2
+ * WebGPU fused element-wise chain.
3
+ *
4
+ * Why a *chain* and not a single op: a lone element-wise op on the GPU is pure
5
+ * transfer tax — upload n floats, do one flop each, read n floats back. The
6
+ * same memory-bound economics retired element-wise ops from the WASM backend.
7
+ * A **fused chain** uploads once, runs every op in the chain on-device by
8
+ * ping-ponging two storage buffers, and reads back once, so the transfer cost
9
+ * is amortized across the whole chain.
10
+ *
11
+ * Contract (mirrors the WASM `elementwiseChainDispatch`): this is a
12
+ * **never-throw** best-effort fast path. It returns `null` — never rejects —
13
+ * whenever the GPU is unavailable, not opted in, the input is too small, or the
14
+ * chain contains an op with no GPU kernel. The caller then falls through to the
15
+ * existing WASM/JS tiers.
16
+ *
17
+ * Precision: the GPU path computes in **f32** (WGSL has no f64). This is why it
18
+ * is gated behind the explicit `enableGpu()` opt-in.
19
+ */
20
+ import { type GPUContextOptions } from '@danielsimonjr/mathts-gpu';
21
+ /**
22
+ * WGSL expressions for each supported op, as a function of `x`.
23
+ *
24
+ * Deliberately a SUBSET of the WASM op set. `erfc` is absent: WGSL has no
25
+ * `erfc` builtin, and hand-rolling a polynomial approximation would silently
26
+ * change the accuracy contract. A chain containing an unsupported op returns
27
+ * `null` and falls back, rather than quietly computing something else.
28
+ */
29
+ declare const WGSL_OP_BODY: {
30
+ readonly abs: "return abs(x);";
31
+ readonly sin: "return sin(x);";
32
+ readonly cos: "return cos(x);";
33
+ readonly tan: "return tan(x);";
34
+ readonly exp: "return exp(x);";
35
+ readonly log: "return log(x);";
36
+ readonly atan: "return atan(x);";
37
+ readonly sinh: "return sinh(x);";
38
+ readonly tanh: "return tanh(x);";
39
+ readonly atanh: "return atanh(x);";
40
+ readonly log2: "return log2(x);";
41
+ readonly log10: "return log(x) * 0.4342944819032518;";
42
+ readonly sec: "return 1.0 / cos(x);";
43
+ readonly csc: "return 1.0 / sin(x);";
44
+ readonly cot: "return 1.0 / tan(x);";
45
+ };
46
+ /** Ops that have a GPU kernel. A chain outside this set falls back. */
47
+ export type GpuElementwiseOp = keyof typeof WGSL_OP_BODY;
48
+ export declare const GPU_ELEMENTWISE_OPS: GpuElementwiseOp[];
49
+ /** Whether every op in the chain has a GPU kernel. */
50
+ export declare function isGpuChainSupported(ops: readonly string[]): ops is readonly GpuElementwiseOp[];
51
+ /**
52
+ * Run a fused element-wise chain on the GPU.
53
+ *
54
+ * @param ops - the chain, applied left to right (`['sin','exp']` = `exp(sin(x))`)
55
+ * @param xs - input samples
56
+ * @returns the f32 results, or `null` to signal "fall back to another tier"
57
+ */
58
+ export declare function elementwiseChainGpuDispatch(ops: readonly string[], xs: Float64Array | Float32Array, options?: GPUContextOptions): Promise<Float32Array | null>;
59
+ export {};
60
+ //# sourceMappingURL=elementwise-gpu.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"elementwise-gpu.d.ts","sourceRoot":"","sources":["../../src/gpu/elementwise-gpu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;GAOG;AACH,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;CAkCR,CAAC;AAEX,uEAAuE;AACvE,MAAM,MAAM,gBAAgB,GAAG,MAAM,OAAO,YAAY,CAAC;AAEzD,eAAO,MAAM,mBAAmB,EAAgC,gBAAgB,EAAE,CAAC;AAEnF,sDAAsD;AACtD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,SAAS,MAAM,EAAE,GAAG,GAAG,IAAI,SAAS,gBAAgB,EAAE,CAE9F;AA8CD;;;;;;GAMG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,SAAS,MAAM,EAAE,EACtB,EAAE,EAAE,YAAY,GAAG,YAAY,EAC/B,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAuH9B"}
package/dist/index.js CHANGED
@@ -22,6 +22,8 @@ __export(typed_exports, {
22
22
  CENTRALITY_WORKER_THRESHOLD: () => CENTRALITY_WORKER_THRESHOLD,
23
23
  DIST_WORKER_THRESHOLD: () => DIST_WORKER_THRESHOLD,
24
24
  GAUSS_WORKER_THRESHOLD: () => GAUSS_WORKER_THRESHOLD,
25
+ GPU_ELEMENTWISE_OPS: () => GPU_ELEMENTWISE_OPS,
26
+ GPU_MIN_ELEMENTS: () => GPU_MIN_ELEMENTS2,
25
27
  WASM_INTERP_THRESHOLD: () => WASM_INTERP_THRESHOLD,
26
28
  abs: () => abs,
27
29
  acos: () => acos,
@@ -132,6 +134,7 @@ __export(typed_exports, {
132
134
  delaunayTriangulation: () => delaunayTriangulation,
133
135
  differences: () => differences,
134
136
  digamma: () => digamma,
137
+ disableGpu: () => disableGpu,
135
138
  discreteUniformDist: () => discreteUniformDist,
136
139
  discriminant: () => discriminant,
137
140
  distance2D: () => distance2D,
@@ -149,12 +152,14 @@ __export(typed_exports, {
149
152
  dwt: () => dwt,
150
153
  eigenvectorCentrality: () => eigenvectorCentrality,
151
154
  element: () => element,
155
+ elementwiseChainGpuDispatch: () => elementwiseChainGpuDispatch,
152
156
  eliminate: () => eliminate,
153
157
  ellipticE: () => ellipticE,
154
158
  ellipticEIncomplete: () => ellipticEIncomplete,
155
159
  ellipticF: () => ellipticF,
156
160
  ellipticK: () => ellipticK,
157
161
  ellipticPi: () => ellipticPi,
162
+ enableGpu: () => enableGpu,
158
163
  entropy: () => entropy,
159
164
  equal: () => equal,
160
165
  equalScalar: () => equalScalar,
@@ -189,6 +194,7 @@ __export(typed_exports, {
189
194
  fullSimplify: () => fullSimplify,
190
195
  functionExpand: () => functionExpand,
191
196
  fuseUnaryChain: () => fuseUnaryChain,
197
+ fuseUnaryChainAsync: () => fuseUnaryChainAsync,
192
198
  gammaDist: () => gammaDist,
193
199
  gammaPDF: () => gammaPDF,
194
200
  gammainc: () => gammainc,
@@ -230,6 +236,8 @@ __export(typed_exports, {
230
236
  invFourier: () => invFourier,
231
237
  invGaussDist: () => invGaussDist,
232
238
  isConnected: () => isConnected,
239
+ isGpuChainSupported: () => isGpuChainSupported,
240
+ isGpuEnabled: () => isGpuEnabled2,
233
241
  jacobiSymbol: () => jacobiSymbol,
234
242
  jordanForm: () => jordanForm,
235
243
  jsDivergence: () => jsDivergence,
@@ -7330,6 +7338,169 @@ var typedSpecial = {
7330
7338
  ellipticPi
7331
7339
  };
7332
7340
 
7341
+ // src/gpu/elementwise-gpu.ts
7342
+ import {
7343
+ getGpuDevice,
7344
+ isGpuEnabled,
7345
+ GPU_MIN_ELEMENTS
7346
+ } from "@danielsimonjr/mathts-gpu";
7347
+ var WGSL_OP_BODY = {
7348
+ abs: "return abs(x);",
7349
+ sin: "return sin(x);",
7350
+ cos: "return cos(x);",
7351
+ tan: "return tan(x);",
7352
+ exp: "return exp(x);",
7353
+ log: "return log(x);",
7354
+ atan: "return atan(x);",
7355
+ sinh: "return sinh(x);",
7356
+ tanh: "return tanh(x);",
7357
+ atanh: "return atanh(x);",
7358
+ log2: "return log2(x);",
7359
+ // WGSL has no log10 builtin; log(x) * 1/ln(10).
7360
+ log10: "return log(x) * 0.4342944819032518;",
7361
+ // NOTE — `expm1` and `log1p` are DELIBERATELY ABSENT, like `erfc`.
7362
+ //
7363
+ // WGSL has no builtin for either. The naive identities (`exp(x)-1`,
7364
+ // `log(1+x)`) are catastrophically wrong near zero in f32: `1.0 + 1e-8`
7365
+ // rounds to exactly 1.0f, so `log(1+x)` returns 0 where the true value is
7366
+ // 1e-8 — a 100% relative error.
7367
+ //
7368
+ // The standard Kahan-compensated forms were implemented and MEASURED on real
7369
+ // hardware (NVIDIA Pascal). They still scored 38% (expm1) and 62% (log1p) max
7370
+ // relative error over x in [1e-9, 1e-3], because the compensation relies on
7371
+ // `log()` being accurate for arguments near 1.0, and the GPU's fast-math
7372
+ // `log()` is not.
7373
+ //
7374
+ // An f32 fast path is allowed to be less precise. It is not allowed to be
7375
+ // WRONG. Chains containing these fall back to the exact WASM/JS tiers.
7376
+ sec: "return 1.0 / cos(x);",
7377
+ csc: "return 1.0 / sin(x);",
7378
+ cot: "return 1.0 / tan(x);"
7379
+ };
7380
+ var GPU_ELEMENTWISE_OPS = Object.keys(WGSL_OP_BODY);
7381
+ function isGpuChainSupported(ops) {
7382
+ return ops.every((op) => op in WGSL_OP_BODY);
7383
+ }
7384
+ var WORKGROUP_SIZE = 256;
7385
+ function wgslFor(op) {
7386
+ return `
7387
+ @group(0) @binding(0) var<storage, read> inp: array<f32>;
7388
+ @group(0) @binding(1) var<storage, read_write> outp: array<f32>;
7389
+
7390
+ fn apply(x: f32) -> f32 {
7391
+ ${WGSL_OP_BODY[op]}
7392
+ }
7393
+
7394
+ @compute @workgroup_size(${WORKGROUP_SIZE})
7395
+ fn main(@builtin(global_invocation_id) gid: vec3<u32>) {
7396
+ let i = gid.x;
7397
+ if (i >= arrayLength(&inp)) { return; }
7398
+ outp[i] = apply(inp[i]);
7399
+ }
7400
+ `;
7401
+ }
7402
+ var pipelineCache = /* @__PURE__ */ new WeakMap();
7403
+ function getPipeline(device, op) {
7404
+ let byOp = pipelineCache.get(device);
7405
+ if (!byOp) {
7406
+ byOp = /* @__PURE__ */ new Map();
7407
+ pipelineCache.set(device, byOp);
7408
+ }
7409
+ const cached = byOp.get(op);
7410
+ if (cached) return cached;
7411
+ const pipeline = device.createComputePipeline({
7412
+ label: `elementwise:${op}`,
7413
+ layout: "auto",
7414
+ compute: {
7415
+ module: device.createShaderModule({ code: wgslFor(op), label: `elementwise:${op}` }),
7416
+ entryPoint: "main"
7417
+ }
7418
+ });
7419
+ byOp.set(op, pipeline);
7420
+ return pipeline;
7421
+ }
7422
+ async function elementwiseChainGpuDispatch(ops, xs, options) {
7423
+ const n = xs.length;
7424
+ if (!isGpuEnabled()) return null;
7425
+ if (ops.length === 0) return null;
7426
+ if (n < GPU_MIN_ELEMENTS) return null;
7427
+ if (!isGpuChainSupported(ops)) return null;
7428
+ const bytes = n * 4;
7429
+ const workgroups = Math.ceil(n / WORKGROUP_SIZE);
7430
+ let bufA;
7431
+ let bufB;
7432
+ let staging;
7433
+ let scopePopped = false;
7434
+ let device;
7435
+ try {
7436
+ const d = await getGpuDevice(options);
7437
+ if (!d) return null;
7438
+ device = d;
7439
+ const limits = device.limits;
7440
+ if (workgroups > limits.maxComputeWorkgroupsPerDimension) return null;
7441
+ if (bytes > limits.maxStorageBufferBindingSize) return null;
7442
+ if (bytes > limits.maxBufferSize) return null;
7443
+ const input = xs instanceof Float32Array ? xs : Float32Array.from(xs);
7444
+ device.pushErrorScope("validation");
7445
+ bufA = device.createBuffer({
7446
+ size: bytes,
7447
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,
7448
+ label: "chain-a"
7449
+ });
7450
+ bufB = device.createBuffer({
7451
+ size: bytes,
7452
+ usage: GPUBufferUsage.STORAGE | GPUBufferUsage.COPY_DST | GPUBufferUsage.COPY_SRC,
7453
+ label: "chain-b"
7454
+ });
7455
+ staging = device.createBuffer({
7456
+ size: bytes,
7457
+ usage: GPUBufferUsage.MAP_READ | GPUBufferUsage.COPY_DST,
7458
+ label: "chain-staging"
7459
+ });
7460
+ device.queue.writeBuffer(bufA, 0, input);
7461
+ const encoder = device.createCommandEncoder({ label: "elementwise-chain" });
7462
+ let src = bufA;
7463
+ let dst2 = bufB;
7464
+ for (const op of ops) {
7465
+ const pipeline = getPipeline(device, op);
7466
+ const bindGroup = device.createBindGroup({
7467
+ layout: pipeline.getBindGroupLayout(0),
7468
+ entries: [
7469
+ { binding: 0, resource: { buffer: src } },
7470
+ { binding: 1, resource: { buffer: dst2 } }
7471
+ ]
7472
+ });
7473
+ const pass = encoder.beginComputePass({ label: `chain:${op}` });
7474
+ pass.setPipeline(pipeline);
7475
+ pass.setBindGroup(0, bindGroup);
7476
+ pass.dispatchWorkgroups(workgroups);
7477
+ pass.end();
7478
+ [src, dst2] = [dst2, src];
7479
+ }
7480
+ encoder.copyBufferToBuffer(src, 0, staging, 0, bytes);
7481
+ device.queue.submit([encoder.finish()]);
7482
+ const validationError = await device.popErrorScope();
7483
+ scopePopped = true;
7484
+ if (validationError) return null;
7485
+ await staging.mapAsync(GPUMapMode.READ);
7486
+ const out = new Float32Array(staging.getMappedRange().slice(0));
7487
+ staging.unmap();
7488
+ return out;
7489
+ } catch {
7490
+ return null;
7491
+ } finally {
7492
+ if (device && !scopePopped) {
7493
+ try {
7494
+ await device.popErrorScope();
7495
+ } catch {
7496
+ }
7497
+ }
7498
+ bufA?.destroy();
7499
+ bufB?.destroy();
7500
+ staging?.destroy();
7501
+ }
7502
+ }
7503
+
7333
7504
  // src/typed/fused.ts
7334
7505
  var SCALAR = {
7335
7506
  abs: Math.abs,
@@ -7354,6 +7525,9 @@ var SCALAR = {
7354
7525
  function fuseUnaryChain(ops, xs) {
7355
7526
  const wasm = elementwiseChainDispatch(ops, xs);
7356
7527
  if (wasm) return wasm;
7528
+ return jsChain(ops, xs);
7529
+ }
7530
+ function jsChain(ops, xs) {
7357
7531
  const out = Float64Array.from(xs);
7358
7532
  for (const op of ops) {
7359
7533
  const f = SCALAR[op];
@@ -7361,6 +7535,11 @@ function fuseUnaryChain(ops, xs) {
7361
7535
  }
7362
7536
  return out;
7363
7537
  }
7538
+ async function fuseUnaryChainAsync(ops, xs) {
7539
+ const gpu = await elementwiseChainGpuDispatch(ops, xs);
7540
+ if (gpu) return gpu;
7541
+ return fuseUnaryChain(ops, xs);
7542
+ }
7364
7543
 
7365
7544
  // src/typed/distributions.ts
7366
7545
  import { mathTyped as mathTyped11 } from "@danielsimonjr/mathts-core";
@@ -15699,8 +15878,10 @@ var matrixSqrtm = mathTyped13("matrixSqrtm", {
15699
15878
  // src/typed/gpu.ts
15700
15879
  import { gpuMatrixBackend } from "@danielsimonjr/mathts-matrix";
15701
15880
  async function ensureGpu() {
15702
- if (gpuMatrixBackend.isAvailable()) {
15881
+ if (!gpuMatrixBackend.isAvailable()) return;
15882
+ try {
15703
15883
  await gpuMatrixBackend.initialize();
15884
+ } catch {
15704
15885
  }
15705
15886
  }
15706
15887
  async function gpuMatmul(a, b) {
@@ -15720,6 +15901,9 @@ async function gpuScale(a, scalar) {
15720
15901
  return gpuMatrixBackend.scaleAsync(a, scalar);
15721
15902
  }
15722
15903
 
15904
+ // src/typed/index.ts
15905
+ import { enableGpu, disableGpu, isGpuEnabled as isGpuEnabled2, GPU_MIN_ELEMENTS as GPU_MIN_ELEMENTS2 } from "@danielsimonjr/mathts-gpu";
15906
+
15723
15907
  // src/typed/relational.ts
15724
15908
  import naturalSort from "javascript-natural-sort";
15725
15909
  import { mathTyped as mathTyped14, Complex as Complex6, BigNumber as BigNumber6, Fraction as Fraction2 } from "@danielsimonjr/mathts-core";
@@ -41443,6 +41627,72 @@ function reviver(_key, value) {
41443
41627
  // src/typed/cas.ts
41444
41628
  import { computePool as computePool12 } from "@danielsimonjr/mathts-parallel";
41445
41629
  import { Complex as Complex10 } from "@danielsimonjr/mathts-core";
41630
+ function _evalNumeric(exprStr) {
41631
+ let pos = 0;
41632
+ const s = exprStr.replace(/\s+/g, "");
41633
+ const parseExpr = () => {
41634
+ let val = parseTerm();
41635
+ while (pos < s.length) {
41636
+ if (s[pos] === "+") {
41637
+ pos++;
41638
+ val += parseTerm();
41639
+ } else if (s[pos] === "-") {
41640
+ pos++;
41641
+ val -= parseTerm();
41642
+ } else break;
41643
+ }
41644
+ return val;
41645
+ };
41646
+ const parseTerm = () => {
41647
+ let val = parseFactor();
41648
+ while (pos < s.length) {
41649
+ if (s[pos] === "*") {
41650
+ pos++;
41651
+ val *= parseFactor();
41652
+ } else if (s[pos] === "/") {
41653
+ pos++;
41654
+ val /= parseFactor();
41655
+ } else break;
41656
+ }
41657
+ return val;
41658
+ };
41659
+ const parseFactor = () => {
41660
+ let val = parseBase();
41661
+ if (pos < s.length && s[pos] === "^") {
41662
+ pos++;
41663
+ val = Math.pow(val, parseFactor());
41664
+ }
41665
+ return val;
41666
+ };
41667
+ const parseBase = () => {
41668
+ if (s[pos] === "+") {
41669
+ pos++;
41670
+ return parseBase();
41671
+ }
41672
+ if (s[pos] === "-") {
41673
+ pos++;
41674
+ return -parseBase();
41675
+ }
41676
+ if (s[pos] === "(") {
41677
+ pos++;
41678
+ const val = parseExpr();
41679
+ if (s[pos] === ")") pos++;
41680
+ return val;
41681
+ }
41682
+ const start = pos;
41683
+ while (pos < s.length && /[\d.]/.test(s[pos])) pos++;
41684
+ if (start === pos) throw new Error();
41685
+ return parseFloat(s.substring(start, pos));
41686
+ };
41687
+ try {
41688
+ const val = parseExpr();
41689
+ if (pos === s.length && typeof val === "number" && isFinite(val)) {
41690
+ return String(val);
41691
+ }
41692
+ } catch {
41693
+ }
41694
+ return void 0;
41695
+ }
41446
41696
  function evalAt(expr, varName, value) {
41447
41697
  return evaluate(expr, { [varName]: value });
41448
41698
  }
@@ -42700,12 +42950,8 @@ function _casSimplifyOne(expr) {
42700
42950
  r = r.replace(/\b0\s*\*\s*[^+-]*/g, "0");
42701
42951
  const numericPattern = /^[\d\s+\-*/().^]+$/;
42702
42952
  if (numericPattern.test(r)) {
42703
- try {
42704
- const jsExpr = r.replace(/\^/g, "**");
42705
- const val = new Function('"use strict"; return (' + jsExpr + ")")();
42706
- if (typeof val === "number" && isFinite(val)) return String(val);
42707
- } catch {
42708
- }
42953
+ const val = _evalNumeric(r);
42954
+ if (val !== void 0) return val;
42709
42955
  }
42710
42956
  r = _combineLikeTerms(r);
42711
42957
  return r || "0";
@@ -42879,6 +43125,72 @@ function casSimplify(input) {
42879
43125
  return Promise.resolve(strs.map(_casSimplifyOne));
42880
43126
  }
42881
43127
  return computePool12.map(strs, (exprStr) => {
43128
+ function _evalNumeric2(exprStr2) {
43129
+ let pos = 0;
43130
+ const s = exprStr2.replace(/\s+/g, "");
43131
+ const parseExpr = () => {
43132
+ let val = parseTerm();
43133
+ while (pos < s.length) {
43134
+ if (s[pos] === "+") {
43135
+ pos++;
43136
+ val += parseTerm();
43137
+ } else if (s[pos] === "-") {
43138
+ pos++;
43139
+ val -= parseTerm();
43140
+ } else break;
43141
+ }
43142
+ return val;
43143
+ };
43144
+ const parseTerm = () => {
43145
+ let val = parseFactor();
43146
+ while (pos < s.length) {
43147
+ if (s[pos] === "*") {
43148
+ pos++;
43149
+ val *= parseFactor();
43150
+ } else if (s[pos] === "/") {
43151
+ pos++;
43152
+ val /= parseFactor();
43153
+ } else break;
43154
+ }
43155
+ return val;
43156
+ };
43157
+ const parseFactor = () => {
43158
+ let val = parseBase();
43159
+ if (pos < s.length && s[pos] === "^") {
43160
+ pos++;
43161
+ val = Math.pow(val, parseFactor());
43162
+ }
43163
+ return val;
43164
+ };
43165
+ const parseBase = () => {
43166
+ if (s[pos] === "+") {
43167
+ pos++;
43168
+ return parseBase();
43169
+ }
43170
+ if (s[pos] === "-") {
43171
+ pos++;
43172
+ return -parseBase();
43173
+ }
43174
+ if (s[pos] === "(") {
43175
+ pos++;
43176
+ const val = parseExpr();
43177
+ if (s[pos] === ")") pos++;
43178
+ return val;
43179
+ }
43180
+ const start = pos;
43181
+ while (pos < s.length && /[\d.]/.test(s[pos])) pos++;
43182
+ if (start === pos) throw new Error();
43183
+ return parseFloat(s.substring(start, pos));
43184
+ };
43185
+ try {
43186
+ const val = parseExpr();
43187
+ if (pos === s.length && typeof val === "number" && isFinite(val)) {
43188
+ return String(val);
43189
+ }
43190
+ } catch {
43191
+ }
43192
+ return void 0;
43193
+ }
42882
43194
  function _combineLikeTermsW(expr) {
42883
43195
  const normalised = expr.replace(/\s*-\s*/g, " + -");
42884
43196
  const rawTerms = normalised.split(/\s*\+\s*/);
@@ -42932,12 +43244,8 @@ function casSimplify(input) {
42932
43244
  r = r.replace(/\s*\+\s*0\b/g, "");
42933
43245
  r = r.replace(/\b0\s*\*\s*[^+-]*/g, "0");
42934
43246
  if (/^[\d\s+\-*/().^]+$/.test(r)) {
42935
- try {
42936
- const jsExpr = r.replace(/\^/g, "**");
42937
- const val = new Function('"use strict"; return (' + jsExpr + ")")();
42938
- if (typeof val === "number" && isFinite(val)) return String(val);
42939
- } catch {
42940
- }
43247
+ const val = _evalNumeric2(r);
43248
+ if (val !== void 0) return val;
42941
43249
  }
42942
43250
  return _combineLikeTermsW(r) || "0";
42943
43251
  }).then((r) => r.result);
@@ -44585,6 +44893,8 @@ export {
44585
44893
  DIST_WORKER_THRESHOLD,
44586
44894
  EARTH_RADIUS_KM,
44587
44895
  GAUSS_WORKER_THRESHOLD,
44896
+ GPU_ELEMENTWISE_OPS,
44897
+ GPU_MIN_ELEMENTS2 as GPU_MIN_ELEMENTS,
44588
44898
  WASM_INTERP_THRESHOLD,
44589
44899
  abs,
44590
44900
  acf,
@@ -44772,6 +45082,7 @@ export {
44772
45082
  differences,
44773
45083
  digamma,
44774
45084
  directionalDerivative,
45085
+ disableGpu,
44775
45086
  discreteUniformDist,
44776
45087
  discriminant,
44777
45088
  distance,
@@ -44800,12 +45111,14 @@ export {
44800
45111
  electronMass,
44801
45112
  element,
44802
45113
  elementaryCharge,
45114
+ elementwiseChainGpuDispatch,
44803
45115
  eliminate,
44804
45116
  ellipticE,
44805
45117
  ellipticEIncomplete,
44806
45118
  ellipticF,
44807
45119
  ellipticK,
44808
45120
  ellipticPi,
45121
+ enableGpu,
44809
45122
  entropy,
44810
45123
  equal,
44811
45124
  equalScalar,
@@ -44926,6 +45239,7 @@ export {
44926
45239
  fullSimplify,
44927
45240
  functionExpand,
44928
45241
  fuseUnaryChain,
45242
+ fuseUnaryChainAsync,
44929
45243
  gamma,
44930
45244
  gammaCDF,
44931
45245
  gammaDist,
@@ -45004,6 +45318,8 @@ export {
45004
45318
  isBounded,
45005
45319
  isConnected,
45006
45320
  isFinite2 as isFinite,
45321
+ isGpuChainSupported,
45322
+ isGpuEnabled2 as isGpuEnabled,
45007
45323
  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19
  */
20
20
  export declare function fuseUnaryChain(ops: WasmElementwiseOp[], xs: Float64Array): Float64Array;
21
+ /**
22
+ * Async sibling of {@link fuseUnaryChain} that may run the chain on the **GPU**.
23
+ *
24
+ * This exists as a separate, `async` entry point rather than changing
25
+ * `fuseUnaryChain`, because a GPU dispatch is inherently asynchronous and
26
+ * `fuseUnaryChain`'s synchronous signature is public API.
27
+ *
28
+ * Tiers, in order: **GPU (f32)** → WASM (f64) → JS (f64).
29
+ *
30
+ * The GPU tier engages only when the caller has opted in via `enableGpu()`, a
31
+ * device is available, the array clears `GPU_MIN_ELEMENTS`, and every op in the
32
+ * chain has a GPU kernel. Otherwise this behaves exactly like `fuseUnaryChain`.
33
+ *
34
+ * **Precision:** when the GPU tier engages the result is a `Float32Array`
35
+ * (~7 significant digits); otherwise it is an exact-f64 `Float64Array`. The
36
+ * return type tells you which path ran — that is the precision contract, and it
37
+ * is why the GPU tier is opt-in rather than automatic.
38
+ */
39
+ export declare function fuseUnaryChainAsync(ops: WasmElementwiseOp[], xs: Float64Array): Promise<Float64Array | Float32Array>;
21
40
  //# sourceMappingURL=fused.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fused.d.ts","sourceRoot":"","sources":["../../src/typed/fused.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,oCAAoC,CAAC;AAyB5C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAAE,YAAY,GAAG,YAAY,CASvF"}
1
+ {"version":3,"file":"fused.d.ts","sourceRoot":"","sources":["../../src/typed/fused.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,oCAAoC,CAAC;AA0B5C;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,EAAE,EAAE,EAAE,EAAE,YAAY,GAAG,YAAY,CAIvF;AAYD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,iBAAiB,EAAE,EACxB,EAAE,EAAE,YAAY,GACf,OAAO,CAAC,YAAY,GAAG,YAAY,CAAC,CAItC"}
@@ -1 +1 @@
1
- {"version":3,"file":"gpu.d.ts","sourceRoot":"","sources":["../../src/typed/gpu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAShE;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGpF;AAED;;;;;;;;;GASG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGjF;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGvE;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGnF"}
1
+ {"version":3,"file":"gpu.d.ts","sourceRoot":"","sources":["../../src/typed/gpu.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAqBhE;;;;;;;;;;GAUG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGpF;AAED;;;;;;;;;GASG;AACH,wBAAsB,MAAM,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGjF;AAED;;;;;;;;GAQG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAGvE;AAED;;;;;;;;;GASG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAGnF"}
@@ -46,6 +46,8 @@ export * from './hypothesis.js';
46
46
  export * from './matrix-ops.js';
47
47
  export { cond } from './matrix-ops.js';
48
48
  export * from './gpu.js';
49
+ export { enableGpu, disableGpu, isGpuEnabled, GPU_MIN_ELEMENTS } from '@danielsimonjr/mathts-gpu';
50
+ export { elementwiseChainGpuDispatch, isGpuChainSupported, GPU_ELEMENTWISE_OPS, type GpuElementwiseOp, } from '../gpu/elementwise-gpu.js';
49
51
  export * from './relational.js';
50
52
  export { typedRelational } from './relational.js';
51
53
  export * from './string.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/typed/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,cAAc,mBAAmB,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAGtD,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5C,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK5C,cA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AWhC,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,cAAc,UAAU,CAAC;AAIzB,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClG,OAAO,EACL,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACnB,KAAK,gBAAgB,GACtB,MAAM,2BAA2B,CAAC;AAInC,cAAc,iBAAiB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGlD,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI1C,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGpD,cAAc,WAAW,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAsCtC;;;;;;GAMG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B1B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-functions",
3
- "version": "0.16.1",
3
+ "version": "0.17.0",
4
4
  "description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",
@@ -35,7 +35,8 @@
35
35
  "dependencies": {
36
36
  "@danielsimonjr/mathts-core": "^0.6.0",
37
37
  "@danielsimonjr/mathts-expression": "^0.6.0",
38
- "@danielsimonjr/mathts-matrix": "^0.2.2",
38
+ "@danielsimonjr/mathts-gpu": "^0.1.0",
39
+ "@danielsimonjr/mathts-matrix": "^0.3.0",
39
40
  "@danielsimonjr/mathts-parallel": "^0.3.3",
40
41
  "bignumber.js": "^9.1.2",
41
42
  "complex.js": "^2.2.5",
@@ -49,6 +50,7 @@
49
50
  },
50
51
  "devDependencies": {
51
52
  "@types/node": "^25.5.2",
53
+ "@webgpu/types": "^0.1.67",
52
54
  "tsup": "^8.0.0",
53
55
  "typescript": "^5.3.0",
54
56
  "vitest": "^4.1.5"