@danielsimonjr/mathts-parallel 0.3.4 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.js +3 -6
  2. package/package.json +58 -57
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // src/ComputePool.ts
2
+ import { pairwiseSum, norm2 } from "@danielsimonjr/mathts-core";
2
3
  import {
3
4
  MathWorkerPool,
4
5
  Transfer
@@ -614,9 +615,7 @@ var ComputePool = class {
614
615
  */
615
616
  async sum(data) {
616
617
  if (!this.shouldParallelize(data.length, "sum")) {
617
- let s = 0;
618
- for (let i = 0; i < data.length; i++) s += data[i];
619
- return this.seqResult(s);
618
+ return this.seqResult(pairwiseSum(data));
620
619
  }
621
620
  return toParallelResult(await this.workerPool.sum(data));
622
621
  }
@@ -755,9 +754,7 @@ var ComputePool = class {
755
754
  */
756
755
  async norm(data) {
757
756
  if (!this.shouldParallelize(data.length, "norm")) {
758
- let s = 0;
759
- for (let i = 0; i < data.length; i++) s += data[i] * data[i];
760
- return this.seqResult(Math.sqrt(s));
757
+ return this.seqResult(norm2(data));
761
758
  }
762
759
  return toParallelResult(await this.workerPool.norm(data));
763
760
  }
package/package.json CHANGED
@@ -1,57 +1,58 @@
1
- {
2
- "name": "@danielsimonjr/mathts-parallel",
3
- "version": "0.3.4",
4
- "description": "WebWorker parallelization for MathTS computations",
5
- "author": "Daniel Simon Jr.",
6
- "license": "MIT",
7
- "type": "module",
8
- "main": "./dist/index.js",
9
- "module": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
11
- "exports": {
12
- ".": {
13
- "import": "./dist/index.js",
14
- "types": "./dist/index.d.ts"
15
- }
16
- },
17
- "files": [
18
- "dist",
19
- "README.md"
20
- ],
21
- "scripts": {
22
- "build": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean",
23
- "dev": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --watch",
24
- "test": "vitest run",
25
- "test:watch": "vitest",
26
- "test:coverage": "vitest run --coverage",
27
- "typecheck": "tsc --noEmit",
28
- "lint": "eslint src --ext .ts",
29
- "lint:fix": "eslint src --ext .ts --fix",
30
- "clean": "rm -rf dist",
31
- "build:prod": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean --minify --treeshake"
32
- },
33
- "dependencies": {
34
- "@danielsimonjr/mathts-workerpool": "^0.2.1"
35
- },
36
- "devDependencies": {
37
- "@types/node": "^25.5.2",
38
- "tsup": "^8.0.0",
39
- "typescript": "^5.3.0",
40
- "vitest": "^4.1.5"
41
- },
42
- "publishConfig": {
43
- "access": "public"
44
- },
45
- "repository": {
46
- "type": "git",
47
- "url": "https://github.com/danielsimonjr/mathts",
48
- "directory": "parallel"
49
- },
50
- "keywords": [
51
- "math",
52
- "typescript",
53
- "parallel",
54
- "webworker",
55
- "worker-pool"
56
- ]
57
- }
1
+ {
2
+ "name": "@danielsimonjr/mathts-parallel",
3
+ "version": "0.4.0",
4
+ "description": "WebWorker parallelization for MathTS computations",
5
+ "author": "Daniel Simon Jr.",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.js",
14
+ "types": "./dist/index.d.ts"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean",
23
+ "dev": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --watch",
24
+ "test": "vitest run",
25
+ "test:watch": "vitest",
26
+ "test:coverage": "vitest run --coverage",
27
+ "typecheck": "tsc --noEmit",
28
+ "lint": "eslint src --ext .ts",
29
+ "lint:fix": "eslint src --ext .ts --fix",
30
+ "clean": "rm -rf dist",
31
+ "build:prod": "tsup src/index.ts src/matrix.worker.ts --format esm --dts --clean --minify --treeshake"
32
+ },
33
+ "dependencies": {
34
+ "@danielsimonjr/mathts-workerpool": "^0.2.1",
35
+ "@danielsimonjr/mathts-core": "^0.7.0"
36
+ },
37
+ "devDependencies": {
38
+ "@types/node": "^25.5.2",
39
+ "tsup": "^8.0.0",
40
+ "typescript": "^5.3.0",
41
+ "vitest": "^4.1.5"
42
+ },
43
+ "publishConfig": {
44
+ "access": "public"
45
+ },
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "https://github.com/danielsimonjr/mathts",
49
+ "directory": "parallel"
50
+ },
51
+ "keywords": [
52
+ "math",
53
+ "typescript",
54
+ "parallel",
55
+ "webworker",
56
+ "worker-pool"
57
+ ]
58
+ }