@danielsimonjr/mathts-wasm 0.3.0 → 0.3.2

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/README.md CHANGED
@@ -27,57 +27,44 @@ npm run asbuild
27
27
 
28
28
  ## Usage
29
29
 
30
- ### Browser
30
+ The published entry is AssemblyScript-generated glue in `build/mathts.js` (see
31
+ `package.json` `exports["."]`). Import named functions directly:
31
32
 
32
33
  ```typescript
33
- import { MathTSWasm } from '@danielsimonjr/mathts-wasm';
34
+ import { add_f64, sqrt_f64, sin_f64 } from '@danielsimonjr/mathts-wasm';
34
35
 
35
- const wasm = await MathTSWasm.create('/path/to/mathts.wasm');
36
-
37
- // Scalar operations
38
- const sum = wasm.add(2, 3); // 5
39
- const sqrt = wasm.sqrt(16); // 4
40
- const sin = wasm.sin(Math.PI / 2); // 1
41
-
42
- // For array/matrix operations, use the raw exports
43
- const exports = wasm.raw;
44
- // ... work with typed arrays and pointers
36
+ console.log(add_f64(2, 3)); // 5
37
+ console.log(sqrt_f64(16)); // 4
38
+ console.log(sin_f64(Math.PI / 2)); // 1
45
39
  ```
46
40
 
47
- ### Node.js
41
+ `matrix` and `functions` load the same binary as `mathts-as.wasm` via their own
42
+ loaders and SHA-384 verification (`core/src/wasm-loader.ts`).
48
43
 
49
- ```typescript
50
- import { loadWasmSync } from '@danielsimonjr/mathts-wasm';
51
- import fs from 'fs';
44
+ ### Dense decompositions (AS exports)
52
45
 
53
- const buffer = fs.readFileSync('./build/mathts.wasm');
54
- const { exports } = loadWasmSync(buffer);
46
+ From `algebra/decomposition.ts` (used by matrix `WASMBackend` tests, not public
47
+ `lu()`/`qr()` in JS):
55
48
 
56
- console.log(exports.add_f64(2, 3)); // 5
57
- ```
49
+ - `matrix_lu_decompose`, `matrix_qr_decompose`, `matrix_cholesky`,
50
+ `matrix_inverse`, `matrix_determinant`
51
+
52
+ Call `heap_reset` after managed sequences when using bump-allocated scratch
53
+ (`heap.ts`). The **functions** WASM bridges call it after each managed call;
54
+ matrix does not — it pools buffers.
58
55
 
59
56
  ## Module Structure
60
57
 
61
58
  ```
62
59
  assembly/
63
60
  ├── src/
64
- │ ├── index.ts # Main entry point
65
- │ ├── types/
66
- │ │ └── complex.ts # Complex number type
67
- │ ├── ops/ # scalar, array, matrix, complex-ops,
68
- │ │ │ # complex-array, linalg, svd, signal,
69
- │ │ │ # special, polynomial, number-theory,
70
- │ │ └── ... # optimization, curvefit, approx, tensor
71
- │ ├── env/
72
- │ │ └── abort.ts # Error handling
73
- │ └── bindings/
74
- │ ├── index.ts # Bindings entry point
75
- │ └── wasm-loader.ts # JS/TS bindings (SHA-384 verified)
76
- ├── build/ # WASM output
77
- ├── tests/
78
- │ └── run.js # Test runner
79
- ├── asconfig.json # AssemblyScript config
80
- ├── tsconfig.bindings.json # TypeScript bindings config
61
+ │ ├── index.ts # AS export surface
62
+ │ ├── algebra/decomposition.ts
63
+ │ ├── elementwise.ts, heap.ts, poly.ts, signal.ts, sort.ts, special.ts, tridiag.ts
64
+ │ ├── types/complex.ts
65
+ │ └── ops/ # scalar, array, matrix, complex-ops, fft, …
66
+ ├── build/ # mathts.wasm, mathts.js, mathts.d.ts
67
+ ├── tests/run.js # debug wasm smoke tests
81
68
  └── package.json
82
69
  ```
83
70
 
@@ -122,9 +109,8 @@ assembly/
122
109
  ## Testing
123
110
 
124
111
  ```bash
125
- # Run tests (requires build first)
126
- npm run asbuild:debug
127
- npm test
112
+ npm run asbuild # release + debug (npm test needs release for test:diff)
113
+ npm test # tests/run.js (debug wasm) + nine kernel tests + test:diff (release wasm)
128
114
  ```
129
115
 
130
116
  ## License
Binary file