@justinelliottcobb/amari-wasm 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 +202 -0
- package/amari_wasm.d.ts +200 -0
- package/amari_wasm.js +568 -0
- package/amari_wasm_bg.wasm +0 -0
- package/package.json +32 -0
package/README.md
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
# @amari/core
|
|
2
|
+
|
|
3
|
+
🚀 **Advanced Mathematical Computing Library for JavaScript/TypeScript**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@amari/core)
|
|
6
|
+
[](https://github.com/justinelliottcobb/Amari/actions/workflows/ci.yml)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
Amari is a high-performance mathematical computing library that brings advanced algebraic structures to JavaScript/TypeScript through WebAssembly. It combines geometric algebra, tropical algebra, dual number automatic differentiation, and cellular automata in a unified framework.
|
|
10
|
+
|
|
11
|
+
## ✨ Features
|
|
12
|
+
|
|
13
|
+
- **🔢 Geometric Algebra (Clifford Algebra)**: Multivectors, rotors, and geometric products for 3D rotations and spatial transformations
|
|
14
|
+
- **🌴 Tropical Algebra**: Max-plus semiring operations for optimization and neural network applications
|
|
15
|
+
- **📈 Automatic Differentiation**: Forward-mode AD with dual numbers for exact derivatives
|
|
16
|
+
- **🔲 Cellular Automata**: Geometric cellular automata with multivector states
|
|
17
|
+
- **⚡ WebGPU Acceleration**: Optional GPU acceleration for large-scale operations
|
|
18
|
+
- **🦀 Pure Rust Implementation**: Memory-safe, high-performance core with WASM bindings
|
|
19
|
+
- **📦 TypeScript Support**: Full TypeScript definitions included
|
|
20
|
+
|
|
21
|
+
## 📦 Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @amari/core
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Or with yarn:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
yarn add @amari/core
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🚀 Quick Start
|
|
34
|
+
|
|
35
|
+
```typescript
|
|
36
|
+
import init, { WasmMultivector, WasmRotor } from '@amari/core';
|
|
37
|
+
|
|
38
|
+
async function main() {
|
|
39
|
+
// Initialize the WASM module
|
|
40
|
+
await init();
|
|
41
|
+
|
|
42
|
+
// Create basis vectors
|
|
43
|
+
const e1 = WasmMultivector.basis_vector(0);
|
|
44
|
+
const e2 = WasmMultivector.basis_vector(1);
|
|
45
|
+
|
|
46
|
+
// Compute geometric product
|
|
47
|
+
const product = e1.geometric_product(e2);
|
|
48
|
+
console.log(product.to_string()); // e12 (bivector)
|
|
49
|
+
|
|
50
|
+
// Create a rotor for 90-degree rotation
|
|
51
|
+
const rotor = WasmRotor.from_axis_angle(
|
|
52
|
+
WasmMultivector.basis_vector(2), // z-axis
|
|
53
|
+
Math.PI / 2
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
// Rotate a vector
|
|
57
|
+
const vector = WasmMultivector.from_coefficients(
|
|
58
|
+
new Float64Array([1, 0, 0, 0, 0, 0, 0, 0])
|
|
59
|
+
);
|
|
60
|
+
const rotated = rotor.rotate_vector(vector);
|
|
61
|
+
|
|
62
|
+
// Clean up WASM memory
|
|
63
|
+
e1.free();
|
|
64
|
+
e2.free();
|
|
65
|
+
product.free();
|
|
66
|
+
rotor.free();
|
|
67
|
+
vector.free();
|
|
68
|
+
rotated.free();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
main();
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 📚 Core Concepts
|
|
75
|
+
|
|
76
|
+
### Geometric Algebra
|
|
77
|
+
|
|
78
|
+
Geometric algebra extends linear algebra with the geometric product, enabling intuitive representation of rotations, reflections, and other transformations:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
// Multivector operations
|
|
82
|
+
const v1 = WasmMultivector.from_coefficients(coeffs);
|
|
83
|
+
const v2 = WasmMultivector.random();
|
|
84
|
+
|
|
85
|
+
const sum = v1.add(v2);
|
|
86
|
+
const product = v1.geometric_product(v2);
|
|
87
|
+
const wedge = v1.wedge_product(v2);
|
|
88
|
+
const inner = v1.inner_product(v2);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Tropical Algebra
|
|
92
|
+
|
|
93
|
+
Tropical algebra replaces addition with max and multiplication with addition, useful for optimization:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { tropical_add, tropical_multiply } from '@amari/core';
|
|
97
|
+
|
|
98
|
+
// Tropical operations: add = max, multiply = add
|
|
99
|
+
const a = 5.0, b = 3.0;
|
|
100
|
+
const trop_sum = tropical_add(a, b); // max(5, 3) = 5
|
|
101
|
+
const trop_prod = tropical_multiply(a, b); // 5 + 3 = 8
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Cellular Automata
|
|
105
|
+
|
|
106
|
+
Create and evolve cellular automata with geometric algebra states:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
const ca = WasmGeometricCA.new(100, 100);
|
|
110
|
+
|
|
111
|
+
// Set initial configuration
|
|
112
|
+
ca.set_cell(50, 50, WasmMultivector.basis_vector(0));
|
|
113
|
+
|
|
114
|
+
// Evolve the system
|
|
115
|
+
for (let i = 0; i < 100; i++) {
|
|
116
|
+
ca.step();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
console.log(`Generation: ${ca.generation()}`);
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 🎯 Use Cases
|
|
123
|
+
|
|
124
|
+
- **Computer Graphics**: 3D rotations and transformations using rotors
|
|
125
|
+
- **Physics Simulations**: Geometric algebra for electromagnetic fields
|
|
126
|
+
- **Machine Learning**: Tropical neural networks and automatic differentiation
|
|
127
|
+
- **Optimization**: Tropical algebra for shortest path and scheduling problems
|
|
128
|
+
- **Scientific Computing**: High-performance mathematical operations
|
|
129
|
+
- **Game Development**: Efficient spatial transformations and physics
|
|
130
|
+
|
|
131
|
+
## 🔧 API Reference
|
|
132
|
+
|
|
133
|
+
### Multivector Operations
|
|
134
|
+
|
|
135
|
+
- `WasmMultivector.basis_vector(index)`: Create a basis vector
|
|
136
|
+
- `WasmMultivector.scalar(value)`: Create a scalar multivector
|
|
137
|
+
- `WasmMultivector.from_coefficients(array)`: Create from coefficients
|
|
138
|
+
- `geometric_product(a, b)`: Compute geometric product
|
|
139
|
+
- `wedge_product(a, b)`: Compute wedge (outer) product
|
|
140
|
+
- `inner_product(a, b)`: Compute inner product
|
|
141
|
+
|
|
142
|
+
### Rotor Operations
|
|
143
|
+
|
|
144
|
+
- `WasmRotor.from_axis_angle(axis, angle)`: Create rotation rotor
|
|
145
|
+
- `WasmRotor.from_bivector(bivector, angle)`: Create from bivector
|
|
146
|
+
- `rotate_vector(vector)`: Apply rotation to vector
|
|
147
|
+
- `compose(other)`: Compose rotations
|
|
148
|
+
|
|
149
|
+
### Tropical Operations
|
|
150
|
+
|
|
151
|
+
- `tropical_add(a, b)`: Tropical addition (max)
|
|
152
|
+
- `tropical_multiply(a, b)`: Tropical multiplication (addition)
|
|
153
|
+
- `tropical_power(base, exp)`: Tropical exponentiation
|
|
154
|
+
|
|
155
|
+
## 🔍 Examples
|
|
156
|
+
|
|
157
|
+
Check out the [examples directory](https://github.com/justinelliottcobb/Amari/tree/master/examples) for more detailed usage:
|
|
158
|
+
|
|
159
|
+
- [Basic Geometric Algebra](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/geometric.ts)
|
|
160
|
+
- [3D Rotations with Rotors](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/rotations.ts)
|
|
161
|
+
- [Tropical Neural Networks](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/tropical.ts)
|
|
162
|
+
- [Cellular Automata](https://github.com/justinelliottcobb/Amari/blob/master/examples/typescript/cellular.ts)
|
|
163
|
+
|
|
164
|
+
## 🏗️ Building from Source
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Clone the repository
|
|
168
|
+
git clone https://github.com/justinelliottcobb/Amari.git
|
|
169
|
+
cd Amari/amari-wasm
|
|
170
|
+
|
|
171
|
+
# Install dependencies
|
|
172
|
+
npm install
|
|
173
|
+
|
|
174
|
+
# Build WASM module
|
|
175
|
+
npm run build
|
|
176
|
+
|
|
177
|
+
# Run tests
|
|
178
|
+
npm test
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 🤝 Contributing
|
|
182
|
+
|
|
183
|
+
Contributions are welcome! Please feel free to submit a Pull Request. See [CONTRIBUTING.md](https://github.com/justinelliottcobb/Amari/blob/master/CONTRIBUTING.md) for details.
|
|
184
|
+
|
|
185
|
+
## 📄 License
|
|
186
|
+
|
|
187
|
+
MIT License - see [LICENSE](https://github.com/justinelliottcobb/Amari/blob/master/LICENSE) for details.
|
|
188
|
+
|
|
189
|
+
## 🙏 Acknowledgments
|
|
190
|
+
|
|
191
|
+
- Built with Rust and wasm-bindgen
|
|
192
|
+
- Inspired by geometric algebra libraries like GAViewer and Ganja.js
|
|
193
|
+
- Tropical algebra concepts from discrete mathematics
|
|
194
|
+
|
|
195
|
+
## 📬 Contact
|
|
196
|
+
|
|
197
|
+
- GitHub: [@justinelliottcobb](https://github.com/justinelliottcobb)
|
|
198
|
+
- NPM: [@amari/core](https://www.npmjs.com/package/@amari/core)
|
|
199
|
+
|
|
200
|
+
---
|
|
201
|
+
|
|
202
|
+
**Made with ❤️ and 🦀 by the Amari team**
|
package/amari_wasm.d.ts
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Initialize the WASM module
|
|
5
|
+
*/
|
|
6
|
+
export function init(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Batch operations for performance
|
|
9
|
+
*/
|
|
10
|
+
export class BatchOperations {
|
|
11
|
+
private constructor();
|
|
12
|
+
free(): void;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
/**
|
|
15
|
+
* Batch geometric product: compute a[i] * b[i] for all i
|
|
16
|
+
*/
|
|
17
|
+
static batchGeometricProduct(a_batch: Float64Array, b_batch: Float64Array): Float64Array;
|
|
18
|
+
/**
|
|
19
|
+
* Batch addition
|
|
20
|
+
*/
|
|
21
|
+
static batchAdd(a_batch: Float64Array, b_batch: Float64Array): Float64Array;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* WASM wrapper for Multivector with TypedArray support
|
|
25
|
+
*/
|
|
26
|
+
export class WasmMultivector {
|
|
27
|
+
free(): void;
|
|
28
|
+
[Symbol.dispose](): void;
|
|
29
|
+
/**
|
|
30
|
+
* Create a new zero multivector
|
|
31
|
+
*/
|
|
32
|
+
constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Create from a Float64Array of coefficients
|
|
35
|
+
*/
|
|
36
|
+
static fromCoefficients(coefficients: Float64Array): WasmMultivector;
|
|
37
|
+
/**
|
|
38
|
+
* Create a scalar multivector
|
|
39
|
+
*/
|
|
40
|
+
static scalar(value: number): WasmMultivector;
|
|
41
|
+
/**
|
|
42
|
+
* Create a basis vector (0-indexed)
|
|
43
|
+
*/
|
|
44
|
+
static basisVector(index: number): WasmMultivector;
|
|
45
|
+
/**
|
|
46
|
+
* Get coefficients as a Float64Array
|
|
47
|
+
*/
|
|
48
|
+
getCoefficients(): Float64Array;
|
|
49
|
+
/**
|
|
50
|
+
* Get a specific coefficient
|
|
51
|
+
*/
|
|
52
|
+
getCoefficient(index: number): number;
|
|
53
|
+
/**
|
|
54
|
+
* Set a specific coefficient
|
|
55
|
+
*/
|
|
56
|
+
setCoefficient(index: number, value: number): void;
|
|
57
|
+
/**
|
|
58
|
+
* Geometric product
|
|
59
|
+
*/
|
|
60
|
+
geometricProduct(other: WasmMultivector): WasmMultivector;
|
|
61
|
+
/**
|
|
62
|
+
* Inner product (dot product for vectors)
|
|
63
|
+
*/
|
|
64
|
+
innerProduct(other: WasmMultivector): WasmMultivector;
|
|
65
|
+
/**
|
|
66
|
+
* Outer product (wedge product)
|
|
67
|
+
*/
|
|
68
|
+
outerProduct(other: WasmMultivector): WasmMultivector;
|
|
69
|
+
/**
|
|
70
|
+
* Scalar product
|
|
71
|
+
*/
|
|
72
|
+
scalarProduct(other: WasmMultivector): number;
|
|
73
|
+
/**
|
|
74
|
+
* Reverse
|
|
75
|
+
*/
|
|
76
|
+
reverse(): WasmMultivector;
|
|
77
|
+
/**
|
|
78
|
+
* Grade projection
|
|
79
|
+
*/
|
|
80
|
+
gradeProjection(grade: number): WasmMultivector;
|
|
81
|
+
/**
|
|
82
|
+
* Exponential (for bivectors to create rotors)
|
|
83
|
+
*/
|
|
84
|
+
exp(): WasmMultivector;
|
|
85
|
+
/**
|
|
86
|
+
* Compute magnitude
|
|
87
|
+
*/
|
|
88
|
+
magnitude(): number;
|
|
89
|
+
/**
|
|
90
|
+
* Compute norm (alias for magnitude, maintained for compatibility)
|
|
91
|
+
*/
|
|
92
|
+
norm(): number;
|
|
93
|
+
/**
|
|
94
|
+
* Normalize
|
|
95
|
+
*/
|
|
96
|
+
normalize(): WasmMultivector;
|
|
97
|
+
/**
|
|
98
|
+
* Compute inverse
|
|
99
|
+
*/
|
|
100
|
+
inverse(): WasmMultivector;
|
|
101
|
+
/**
|
|
102
|
+
* Add two multivectors
|
|
103
|
+
*/
|
|
104
|
+
add(other: WasmMultivector): WasmMultivector;
|
|
105
|
+
/**
|
|
106
|
+
* Subtract two multivectors
|
|
107
|
+
*/
|
|
108
|
+
sub(other: WasmMultivector): WasmMultivector;
|
|
109
|
+
/**
|
|
110
|
+
* Scale by a scalar
|
|
111
|
+
*/
|
|
112
|
+
scale(scalar: number): WasmMultivector;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Rotor operations for WASM
|
|
116
|
+
*/
|
|
117
|
+
export class WasmRotor {
|
|
118
|
+
private constructor();
|
|
119
|
+
free(): void;
|
|
120
|
+
[Symbol.dispose](): void;
|
|
121
|
+
/**
|
|
122
|
+
* Create a rotor from a bivector and angle
|
|
123
|
+
*/
|
|
124
|
+
static fromBivector(bivector: WasmMultivector, angle: number): WasmRotor;
|
|
125
|
+
/**
|
|
126
|
+
* Apply rotor to a multivector
|
|
127
|
+
*/
|
|
128
|
+
apply(mv: WasmMultivector): WasmMultivector;
|
|
129
|
+
/**
|
|
130
|
+
* Compose two rotors
|
|
131
|
+
*/
|
|
132
|
+
compose(other: WasmRotor): WasmRotor;
|
|
133
|
+
/**
|
|
134
|
+
* Get inverse rotor
|
|
135
|
+
*/
|
|
136
|
+
inverse(): WasmRotor;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
140
|
+
|
|
141
|
+
export interface InitOutput {
|
|
142
|
+
readonly memory: WebAssembly.Memory;
|
|
143
|
+
readonly __wbg_wasmmultivector_free: (a: number, b: number) => void;
|
|
144
|
+
readonly wasmmultivector_new: () => number;
|
|
145
|
+
readonly wasmmultivector_fromCoefficients: (a: number, b: number) => [number, number, number];
|
|
146
|
+
readonly wasmmultivector_scalar: (a: number) => number;
|
|
147
|
+
readonly wasmmultivector_basisVector: (a: number) => [number, number, number];
|
|
148
|
+
readonly wasmmultivector_getCoefficients: (a: number) => [number, number];
|
|
149
|
+
readonly wasmmultivector_getCoefficient: (a: number, b: number) => number;
|
|
150
|
+
readonly wasmmultivector_setCoefficient: (a: number, b: number, c: number) => void;
|
|
151
|
+
readonly wasmmultivector_geometricProduct: (a: number, b: number) => number;
|
|
152
|
+
readonly wasmmultivector_innerProduct: (a: number, b: number) => number;
|
|
153
|
+
readonly wasmmultivector_outerProduct: (a: number, b: number) => number;
|
|
154
|
+
readonly wasmmultivector_scalarProduct: (a: number, b: number) => number;
|
|
155
|
+
readonly wasmmultivector_reverse: (a: number) => number;
|
|
156
|
+
readonly wasmmultivector_gradeProjection: (a: number, b: number) => number;
|
|
157
|
+
readonly wasmmultivector_exp: (a: number) => number;
|
|
158
|
+
readonly wasmmultivector_magnitude: (a: number) => number;
|
|
159
|
+
readonly wasmmultivector_normalize: (a: number) => [number, number, number];
|
|
160
|
+
readonly wasmmultivector_inverse: (a: number) => [number, number, number];
|
|
161
|
+
readonly wasmmultivector_add: (a: number, b: number) => number;
|
|
162
|
+
readonly wasmmultivector_sub: (a: number, b: number) => number;
|
|
163
|
+
readonly wasmmultivector_scale: (a: number, b: number) => number;
|
|
164
|
+
readonly __wbg_batchoperations_free: (a: number, b: number) => void;
|
|
165
|
+
readonly batchoperations_batchGeometricProduct: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
166
|
+
readonly batchoperations_batchAdd: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
|
167
|
+
readonly wasmrotor_fromBivector: (a: number, b: number) => number;
|
|
168
|
+
readonly wasmrotor_apply: (a: number, b: number) => number;
|
|
169
|
+
readonly wasmrotor_compose: (a: number, b: number) => number;
|
|
170
|
+
readonly init: () => void;
|
|
171
|
+
readonly wasmmultivector_norm: (a: number) => number;
|
|
172
|
+
readonly wasmrotor_inverse: (a: number) => number;
|
|
173
|
+
readonly __wbg_wasmrotor_free: (a: number, b: number) => void;
|
|
174
|
+
readonly __wbindgen_export_0: WebAssembly.Table;
|
|
175
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
176
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
177
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
178
|
+
readonly __wbindgen_start: () => void;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
182
|
+
/**
|
|
183
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
184
|
+
* a precompiled `WebAssembly.Module`.
|
|
185
|
+
*
|
|
186
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
187
|
+
*
|
|
188
|
+
* @returns {InitOutput}
|
|
189
|
+
*/
|
|
190
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
194
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
195
|
+
*
|
|
196
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
197
|
+
*
|
|
198
|
+
* @returns {Promise<InitOutput>}
|
|
199
|
+
*/
|
|
200
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
package/amari_wasm.js
ADDED
|
@@ -0,0 +1,568 @@
|
|
|
1
|
+
let wasm;
|
|
2
|
+
|
|
3
|
+
let cachedUint8ArrayMemory0 = null;
|
|
4
|
+
|
|
5
|
+
function getUint8ArrayMemory0() {
|
|
6
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
7
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
8
|
+
}
|
|
9
|
+
return cachedUint8ArrayMemory0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
13
|
+
|
|
14
|
+
cachedTextDecoder.decode();
|
|
15
|
+
|
|
16
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
17
|
+
let numBytesDecoded = 0;
|
|
18
|
+
function decodeText(ptr, len) {
|
|
19
|
+
numBytesDecoded += len;
|
|
20
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
21
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
22
|
+
cachedTextDecoder.decode();
|
|
23
|
+
numBytesDecoded = len;
|
|
24
|
+
}
|
|
25
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getStringFromWasm0(ptr, len) {
|
|
29
|
+
ptr = ptr >>> 0;
|
|
30
|
+
return decodeText(ptr, len);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let cachedFloat64ArrayMemory0 = null;
|
|
34
|
+
|
|
35
|
+
function getFloat64ArrayMemory0() {
|
|
36
|
+
if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
|
|
37
|
+
cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
|
|
38
|
+
}
|
|
39
|
+
return cachedFloat64ArrayMemory0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
let WASM_VECTOR_LEN = 0;
|
|
43
|
+
|
|
44
|
+
function passArrayF64ToWasm0(arg, malloc) {
|
|
45
|
+
const ptr = malloc(arg.length * 8, 8) >>> 0;
|
|
46
|
+
getFloat64ArrayMemory0().set(arg, ptr / 8);
|
|
47
|
+
WASM_VECTOR_LEN = arg.length;
|
|
48
|
+
return ptr;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function takeFromExternrefTable0(idx) {
|
|
52
|
+
const value = wasm.__wbindgen_export_0.get(idx);
|
|
53
|
+
wasm.__externref_table_dealloc(idx);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getArrayF64FromWasm0(ptr, len) {
|
|
58
|
+
ptr = ptr >>> 0;
|
|
59
|
+
return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function _assertClass(instance, klass) {
|
|
63
|
+
if (!(instance instanceof klass)) {
|
|
64
|
+
throw new Error(`expected instance of ${klass.name}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Initialize the WASM module
|
|
69
|
+
*/
|
|
70
|
+
export function init() {
|
|
71
|
+
wasm.init();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const BatchOperationsFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
75
|
+
? { register: () => {}, unregister: () => {} }
|
|
76
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_batchoperations_free(ptr >>> 0, 1));
|
|
77
|
+
/**
|
|
78
|
+
* Batch operations for performance
|
|
79
|
+
*/
|
|
80
|
+
export class BatchOperations {
|
|
81
|
+
|
|
82
|
+
__destroy_into_raw() {
|
|
83
|
+
const ptr = this.__wbg_ptr;
|
|
84
|
+
this.__wbg_ptr = 0;
|
|
85
|
+
BatchOperationsFinalization.unregister(this);
|
|
86
|
+
return ptr;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
free() {
|
|
90
|
+
const ptr = this.__destroy_into_raw();
|
|
91
|
+
wasm.__wbg_batchoperations_free(ptr, 0);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Batch geometric product: compute a[i] * b[i] for all i
|
|
95
|
+
* @param {Float64Array} a_batch
|
|
96
|
+
* @param {Float64Array} b_batch
|
|
97
|
+
* @returns {Float64Array}
|
|
98
|
+
*/
|
|
99
|
+
static batchGeometricProduct(a_batch, b_batch) {
|
|
100
|
+
const ptr0 = passArrayF64ToWasm0(a_batch, wasm.__wbindgen_malloc);
|
|
101
|
+
const len0 = WASM_VECTOR_LEN;
|
|
102
|
+
const ptr1 = passArrayF64ToWasm0(b_batch, wasm.__wbindgen_malloc);
|
|
103
|
+
const len1 = WASM_VECTOR_LEN;
|
|
104
|
+
const ret = wasm.batchoperations_batchGeometricProduct(ptr0, len0, ptr1, len1);
|
|
105
|
+
if (ret[3]) {
|
|
106
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
107
|
+
}
|
|
108
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
109
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
110
|
+
return v3;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Batch addition
|
|
114
|
+
* @param {Float64Array} a_batch
|
|
115
|
+
* @param {Float64Array} b_batch
|
|
116
|
+
* @returns {Float64Array}
|
|
117
|
+
*/
|
|
118
|
+
static batchAdd(a_batch, b_batch) {
|
|
119
|
+
const ptr0 = passArrayF64ToWasm0(a_batch, wasm.__wbindgen_malloc);
|
|
120
|
+
const len0 = WASM_VECTOR_LEN;
|
|
121
|
+
const ptr1 = passArrayF64ToWasm0(b_batch, wasm.__wbindgen_malloc);
|
|
122
|
+
const len1 = WASM_VECTOR_LEN;
|
|
123
|
+
const ret = wasm.batchoperations_batchAdd(ptr0, len0, ptr1, len1);
|
|
124
|
+
if (ret[3]) {
|
|
125
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
126
|
+
}
|
|
127
|
+
var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
128
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
129
|
+
return v3;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (Symbol.dispose) BatchOperations.prototype[Symbol.dispose] = BatchOperations.prototype.free;
|
|
133
|
+
|
|
134
|
+
const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
135
|
+
? { register: () => {}, unregister: () => {} }
|
|
136
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmmultivector_free(ptr >>> 0, 1));
|
|
137
|
+
/**
|
|
138
|
+
* WASM wrapper for Multivector with TypedArray support
|
|
139
|
+
*/
|
|
140
|
+
export class WasmMultivector {
|
|
141
|
+
|
|
142
|
+
static __wrap(ptr) {
|
|
143
|
+
ptr = ptr >>> 0;
|
|
144
|
+
const obj = Object.create(WasmMultivector.prototype);
|
|
145
|
+
obj.__wbg_ptr = ptr;
|
|
146
|
+
WasmMultivectorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
147
|
+
return obj;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
__destroy_into_raw() {
|
|
151
|
+
const ptr = this.__wbg_ptr;
|
|
152
|
+
this.__wbg_ptr = 0;
|
|
153
|
+
WasmMultivectorFinalization.unregister(this);
|
|
154
|
+
return ptr;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
free() {
|
|
158
|
+
const ptr = this.__destroy_into_raw();
|
|
159
|
+
wasm.__wbg_wasmmultivector_free(ptr, 0);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Create a new zero multivector
|
|
163
|
+
*/
|
|
164
|
+
constructor() {
|
|
165
|
+
const ret = wasm.wasmmultivector_new();
|
|
166
|
+
this.__wbg_ptr = ret >>> 0;
|
|
167
|
+
WasmMultivectorFinalization.register(this, this.__wbg_ptr, this);
|
|
168
|
+
return this;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Create from a Float64Array of coefficients
|
|
172
|
+
* @param {Float64Array} coefficients
|
|
173
|
+
* @returns {WasmMultivector}
|
|
174
|
+
*/
|
|
175
|
+
static fromCoefficients(coefficients) {
|
|
176
|
+
const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
|
|
177
|
+
const len0 = WASM_VECTOR_LEN;
|
|
178
|
+
const ret = wasm.wasmmultivector_fromCoefficients(ptr0, len0);
|
|
179
|
+
if (ret[2]) {
|
|
180
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
181
|
+
}
|
|
182
|
+
return WasmMultivector.__wrap(ret[0]);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Create a scalar multivector
|
|
186
|
+
* @param {number} value
|
|
187
|
+
* @returns {WasmMultivector}
|
|
188
|
+
*/
|
|
189
|
+
static scalar(value) {
|
|
190
|
+
const ret = wasm.wasmmultivector_scalar(value);
|
|
191
|
+
return WasmMultivector.__wrap(ret);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create a basis vector (0-indexed)
|
|
195
|
+
* @param {number} index
|
|
196
|
+
* @returns {WasmMultivector}
|
|
197
|
+
*/
|
|
198
|
+
static basisVector(index) {
|
|
199
|
+
const ret = wasm.wasmmultivector_basisVector(index);
|
|
200
|
+
if (ret[2]) {
|
|
201
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
202
|
+
}
|
|
203
|
+
return WasmMultivector.__wrap(ret[0]);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get coefficients as a Float64Array
|
|
207
|
+
* @returns {Float64Array}
|
|
208
|
+
*/
|
|
209
|
+
getCoefficients() {
|
|
210
|
+
const ret = wasm.wasmmultivector_getCoefficients(this.__wbg_ptr);
|
|
211
|
+
var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
|
|
212
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
|
|
213
|
+
return v1;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Get a specific coefficient
|
|
217
|
+
* @param {number} index
|
|
218
|
+
* @returns {number}
|
|
219
|
+
*/
|
|
220
|
+
getCoefficient(index) {
|
|
221
|
+
const ret = wasm.wasmmultivector_getCoefficient(this.__wbg_ptr, index);
|
|
222
|
+
return ret;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Set a specific coefficient
|
|
226
|
+
* @param {number} index
|
|
227
|
+
* @param {number} value
|
|
228
|
+
*/
|
|
229
|
+
setCoefficient(index, value) {
|
|
230
|
+
wasm.wasmmultivector_setCoefficient(this.__wbg_ptr, index, value);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Geometric product
|
|
234
|
+
* @param {WasmMultivector} other
|
|
235
|
+
* @returns {WasmMultivector}
|
|
236
|
+
*/
|
|
237
|
+
geometricProduct(other) {
|
|
238
|
+
_assertClass(other, WasmMultivector);
|
|
239
|
+
const ret = wasm.wasmmultivector_geometricProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
240
|
+
return WasmMultivector.__wrap(ret);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Inner product (dot product for vectors)
|
|
244
|
+
* @param {WasmMultivector} other
|
|
245
|
+
* @returns {WasmMultivector}
|
|
246
|
+
*/
|
|
247
|
+
innerProduct(other) {
|
|
248
|
+
_assertClass(other, WasmMultivector);
|
|
249
|
+
const ret = wasm.wasmmultivector_innerProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
250
|
+
return WasmMultivector.__wrap(ret);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Outer product (wedge product)
|
|
254
|
+
* @param {WasmMultivector} other
|
|
255
|
+
* @returns {WasmMultivector}
|
|
256
|
+
*/
|
|
257
|
+
outerProduct(other) {
|
|
258
|
+
_assertClass(other, WasmMultivector);
|
|
259
|
+
const ret = wasm.wasmmultivector_outerProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
260
|
+
return WasmMultivector.__wrap(ret);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Scalar product
|
|
264
|
+
* @param {WasmMultivector} other
|
|
265
|
+
* @returns {number}
|
|
266
|
+
*/
|
|
267
|
+
scalarProduct(other) {
|
|
268
|
+
_assertClass(other, WasmMultivector);
|
|
269
|
+
const ret = wasm.wasmmultivector_scalarProduct(this.__wbg_ptr, other.__wbg_ptr);
|
|
270
|
+
return ret;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Reverse
|
|
274
|
+
* @returns {WasmMultivector}
|
|
275
|
+
*/
|
|
276
|
+
reverse() {
|
|
277
|
+
const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
|
|
278
|
+
return WasmMultivector.__wrap(ret);
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Grade projection
|
|
282
|
+
* @param {number} grade
|
|
283
|
+
* @returns {WasmMultivector}
|
|
284
|
+
*/
|
|
285
|
+
gradeProjection(grade) {
|
|
286
|
+
const ret = wasm.wasmmultivector_gradeProjection(this.__wbg_ptr, grade);
|
|
287
|
+
return WasmMultivector.__wrap(ret);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Exponential (for bivectors to create rotors)
|
|
291
|
+
* @returns {WasmMultivector}
|
|
292
|
+
*/
|
|
293
|
+
exp() {
|
|
294
|
+
const ret = wasm.wasmmultivector_exp(this.__wbg_ptr);
|
|
295
|
+
return WasmMultivector.__wrap(ret);
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Compute magnitude
|
|
299
|
+
* @returns {number}
|
|
300
|
+
*/
|
|
301
|
+
magnitude() {
|
|
302
|
+
const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
|
|
303
|
+
return ret;
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Compute norm (alias for magnitude, maintained for compatibility)
|
|
307
|
+
* @returns {number}
|
|
308
|
+
*/
|
|
309
|
+
norm() {
|
|
310
|
+
const ret = wasm.wasmmultivector_magnitude(this.__wbg_ptr);
|
|
311
|
+
return ret;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Normalize
|
|
315
|
+
* @returns {WasmMultivector}
|
|
316
|
+
*/
|
|
317
|
+
normalize() {
|
|
318
|
+
const ret = wasm.wasmmultivector_normalize(this.__wbg_ptr);
|
|
319
|
+
if (ret[2]) {
|
|
320
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
321
|
+
}
|
|
322
|
+
return WasmMultivector.__wrap(ret[0]);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Compute inverse
|
|
326
|
+
* @returns {WasmMultivector}
|
|
327
|
+
*/
|
|
328
|
+
inverse() {
|
|
329
|
+
const ret = wasm.wasmmultivector_inverse(this.__wbg_ptr);
|
|
330
|
+
if (ret[2]) {
|
|
331
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
332
|
+
}
|
|
333
|
+
return WasmMultivector.__wrap(ret[0]);
|
|
334
|
+
}
|
|
335
|
+
/**
|
|
336
|
+
* Add two multivectors
|
|
337
|
+
* @param {WasmMultivector} other
|
|
338
|
+
* @returns {WasmMultivector}
|
|
339
|
+
*/
|
|
340
|
+
add(other) {
|
|
341
|
+
_assertClass(other, WasmMultivector);
|
|
342
|
+
const ret = wasm.wasmmultivector_add(this.__wbg_ptr, other.__wbg_ptr);
|
|
343
|
+
return WasmMultivector.__wrap(ret);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Subtract two multivectors
|
|
347
|
+
* @param {WasmMultivector} other
|
|
348
|
+
* @returns {WasmMultivector}
|
|
349
|
+
*/
|
|
350
|
+
sub(other) {
|
|
351
|
+
_assertClass(other, WasmMultivector);
|
|
352
|
+
const ret = wasm.wasmmultivector_sub(this.__wbg_ptr, other.__wbg_ptr);
|
|
353
|
+
return WasmMultivector.__wrap(ret);
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Scale by a scalar
|
|
357
|
+
* @param {number} scalar
|
|
358
|
+
* @returns {WasmMultivector}
|
|
359
|
+
*/
|
|
360
|
+
scale(scalar) {
|
|
361
|
+
const ret = wasm.wasmmultivector_scale(this.__wbg_ptr, scalar);
|
|
362
|
+
return WasmMultivector.__wrap(ret);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (Symbol.dispose) WasmMultivector.prototype[Symbol.dispose] = WasmMultivector.prototype.free;
|
|
366
|
+
|
|
367
|
+
const WasmRotorFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
368
|
+
? { register: () => {}, unregister: () => {} }
|
|
369
|
+
: new FinalizationRegistry(ptr => wasm.__wbg_wasmrotor_free(ptr >>> 0, 1));
|
|
370
|
+
/**
|
|
371
|
+
* Rotor operations for WASM
|
|
372
|
+
*/
|
|
373
|
+
export class WasmRotor {
|
|
374
|
+
|
|
375
|
+
static __wrap(ptr) {
|
|
376
|
+
ptr = ptr >>> 0;
|
|
377
|
+
const obj = Object.create(WasmRotor.prototype);
|
|
378
|
+
obj.__wbg_ptr = ptr;
|
|
379
|
+
WasmRotorFinalization.register(obj, obj.__wbg_ptr, obj);
|
|
380
|
+
return obj;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
__destroy_into_raw() {
|
|
384
|
+
const ptr = this.__wbg_ptr;
|
|
385
|
+
this.__wbg_ptr = 0;
|
|
386
|
+
WasmRotorFinalization.unregister(this);
|
|
387
|
+
return ptr;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
free() {
|
|
391
|
+
const ptr = this.__destroy_into_raw();
|
|
392
|
+
wasm.__wbg_wasmrotor_free(ptr, 0);
|
|
393
|
+
}
|
|
394
|
+
/**
|
|
395
|
+
* Create a rotor from a bivector and angle
|
|
396
|
+
* @param {WasmMultivector} bivector
|
|
397
|
+
* @param {number} angle
|
|
398
|
+
* @returns {WasmRotor}
|
|
399
|
+
*/
|
|
400
|
+
static fromBivector(bivector, angle) {
|
|
401
|
+
_assertClass(bivector, WasmMultivector);
|
|
402
|
+
const ret = wasm.wasmrotor_fromBivector(bivector.__wbg_ptr, angle);
|
|
403
|
+
return WasmRotor.__wrap(ret);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Apply rotor to a multivector
|
|
407
|
+
* @param {WasmMultivector} mv
|
|
408
|
+
* @returns {WasmMultivector}
|
|
409
|
+
*/
|
|
410
|
+
apply(mv) {
|
|
411
|
+
_assertClass(mv, WasmMultivector);
|
|
412
|
+
const ret = wasm.wasmrotor_apply(this.__wbg_ptr, mv.__wbg_ptr);
|
|
413
|
+
return WasmMultivector.__wrap(ret);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Compose two rotors
|
|
417
|
+
* @param {WasmRotor} other
|
|
418
|
+
* @returns {WasmRotor}
|
|
419
|
+
*/
|
|
420
|
+
compose(other) {
|
|
421
|
+
_assertClass(other, WasmRotor);
|
|
422
|
+
const ret = wasm.wasmrotor_compose(this.__wbg_ptr, other.__wbg_ptr);
|
|
423
|
+
return WasmRotor.__wrap(ret);
|
|
424
|
+
}
|
|
425
|
+
/**
|
|
426
|
+
* Get inverse rotor
|
|
427
|
+
* @returns {WasmRotor}
|
|
428
|
+
*/
|
|
429
|
+
inverse() {
|
|
430
|
+
const ret = wasm.wasmmultivector_reverse(this.__wbg_ptr);
|
|
431
|
+
return WasmRotor.__wrap(ret);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
if (Symbol.dispose) WasmRotor.prototype[Symbol.dispose] = WasmRotor.prototype.free;
|
|
435
|
+
|
|
436
|
+
const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
|
|
437
|
+
|
|
438
|
+
async function __wbg_load(module, imports) {
|
|
439
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
440
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
441
|
+
try {
|
|
442
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
443
|
+
|
|
444
|
+
} catch (e) {
|
|
445
|
+
const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
|
|
446
|
+
|
|
447
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
448
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
449
|
+
|
|
450
|
+
} else {
|
|
451
|
+
throw e;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const bytes = await module.arrayBuffer();
|
|
457
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
458
|
+
|
|
459
|
+
} else {
|
|
460
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
461
|
+
|
|
462
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
463
|
+
return { instance, module };
|
|
464
|
+
|
|
465
|
+
} else {
|
|
466
|
+
return instance;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
function __wbg_get_imports() {
|
|
472
|
+
const imports = {};
|
|
473
|
+
imports.wbg = {};
|
|
474
|
+
imports.wbg.__wbg_log_6123108905c49def = function(arg0, arg1) {
|
|
475
|
+
console.log(getStringFromWasm0(arg0, arg1));
|
|
476
|
+
};
|
|
477
|
+
imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
|
|
478
|
+
throw new Error(getStringFromWasm0(arg0, arg1));
|
|
479
|
+
};
|
|
480
|
+
imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
|
|
481
|
+
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
482
|
+
const ret = getStringFromWasm0(arg0, arg1);
|
|
483
|
+
return ret;
|
|
484
|
+
};
|
|
485
|
+
imports.wbg.__wbindgen_init_externref_table = function() {
|
|
486
|
+
const table = wasm.__wbindgen_export_0;
|
|
487
|
+
const offset = table.grow(4);
|
|
488
|
+
table.set(0, undefined);
|
|
489
|
+
table.set(offset + 0, undefined);
|
|
490
|
+
table.set(offset + 1, null);
|
|
491
|
+
table.set(offset + 2, true);
|
|
492
|
+
table.set(offset + 3, false);
|
|
493
|
+
;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
return imports;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
function __wbg_init_memory(imports, memory) {
|
|
500
|
+
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
function __wbg_finalize_init(instance, module) {
|
|
504
|
+
wasm = instance.exports;
|
|
505
|
+
__wbg_init.__wbindgen_wasm_module = module;
|
|
506
|
+
cachedFloat64ArrayMemory0 = null;
|
|
507
|
+
cachedUint8ArrayMemory0 = null;
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
wasm.__wbindgen_start();
|
|
511
|
+
return wasm;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
function initSync(module) {
|
|
515
|
+
if (wasm !== undefined) return wasm;
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
if (typeof module !== 'undefined') {
|
|
519
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
520
|
+
({module} = module)
|
|
521
|
+
} else {
|
|
522
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
const imports = __wbg_get_imports();
|
|
527
|
+
|
|
528
|
+
__wbg_init_memory(imports);
|
|
529
|
+
|
|
530
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
531
|
+
module = new WebAssembly.Module(module);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
535
|
+
|
|
536
|
+
return __wbg_finalize_init(instance, module);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
async function __wbg_init(module_or_path) {
|
|
540
|
+
if (wasm !== undefined) return wasm;
|
|
541
|
+
|
|
542
|
+
|
|
543
|
+
if (typeof module_or_path !== 'undefined') {
|
|
544
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
545
|
+
({module_or_path} = module_or_path)
|
|
546
|
+
} else {
|
|
547
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
if (typeof module_or_path === 'undefined') {
|
|
552
|
+
module_or_path = new URL('amari_wasm_bg.wasm', import.meta.url);
|
|
553
|
+
}
|
|
554
|
+
const imports = __wbg_get_imports();
|
|
555
|
+
|
|
556
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
557
|
+
module_or_path = fetch(module_or_path);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
__wbg_init_memory(imports);
|
|
561
|
+
|
|
562
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
563
|
+
|
|
564
|
+
return __wbg_finalize_init(instance, module);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
export { initSync };
|
|
568
|
+
export default __wbg_init;
|
|
Binary file
|
package/package.json
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@justinelliottcobb/amari-wasm",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"collaborators": [
|
|
5
|
+
"Amari Contributors"
|
|
6
|
+
],
|
|
7
|
+
"description": "WebAssembly bindings for Amari mathematical computing library",
|
|
8
|
+
"version": "0.3.2",
|
|
9
|
+
"license": "MIT OR Apache-2.0",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/justinelliottcobb/Amari"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"amari_wasm_bg.wasm",
|
|
16
|
+
"amari_wasm.js",
|
|
17
|
+
"amari_wasm.d.ts"
|
|
18
|
+
],
|
|
19
|
+
"main": "amari_wasm.js",
|
|
20
|
+
"homepage": "https://github.com/justinelliottcobb/Amari",
|
|
21
|
+
"types": "amari_wasm.d.ts",
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./snippets/*"
|
|
24
|
+
],
|
|
25
|
+
"keywords": [
|
|
26
|
+
"wasm",
|
|
27
|
+
"webassembly",
|
|
28
|
+
"geometric-algebra",
|
|
29
|
+
"mathematics",
|
|
30
|
+
"javascript"
|
|
31
|
+
]
|
|
32
|
+
}
|