@justinelliottcobb/amari-wasm 0.9.8 → 0.9.10
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 +35 -31
- package/amari_wasm.d.ts +7 -7
- package/amari_wasm.js +18 -18
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @justinelliottcobb/amari-wasm v0.9.
|
|
1
|
+
# @justinelliottcobb/amari-wasm v0.9.8
|
|
2
2
|
|
|
3
3
|
**Unified Mathematical Computing Library with High-Precision WebAssembly Support**
|
|
4
4
|
|
|
@@ -6,42 +6,45 @@
|
|
|
6
6
|
[](https://github.com/justinelliottcobb/Amari/actions/workflows/ci.yml)
|
|
7
7
|
[](https://opensource.org/licenses/MIT)
|
|
8
8
|
|
|
9
|
-
Amari is a comprehensive mathematical computing library that brings advanced algebraic systems to JavaScript/TypeScript through WebAssembly
|
|
9
|
+
Amari is a comprehensive mathematical computing library that brings advanced algebraic systems to JavaScript/TypeScript through WebAssembly. Features high-precision arithmetic for spacecraft orbital mechanics and relativistic physics calculations with pure Rust implementation and no native dependencies for universal deployment.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
### New in v0.9.0: High-Precision WebAssembly
|
|
14
|
-
- **Spacecraft Orbital Mechanics**: Full-precision trajectory calculations now available in browsers
|
|
15
|
-
- **Relativistic Physics**: Spacetime algebra (Cl(1,3)) with WebAssembly-compatible precision
|
|
16
|
-
- **Pure Rust Backend**: dashu-powered arithmetic with no native dependencies
|
|
17
|
-
- **Universal Deployment**: Same precision guarantees across desktop, web, and edge environments
|
|
18
|
-
- **WebAssembly 3.0 Ready**: Leverages latest WASM features for enhanced mathematical computing
|
|
19
|
-
|
|
20
13
|
### Core Mathematical Systems
|
|
14
|
+
|
|
21
15
|
- **Geometric Algebra (Clifford Algebra)**: Multivectors, rotors, and geometric products for 3D rotations and spatial transformations
|
|
22
16
|
- **Tropical Algebra**: Max-plus semiring operations for optimization and neural network applications
|
|
23
17
|
- **Automatic Differentiation**: Forward-mode AD with dual numbers for exact derivatives
|
|
18
|
+
- **Relativistic Physics**: Spacetime algebra (Cl(1,3)) with WebAssembly-compatible precision
|
|
19
|
+
- **Spacecraft Orbital Mechanics**: Full-precision trajectory calculations in browsers
|
|
24
20
|
- **Cellular Automata**: Geometric cellular automata with multivector states
|
|
25
21
|
- **WebGPU Acceleration**: Optional GPU acceleration for large-scale operations
|
|
26
22
|
- **Pure Rust Implementation**: Memory-safe, high-performance core with WASM bindings
|
|
27
23
|
- **TypeScript Support**: Full TypeScript definitions included
|
|
28
24
|
|
|
25
|
+
### High-Precision Arithmetic
|
|
26
|
+
|
|
27
|
+
- **Pure Rust Backend**: dashu-powered arithmetic with no native dependencies
|
|
28
|
+
- **Universal Deployment**: Same precision guarantees across desktop, web, and edge environments
|
|
29
|
+
- **Orbital-Grade Tolerance**: Configurable precision for critical trajectory calculations
|
|
30
|
+
- **WebAssembly 3.0 Ready**: Leverages latest WASM features for enhanced mathematical computing
|
|
31
|
+
|
|
29
32
|
## Installation
|
|
30
33
|
|
|
31
34
|
```bash
|
|
32
|
-
npm install @amari
|
|
35
|
+
npm install @justinelliottcobb/amari-wasm
|
|
33
36
|
```
|
|
34
37
|
|
|
35
38
|
Or with yarn:
|
|
36
39
|
|
|
37
40
|
```bash
|
|
38
|
-
yarn add @amari
|
|
41
|
+
yarn add @justinelliottcobb/amari-wasm
|
|
39
42
|
```
|
|
40
43
|
|
|
41
44
|
## Quick Start
|
|
42
45
|
|
|
43
46
|
```typescript
|
|
44
|
-
import init, { WasmMultivector, WasmRotor } from '@amari
|
|
47
|
+
import init, { WasmMultivector, WasmRotor } from '@justinelliottcobb/amari-wasm';
|
|
45
48
|
|
|
46
49
|
async function main() {
|
|
47
50
|
// Initialize the WASM module
|
|
@@ -79,7 +82,7 @@ async function main() {
|
|
|
79
82
|
main();
|
|
80
83
|
```
|
|
81
84
|
|
|
82
|
-
## High-Precision Orbital Mechanics
|
|
85
|
+
## High-Precision Orbital Mechanics
|
|
83
86
|
|
|
84
87
|
```typescript
|
|
85
88
|
import init, {
|
|
@@ -87,7 +90,7 @@ import init, {
|
|
|
87
90
|
WasmFourVelocity,
|
|
88
91
|
WasmRelativisticParticle,
|
|
89
92
|
WasmSchwarzschildMetric
|
|
90
|
-
} from '@amari
|
|
93
|
+
} from '@justinelliottcobb/amari-wasm';
|
|
91
94
|
|
|
92
95
|
async function spacecraftSimulation() {
|
|
93
96
|
await init();
|
|
@@ -124,7 +127,7 @@ async function spacecraftSimulation() {
|
|
|
124
127
|
console.log(`Orbital trajectory computed with ${trajectory.length} points`);
|
|
125
128
|
console.log(`Final position deviation: ${spacecraft.position_error()} meters`);
|
|
126
129
|
|
|
127
|
-
// WebAssembly precision matches native accuracy
|
|
130
|
+
// WebAssembly precision matches native accuracy
|
|
128
131
|
|
|
129
132
|
// Clean up WASM memory
|
|
130
133
|
earth.free();
|
|
@@ -157,7 +160,7 @@ const inner = v1.inner_product(v2);
|
|
|
157
160
|
Tropical algebra replaces addition with max and multiplication with addition, useful for optimization:
|
|
158
161
|
|
|
159
162
|
```typescript
|
|
160
|
-
import { tropical_add, tropical_multiply } from '@amari
|
|
163
|
+
import { tropical_add, tropical_multiply } from '@justinelliottcobb/amari-wasm';
|
|
161
164
|
|
|
162
165
|
// Tropical operations: add = max, multiply = add
|
|
163
166
|
const a = 5.0, b = 3.0;
|
|
@@ -185,12 +188,13 @@ console.log(`Generation: ${ca.generation()}`);
|
|
|
185
188
|
|
|
186
189
|
## Use Cases
|
|
187
190
|
|
|
188
|
-
-
|
|
189
|
-
-
|
|
190
|
-
-
|
|
191
|
-
-
|
|
192
|
-
-
|
|
193
|
-
-
|
|
191
|
+
- Computer Graphics: 3D rotations and transformations using rotors
|
|
192
|
+
- Physics Simulations: Geometric algebra for electromagnetic fields and relativistic calculations
|
|
193
|
+
- Machine Learning: Tropical neural networks and automatic differentiation
|
|
194
|
+
- Optimization: Tropical algebra for shortest path and scheduling problems
|
|
195
|
+
- Scientific Computing: High-performance mathematical operations with orbital-grade precision
|
|
196
|
+
- Game Development: Efficient spatial transformations and physics
|
|
197
|
+
- Spacecraft Trajectory Planning: High-precision orbital mechanics in web applications
|
|
194
198
|
|
|
195
199
|
## API Reference
|
|
196
200
|
|
|
@@ -216,7 +220,7 @@ console.log(`Generation: ${ca.generation()}`);
|
|
|
216
220
|
- `tropical_multiply(a, b)`: Tropical multiplication (addition)
|
|
217
221
|
- `tropical_power(base, exp)`: Tropical exponentiation
|
|
218
222
|
|
|
219
|
-
##
|
|
223
|
+
## Examples
|
|
220
224
|
|
|
221
225
|
Check out the [examples directory](https://github.com/justinelliottcobb/Amari/tree/master/examples) for more detailed usage:
|
|
222
226
|
|
|
@@ -225,7 +229,7 @@ Check out the [examples directory](https://github.com/justinelliottcobb/Amari/tr
|
|
|
225
229
|
- [Tropical Neural Networks](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/tropical.ts)
|
|
226
230
|
- [Cellular Automata](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/cellular.ts)
|
|
227
231
|
|
|
228
|
-
##
|
|
232
|
+
## Building from Source
|
|
229
233
|
|
|
230
234
|
```bash
|
|
231
235
|
# Clone the repository
|
|
@@ -242,25 +246,25 @@ npm run build
|
|
|
242
246
|
npm test
|
|
243
247
|
```
|
|
244
248
|
|
|
245
|
-
##
|
|
249
|
+
## Contributing
|
|
246
250
|
|
|
247
|
-
Contributions are welcome
|
|
251
|
+
Contributions are welcome. Please see [CONTRIBUTING.md](https://github.com/justinelliottcobb/Amari/blob/master/CONTRIBUTING.md) for details.
|
|
248
252
|
|
|
249
|
-
##
|
|
253
|
+
## License
|
|
250
254
|
|
|
251
255
|
MIT License - see [LICENSE](https://github.com/justinelliottcobb/Amari/blob/master/LICENSE) for details.
|
|
252
256
|
|
|
253
|
-
##
|
|
257
|
+
## Acknowledgments
|
|
254
258
|
|
|
255
259
|
- Built with Rust and wasm-bindgen
|
|
256
260
|
- Inspired by geometric algebra libraries like GAViewer and Ganja.js
|
|
257
261
|
- Tropical algebra concepts from discrete mathematics
|
|
258
262
|
|
|
259
|
-
##
|
|
263
|
+
## Contact
|
|
260
264
|
|
|
261
265
|
- GitHub: [@justinelliottcobb](https://github.com/justinelliottcobb)
|
|
262
|
-
- NPM: [@amari
|
|
266
|
+
- NPM: [@justinelliottcobb/amari-wasm](https://www.npmjs.com/package/@justinelliottcobb/amari-wasm)
|
|
263
267
|
|
|
264
268
|
---
|
|
265
269
|
|
|
266
|
-
|
|
270
|
+
Made with Rust by the Amari team
|
package/amari_wasm.d.ts
CHANGED
|
@@ -4,10 +4,6 @@
|
|
|
4
4
|
* Initialize the enumerative geometry module
|
|
5
5
|
*/
|
|
6
6
|
export function initEnumerative(): void;
|
|
7
|
-
/**
|
|
8
|
-
* Validate that this module loaded correctly
|
|
9
|
-
*/
|
|
10
|
-
export function validate_relativistic_module(): boolean;
|
|
11
7
|
/**
|
|
12
8
|
* Convert velocity to Lorentz factor
|
|
13
9
|
*/
|
|
@@ -16,6 +12,10 @@ export function velocity_to_gamma(velocity_magnitude: number): number;
|
|
|
16
12
|
* Convert Lorentz factor to velocity
|
|
17
13
|
*/
|
|
18
14
|
export function gamma_to_velocity(gamma: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Validate that this module loaded correctly
|
|
17
|
+
*/
|
|
18
|
+
export function validate_relativistic_module(): boolean;
|
|
19
19
|
/**
|
|
20
20
|
* Calculate light deflection angle for photon grazing massive object
|
|
21
21
|
*/
|
|
@@ -2258,9 +2258,9 @@ export interface InitOutput {
|
|
|
2258
2258
|
readonly __wbg_wasmrotor_free: (a: number, b: number) => void;
|
|
2259
2259
|
readonly wasmmultiobjectiveoptimizer_new: () => number;
|
|
2260
2260
|
readonly wasmsimpleoptimizer_new: () => number;
|
|
2261
|
-
readonly
|
|
2262
|
-
readonly
|
|
2263
|
-
readonly
|
|
2261
|
+
readonly wasm_bindgen__convert__closures_____invoke__h9e55f7f912fc76ac: (a: number, b: number, c: any) => void;
|
|
2262
|
+
readonly wasm_bindgen__closure__destroy__ha65d378aaf4b53b1: (a: number, b: number) => void;
|
|
2263
|
+
readonly wasm_bindgen__convert__closures_____invoke__h04878e576420376d: (a: number, b: number, c: any, d: any) => void;
|
|
2264
2264
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
2265
2265
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
2266
2266
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/amari_wasm.js
CHANGED
|
@@ -268,15 +268,6 @@ function passArrayF64ToWasm0(arg, malloc) {
|
|
|
268
268
|
WASM_VECTOR_LEN = arg.length;
|
|
269
269
|
return ptr;
|
|
270
270
|
}
|
|
271
|
-
/**
|
|
272
|
-
* Validate that this module loaded correctly
|
|
273
|
-
* @returns {boolean}
|
|
274
|
-
*/
|
|
275
|
-
export function validate_relativistic_module() {
|
|
276
|
-
const ret = wasm.validate_relativistic_module();
|
|
277
|
-
return ret !== 0;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
271
|
/**
|
|
281
272
|
* Convert velocity to Lorentz factor
|
|
282
273
|
* @param {number} velocity_magnitude
|
|
@@ -303,6 +294,15 @@ export function gamma_to_velocity(gamma) {
|
|
|
303
294
|
return ret[0];
|
|
304
295
|
}
|
|
305
296
|
|
|
297
|
+
/**
|
|
298
|
+
* Validate that this module loaded correctly
|
|
299
|
+
* @returns {boolean}
|
|
300
|
+
*/
|
|
301
|
+
export function validate_relativistic_module() {
|
|
302
|
+
const ret = wasm.validate_relativistic_module();
|
|
303
|
+
return ret !== 0;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
306
|
/**
|
|
307
307
|
* Calculate light deflection angle for photon grazing massive object
|
|
308
308
|
* @param {number} impact_parameter
|
|
@@ -339,12 +339,12 @@ function getArrayU8FromWasm0(ptr, len) {
|
|
|
339
339
|
ptr = ptr >>> 0;
|
|
340
340
|
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
341
341
|
}
|
|
342
|
-
function
|
|
343
|
-
wasm.
|
|
342
|
+
function wasm_bindgen__convert__closures_____invoke__h9e55f7f912fc76ac(arg0, arg1, arg2) {
|
|
343
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h9e55f7f912fc76ac(arg0, arg1, arg2);
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
function
|
|
347
|
-
wasm.
|
|
346
|
+
function wasm_bindgen__convert__closures_____invoke__h04878e576420376d(arg0, arg1, arg2, arg3) {
|
|
347
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h04878e576420376d(arg0, arg1, arg2, arg3);
|
|
348
348
|
}
|
|
349
349
|
|
|
350
350
|
const AutoDiffFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
@@ -5680,12 +5680,12 @@ function __wbg_get_imports() {
|
|
|
5680
5680
|
const ret = arg0.length;
|
|
5681
5681
|
return ret;
|
|
5682
5682
|
};
|
|
5683
|
+
imports.wbg.__wbg_log_660547816007a991 = function(arg0, arg1) {
|
|
5684
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
5685
|
+
};
|
|
5683
5686
|
imports.wbg.__wbg_log_8cec76766b8c0e33 = function(arg0) {
|
|
5684
5687
|
console.log(arg0);
|
|
5685
5688
|
};
|
|
5686
|
-
imports.wbg.__wbg_log_bc75dce15192515f = function(arg0, arg1) {
|
|
5687
|
-
console.log(getStringFromWasm0(arg0, arg1));
|
|
5688
|
-
};
|
|
5689
5689
|
imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
|
|
5690
5690
|
const ret = new Object();
|
|
5691
5691
|
return ret;
|
|
@@ -5697,7 +5697,7 @@ function __wbg_get_imports() {
|
|
|
5697
5697
|
const a = state0.a;
|
|
5698
5698
|
state0.a = 0;
|
|
5699
5699
|
try {
|
|
5700
|
-
return
|
|
5700
|
+
return wasm_bindgen__convert__closures_____invoke__h04878e576420376d(a, state0.b, arg0, arg1);
|
|
5701
5701
|
} finally {
|
|
5702
5702
|
state0.a = a;
|
|
5703
5703
|
}
|
|
@@ -5800,7 +5800,7 @@ function __wbg_get_imports() {
|
|
|
5800
5800
|
};
|
|
5801
5801
|
imports.wbg.__wbindgen_cast_69f35aa0fcaecc47 = function(arg0, arg1) {
|
|
5802
5802
|
// Cast intrinsic for `Closure(Closure { dtor_idx: 37, function: Function { arguments: [Externref], shim_idx: 38, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
5803
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
5803
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__ha65d378aaf4b53b1, wasm_bindgen__convert__closures_____invoke__h9e55f7f912fc76ac);
|
|
5804
5804
|
return ret;
|
|
5805
5805
|
};
|
|
5806
5806
|
imports.wbg.__wbindgen_cast_b63aeb0d85365734 = function(arg0, arg1) {
|
package/amari_wasm_bg.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"Amari Contributors"
|
|
6
6
|
],
|
|
7
7
|
"description": "WebAssembly bindings for Amari mathematical computing library - geometric algebra, tropical algebra, automatic differentiation, fusion systems, and information geometry",
|
|
8
|
-
"version": "0.9.
|
|
8
|
+
"version": "0.9.10",
|
|
9
9
|
"license": "MIT OR Apache-2.0",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|