@justinelliottcobb/amari-wasm 0.9.7 → 0.9.8

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/amari_wasm.d.ts CHANGED
@@ -8,10 +8,6 @@ export function initEnumerative(): void;
8
8
  * Validate that this module loaded correctly
9
9
  */
10
10
  export function validate_relativistic_module(): boolean;
11
- /**
12
- * Calculate light deflection angle for photon grazing massive object
13
- */
14
- export function light_deflection_angle(impact_parameter: number, mass: number): number;
15
11
  /**
16
12
  * Convert velocity to Lorentz factor
17
13
  */
@@ -20,6 +16,10 @@ export function velocity_to_gamma(velocity_magnitude: number): number;
20
16
  * Convert Lorentz factor to velocity
21
17
  */
22
18
  export function gamma_to_velocity(gamma: number): number;
19
+ /**
20
+ * Calculate light deflection angle for photon grazing massive object
21
+ */
22
+ export function light_deflection_angle(impact_parameter: number, mass: number): number;
23
23
  /**
24
24
  * Initialize the WASM module
25
25
  */
@@ -899,6 +899,33 @@ export class WasmGeometricNetwork {
899
899
  */
900
900
  numNodes(): number;
901
901
  }
902
+ /**
903
+ * GPU-accelerated optimization wrapper for WASM
904
+ */
905
+ export class WasmGpuOptimizer {
906
+ free(): void;
907
+ [Symbol.dispose](): void;
908
+ /**
909
+ * Initialize GPU context for optimization
910
+ */
911
+ initializeGpu(): Promise<boolean>;
912
+ /**
913
+ * Batch optimization with parallel processing simulation
914
+ */
915
+ optimizeBatch(problems_data: Float64Array, problem_size: number, num_problems: number, max_iterations: number, tolerance: number): Promise<Float64Array>;
916
+ /**
917
+ * Check if GPU acceleration is available
918
+ */
919
+ isGpuAvailable(): boolean;
920
+ /**
921
+ * Optimize a quadratic function with GPU acceleration
922
+ */
923
+ optimizeQuadraticGpu(coefficients: Float64Array, initial_point: Float64Array, max_iterations: number, tolerance: number): Promise<WasmOptimizationResult>;
924
+ /**
925
+ * Create a new GPU optimizer
926
+ */
927
+ constructor();
928
+ }
902
929
  /**
903
930
  * WASM wrapper for Grassmannian varieties
904
931
  */
@@ -1020,6 +1047,42 @@ export class WasmMultiDualNumber {
1020
1047
  */
1021
1048
  static variable(value: number, num_vars: number, var_index: number): WasmMultiDualNumber;
1022
1049
  }
1050
+ /**
1051
+ * Simple multi-objective optimizer for WASM
1052
+ */
1053
+ export class WasmMultiObjectiveOptimizer {
1054
+ free(): void;
1055
+ [Symbol.dispose](): void;
1056
+ /**
1057
+ * Optimize a simple bi-objective problem
1058
+ * f1 = sum(x_i^2), f2 = sum((x_i - 1)^2)
1059
+ */
1060
+ optimizeBiObjective(dimension: number, population_size: number, generations: number): WasmMultiObjectiveResult;
1061
+ /**
1062
+ * Create a new multi-objective optimizer
1063
+ */
1064
+ constructor();
1065
+ }
1066
+ /**
1067
+ * Multi-objective optimization result
1068
+ */
1069
+ export class WasmMultiObjectiveResult {
1070
+ private constructor();
1071
+ free(): void;
1072
+ [Symbol.dispose](): void;
1073
+ /**
1074
+ * Get number of generations
1075
+ */
1076
+ readonly generations: number;
1077
+ /**
1078
+ * Get Pareto front as flattened array
1079
+ */
1080
+ readonly pareto_front: Float64Array;
1081
+ /**
1082
+ * Check if optimization converged
1083
+ */
1084
+ readonly converged: boolean;
1085
+ }
1023
1086
  /**
1024
1087
  * WASM wrapper for Multivector with TypedArray support
1025
1088
  */
@@ -1142,6 +1205,46 @@ export class WasmNodeMetadata {
1142
1205
  */
1143
1206
  set label(value: string | null | undefined);
1144
1207
  }
1208
+ /**
1209
+ * WASM wrapper for optimization results
1210
+ */
1211
+ export class WasmOptimizationResult {
1212
+ private constructor();
1213
+ free(): void;
1214
+ [Symbol.dispose](): void;
1215
+ /**
1216
+ * Get number of iterations
1217
+ */
1218
+ readonly iterations: number;
1219
+ /**
1220
+ * Get final objective value
1221
+ */
1222
+ readonly objective_value: number;
1223
+ /**
1224
+ * Get solution vector
1225
+ */
1226
+ readonly solution: Float64Array;
1227
+ /**
1228
+ * Check if optimization converged
1229
+ */
1230
+ readonly converged: boolean;
1231
+ }
1232
+ /**
1233
+ * Utility functions for optimization
1234
+ */
1235
+ export class WasmOptimizationUtils {
1236
+ private constructor();
1237
+ free(): void;
1238
+ [Symbol.dispose](): void;
1239
+ /**
1240
+ * Compute numerical gradient
1241
+ */
1242
+ static numericalGradient(coefficients: Float64Array, point: Float64Array, epsilon: number): Float64Array;
1243
+ /**
1244
+ * Check if a point dominates another in multi-objective optimization
1245
+ */
1246
+ static dominates(objectives1: Float64Array, objectives2: Float64Array): boolean;
1247
+ }
1145
1248
  /**
1146
1249
  * WASM wrapper for projective spaces
1147
1250
  */
@@ -1363,6 +1466,21 @@ export class WasmSensitivityMap {
1363
1466
  */
1364
1467
  getTotalSensitivity(): number;
1365
1468
  }
1469
+ /**
1470
+ * Simple quadratic optimization problem for WASM demonstration
1471
+ */
1472
+ export class WasmSimpleOptimizer {
1473
+ free(): void;
1474
+ [Symbol.dispose](): void;
1475
+ /**
1476
+ * Optimize a simple quadratic function: minimize sum(c_i * x_i^2)
1477
+ */
1478
+ optimizeQuadratic(coefficients: Float64Array, initial_point: Float64Array): WasmOptimizationResult;
1479
+ /**
1480
+ * Create a new simple optimizer
1481
+ */
1482
+ constructor();
1483
+ }
1366
1484
  /**
1367
1485
  * WASM wrapper for spacetime vectors
1368
1486
  */
@@ -1748,6 +1866,7 @@ export interface InitOutput {
1748
1866
  readonly __wbg_wasmmultidualnumber_free: (a: number, b: number) => void;
1749
1867
  readonly __wbg_wasmmultivector_free: (a: number, b: number) => void;
1750
1868
  readonly __wbg_wasmnodemetadata_free: (a: number, b: number) => void;
1869
+ readonly __wbg_wasmoptimizationresult_free: (a: number, b: number) => void;
1751
1870
  readonly __wbg_wasmprojectivespace_free: (a: number, b: number) => void;
1752
1871
  readonly __wbg_wasmpropagationanalysis_free: (a: number, b: number) => void;
1753
1872
  readonly __wbg_wasmrelativisticparticle_free: (a: number, b: number) => void;
@@ -1927,6 +2046,11 @@ export interface InitOutput {
1927
2046
  readonly wasmgeometricnetwork_spectralClustering: (a: number, b: number) => [number, number, number];
1928
2047
  readonly wasmgeometricnetwork_toTropicalNetwork: (a: number) => [number, number, number];
1929
2048
  readonly wasmgeometricnetwork_withCapacity: (a: number, b: number) => number;
2049
+ readonly wasmgpuoptimizer_initializeGpu: (a: number) => any;
2050
+ readonly wasmgpuoptimizer_isGpuAvailable: (a: number) => number;
2051
+ readonly wasmgpuoptimizer_new: () => number;
2052
+ readonly wasmgpuoptimizer_optimizeBatch: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
2053
+ readonly wasmgpuoptimizer_optimizeQuadraticGpu: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => any;
1930
2054
  readonly wasmgrassmannian_getDimension: (a: number) => number;
1931
2055
  readonly wasmgrassmannian_getParameters: (a: number) => [number, number];
1932
2056
  readonly wasmgrassmannian_new: (a: number, b: number) => [number, number, number];
@@ -1949,6 +2073,10 @@ export interface InitOutput {
1949
2073
  readonly wasmmultidualnumber_new: (a: number, b: number, c: number) => number;
1950
2074
  readonly wasmmultidualnumber_sqrt: (a: number) => [number, number, number];
1951
2075
  readonly wasmmultidualnumber_variable: (a: number, b: number, c: number) => number;
2076
+ readonly wasmmultiobjectiveoptimizer_optimizeBiObjective: (a: number, b: number, c: number, d: number) => [number, number, number];
2077
+ readonly wasmmultiobjectiveresult_converged: (a: number) => number;
2078
+ readonly wasmmultiobjectiveresult_generations: (a: number) => number;
2079
+ readonly wasmmultiobjectiveresult_pareto_front: (a: number) => [number, number];
1952
2080
  readonly wasmmultivector_add: (a: number, b: number) => number;
1953
2081
  readonly wasmmultivector_basisVector: (a: number) => [number, number, number];
1954
2082
  readonly wasmmultivector_exp: (a: number) => number;
@@ -1975,10 +2103,14 @@ export interface InitOutput {
1975
2103
  readonly wasmnodemetadata_setProperty: (a: number, b: number, c: number, d: number) => void;
1976
2104
  readonly wasmnodemetadata_set_label: (a: number, b: number, c: number) => void;
1977
2105
  readonly wasmnodemetadata_withLabel: (a: number, b: number) => number;
2106
+ readonly wasmoptimizationresult_converged: (a: number) => number;
2107
+ readonly wasmoptimizationresult_iterations: (a: number) => number;
2108
+ readonly wasmoptimizationresult_solution: (a: number) => [number, number];
2109
+ readonly wasmoptimizationutils_dominates: (a: number, b: number, c: number, d: number) => number;
2110
+ readonly wasmoptimizationutils_numericalGradient: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
1978
2111
  readonly wasmprojectivespace_bezoutIntersection: (a: number, b: number, c: number) => number;
1979
2112
  readonly wasmprojectivespace_hasDimension: (a: number, b: number) => number;
1980
2113
  readonly wasmprojectivespace_new: (a: number) => number;
1981
- readonly wasmpropagationanalysis_convergence_time: (a: number) => number;
1982
2114
  readonly wasmpropagationanalysis_coverage: (a: number) => [number, number];
1983
2115
  readonly wasmpropagationanalysis_influence_scores: (a: number) => [number, number];
1984
2116
  readonly wasmrelativisticconstants_earth_mass: () => number;
@@ -2012,6 +2144,7 @@ export interface InitOutput {
2012
2144
  readonly wasmsensitivitymap_getAllSensitivities: (a: number) => [number, number, number];
2013
2145
  readonly wasmsensitivitymap_getMostSensitive: (a: number, b: number) => [number, number];
2014
2146
  readonly wasmsensitivitymap_getTotalSensitivity: (a: number) => number;
2147
+ readonly wasmsimpleoptimizer_optimizeQuadratic: (a: number, b: number, c: number, d: number, e: number) => [number, number, number];
2015
2148
  readonly wasmspacetimevector_is_null: (a: number) => number;
2016
2149
  readonly wasmspacetimevector_is_spacelike: (a: number) => number;
2017
2150
  readonly wasmspacetimevector_is_timelike: (a: number) => number;
@@ -2051,7 +2184,6 @@ export interface InitOutput {
2051
2184
  readonly wasmtropicaldualdistribution_mostLikelySequence: (a: number, b: number) => [number, number];
2052
2185
  readonly wasmtropicaldualdistribution_new: (a: number, b: number) => number;
2053
2186
  readonly wasmtropicalnetwork_fromWeights: (a: number, b: number, c: number) => [number, number, number];
2054
- readonly wasmtropicalnetwork_getSize: (a: number) => number;
2055
2187
  readonly wasmtropicalnetwork_new: (a: number) => number;
2056
2188
  readonly wasmtropicalnetwork_setEdge: (a: number, b: number, c: number, d: number) => [number, number];
2057
2189
  readonly wasmtropicalnetwork_shortestPathTropical: (a: number, b: number, c: number) => [number, number, number];
@@ -2067,7 +2199,6 @@ export interface InitOutput {
2067
2199
  readonly wasmtropicalnumber_toProb: (a: number) => number;
2068
2200
  readonly wasmtropicalnumber_tropicalPow: (a: number, b: number) => number;
2069
2201
  readonly wasmtropicalnumber_zero: () => number;
2070
- readonly wasmtropicalpolynomial_coefficients_count: (a: number) => number;
2071
2202
  readonly wasmtropicalpolynomial_evaluate: (a: number, b: number) => number;
2072
2203
  readonly wasmtropicalpolynomial_new: (a: number, b: number) => number;
2073
2204
  readonly wasmtropicalpolynomial_tropical_roots: (a: number) => any;
@@ -2079,6 +2210,7 @@ export interface InitOutput {
2079
2210
  readonly wasmspacetimevector_t: (a: number) => number;
2080
2211
  readonly wasmtropicalnumber_tropicalMul: (a: number, b: number) => number;
2081
2212
  readonly wasmtrajectorypoint_position: (a: number) => number;
2213
+ readonly wasmtropicalpolynomial_coefficients_count: (a: number) => number;
2082
2214
  readonly wasmtropicalnumber_tropicalAdd: (a: number, b: number) => number;
2083
2215
  readonly wasmcommunity_cohesion_score: (a: number) => number;
2084
2216
  readonly wasmdualnumber_getReal: (a: number) => number;
@@ -2086,12 +2218,15 @@ export interface InitOutput {
2086
2218
  readonly wasmevaluationresult_getGradientNorm: (a: number) => number;
2087
2219
  readonly wasmgeometricedge_weight: (a: number) => number;
2088
2220
  readonly wasmmultidualnumber_getReal: (a: number) => number;
2221
+ readonly wasmoptimizationresult_objective_value: (a: number) => number;
2089
2222
  readonly wasmprojectivespace_getDimension: (a: number) => number;
2223
+ readonly wasmpropagationanalysis_convergence_time: (a: number) => number;
2090
2224
  readonly wasmschwarzschildmetric_mass: (a: number) => number;
2091
2225
  readonly wasmspacetimevector_x: (a: number) => number;
2092
2226
  readonly wasmspacetimevector_y: (a: number) => number;
2093
2227
  readonly wasmspacetimevector_z: (a: number) => number;
2094
2228
  readonly wasmtropicalcurve_getGenus: (a: number) => number;
2229
+ readonly wasmtropicalnetwork_getSize: (a: number) => number;
2095
2230
  readonly wasmtropicalnumber_getValue: (a: number) => number;
2096
2231
  readonly __wbg_automatabatchoperations_free: (a: number, b: number) => void;
2097
2232
  readonly __wbg_automatautils_free: (a: number, b: number) => void;
@@ -2110,18 +2245,28 @@ export interface InitOutput {
2110
2245
  readonly __wbg_wasmdualnumber_free: (a: number, b: number) => void;
2111
2246
  readonly __wbg_wasmfourvelocity_free: (a: number, b: number) => void;
2112
2247
  readonly __wbg_wasmgeometricedge_free: (a: number, b: number) => void;
2248
+ readonly __wbg_wasmgpuoptimizer_free: (a: number, b: number) => void;
2249
+ readonly __wbg_wasmmultiobjectiveoptimizer_free: (a: number, b: number) => void;
2250
+ readonly __wbg_wasmoptimizationutils_free: (a: number, b: number) => void;
2113
2251
  readonly __wbg_wasmrelativisticconstants_free: (a: number, b: number) => void;
2252
+ readonly __wbg_wasmsimpleoptimizer_free: (a: number, b: number) => void;
2114
2253
  readonly __wbg_wasmspacetimevector_free: (a: number, b: number) => void;
2115
2254
  readonly __wbg_wasmtropicalcurve_free: (a: number, b: number) => void;
2116
2255
  readonly __wbg_wasmtropicalnumber_free: (a: number, b: number) => void;
2256
+ readonly __wbg_wasmmultiobjectiveresult_free: (a: number, b: number) => void;
2117
2257
  readonly wasmrotor_inverse: (a: number) => number;
2118
2258
  readonly __wbg_wasmrotor_free: (a: number, b: number) => void;
2259
+ readonly wasmmultiobjectiveoptimizer_new: () => number;
2260
+ readonly wasmsimpleoptimizer_new: () => number;
2261
+ readonly wasm_bindgen__convert__closures_____invoke__hce8272eee2f071c2: (a: number, b: number, c: any) => void;
2262
+ readonly wasm_bindgen__closure__destroy__h2186110628e4ed68: (a: number, b: number) => void;
2263
+ readonly wasm_bindgen__convert__closures_____invoke__h4ca4ba3872354ffe: (a: number, b: number, c: any, d: any) => void;
2264
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
2265
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
2119
2266
  readonly __wbindgen_exn_store: (a: number) => void;
2120
2267
  readonly __externref_table_alloc: () => number;
2121
- readonly __wbindgen_export_2: WebAssembly.Table;
2268
+ readonly __wbindgen_externrefs: WebAssembly.Table;
2122
2269
  readonly __wbindgen_free: (a: number, b: number, c: number) => void;
2123
- readonly __wbindgen_malloc: (a: number, b: number) => number;
2124
- readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
2125
2270
  readonly __externref_table_dealloc: (a: number) => void;
2126
2271
  readonly __wbindgen_start: () => void;
2127
2272
  }
package/amari_wasm.js CHANGED
@@ -1,20 +1,72 @@
1
1
  let wasm;
2
2
 
3
- function addToExternrefTable0(obj) {
4
- const idx = wasm.__externref_table_alloc();
5
- wasm.__wbindgen_export_2.set(idx, obj);
6
- return idx;
7
- }
8
-
9
- function handleError(f, args) {
10
- try {
11
- return f.apply(this, args);
12
- } catch (e) {
13
- const idx = addToExternrefTable0(e);
14
- wasm.__wbindgen_exn_store(idx);
3
+ function debugString(val) {
4
+ // primitive types
5
+ const type = typeof val;
6
+ if (type == 'number' || type == 'boolean' || val == null) {
7
+ return `${val}`;
8
+ }
9
+ if (type == 'string') {
10
+ return `"${val}"`;
11
+ }
12
+ if (type == 'symbol') {
13
+ const description = val.description;
14
+ if (description == null) {
15
+ return 'Symbol';
16
+ } else {
17
+ return `Symbol(${description})`;
18
+ }
19
+ }
20
+ if (type == 'function') {
21
+ const name = val.name;
22
+ if (typeof name == 'string' && name.length > 0) {
23
+ return `Function(${name})`;
24
+ } else {
25
+ return 'Function';
26
+ }
27
+ }
28
+ // objects
29
+ if (Array.isArray(val)) {
30
+ const length = val.length;
31
+ let debug = '[';
32
+ if (length > 0) {
33
+ debug += debugString(val[0]);
34
+ }
35
+ for(let i = 1; i < length; i++) {
36
+ debug += ', ' + debugString(val[i]);
37
+ }
38
+ debug += ']';
39
+ return debug;
40
+ }
41
+ // Test for built-in
42
+ const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
43
+ let className;
44
+ if (builtInMatches && builtInMatches.length > 1) {
45
+ className = builtInMatches[1];
46
+ } else {
47
+ // Failed to match the standard '[object ClassName]'
48
+ return toString.call(val);
15
49
  }
50
+ if (className == 'Object') {
51
+ // we're a user defined class or Object
52
+ // JSON.stringify avoids problems with cycles, and is generally much
53
+ // easier than looping through ownProperties of `val`.
54
+ try {
55
+ return 'Object(' + JSON.stringify(val) + ')';
56
+ } catch (_) {
57
+ return 'Object';
58
+ }
59
+ }
60
+ // errors
61
+ if (val instanceof Error) {
62
+ return `${val.name}: ${val.message}\n${val.stack}`;
63
+ }
64
+ // TODO we could test for more things here, like `Set`s and `Map`s.
65
+ return className;
16
66
  }
17
67
 
68
+ let WASM_VECTOR_LEN = 0;
69
+
18
70
  let cachedUint8ArrayMemory0 = null;
19
71
 
20
72
  function getUint8ArrayMemory0() {
@@ -24,29 +76,6 @@ function getUint8ArrayMemory0() {
24
76
  return cachedUint8ArrayMemory0;
25
77
  }
26
78
 
27
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
28
-
29
- cachedTextDecoder.decode();
30
-
31
- const MAX_SAFARI_DECODE_BYTES = 2146435072;
32
- let numBytesDecoded = 0;
33
- function decodeText(ptr, len) {
34
- numBytesDecoded += len;
35
- if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
36
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
37
- cachedTextDecoder.decode();
38
- numBytesDecoded = len;
39
- }
40
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
41
- }
42
-
43
- function getStringFromWasm0(ptr, len) {
44
- ptr = ptr >>> 0;
45
- return decodeText(ptr, len);
46
- }
47
-
48
- let WASM_VECTOR_LEN = 0;
49
-
50
79
  const cachedTextEncoder = new TextEncoder();
51
80
 
52
81
  if (!('encodeInto' in cachedTextEncoder)) {
@@ -108,73 +137,90 @@ function getDataViewMemory0() {
108
137
  return cachedDataViewMemory0;
109
138
  }
110
139
 
111
- function debugString(val) {
112
- // primitive types
113
- const type = typeof val;
114
- if (type == 'number' || type == 'boolean' || val == null) {
115
- return `${val}`;
116
- }
117
- if (type == 'string') {
118
- return `"${val}"`;
119
- }
120
- if (type == 'symbol') {
121
- const description = val.description;
122
- if (description == null) {
123
- return 'Symbol';
124
- } else {
125
- return `Symbol(${description})`;
126
- }
127
- }
128
- if (type == 'function') {
129
- const name = val.name;
130
- if (typeof name == 'string' && name.length > 0) {
131
- return `Function(${name})`;
132
- } else {
133
- return 'Function';
134
- }
135
- }
136
- // objects
137
- if (Array.isArray(val)) {
138
- const length = val.length;
139
- let debug = '[';
140
- if (length > 0) {
141
- debug += debugString(val[0]);
142
- }
143
- for(let i = 1; i < length; i++) {
144
- debug += ', ' + debugString(val[i]);
145
- }
146
- debug += ']';
147
- return debug;
140
+ function isLikeNone(x) {
141
+ return x === undefined || x === null;
142
+ }
143
+
144
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
145
+
146
+ cachedTextDecoder.decode();
147
+
148
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
149
+ let numBytesDecoded = 0;
150
+ function decodeText(ptr, len) {
151
+ numBytesDecoded += len;
152
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
153
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
154
+ cachedTextDecoder.decode();
155
+ numBytesDecoded = len;
148
156
  }
149
- // Test for built-in
150
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
151
- let className;
152
- if (builtInMatches && builtInMatches.length > 1) {
153
- className = builtInMatches[1];
154
- } else {
155
- // Failed to match the standard '[object ClassName]'
156
- return toString.call(val);
157
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
158
+ }
159
+
160
+ function getStringFromWasm0(ptr, len) {
161
+ ptr = ptr >>> 0;
162
+ return decodeText(ptr, len);
163
+ }
164
+
165
+ function addToExternrefTable0(obj) {
166
+ const idx = wasm.__externref_table_alloc();
167
+ wasm.__wbindgen_externrefs.set(idx, obj);
168
+ return idx;
169
+ }
170
+
171
+ function handleError(f, args) {
172
+ try {
173
+ return f.apply(this, args);
174
+ } catch (e) {
175
+ const idx = addToExternrefTable0(e);
176
+ wasm.__wbindgen_exn_store(idx);
157
177
  }
158
- if (className == 'Object') {
159
- // we're a user defined class or Object
160
- // JSON.stringify avoids problems with cycles, and is generally much
161
- // easier than looping through ownProperties of `val`.
178
+ }
179
+
180
+ const CLOSURE_DTORS = (typeof FinalizationRegistry === 'undefined')
181
+ ? { register: () => {}, unregister: () => {} }
182
+ : new FinalizationRegistry(state => state.dtor(state.a, state.b));
183
+
184
+ function makeMutClosure(arg0, arg1, dtor, f) {
185
+ const state = { a: arg0, b: arg1, cnt: 1, dtor };
186
+ const real = (...args) => {
187
+
188
+ // First up with a closure we increment the internal reference
189
+ // count. This ensures that the Rust closure environment won't
190
+ // be deallocated while we're invoking it.
191
+ state.cnt++;
192
+ const a = state.a;
193
+ state.a = 0;
162
194
  try {
163
- return 'Object(' + JSON.stringify(val) + ')';
164
- } catch (_) {
165
- return 'Object';
195
+ return f(a, state.b, ...args);
196
+ } finally {
197
+ state.a = a;
198
+ real._wbg_cb_unref();
166
199
  }
200
+ };
201
+ real._wbg_cb_unref = () => {
202
+ if (--state.cnt === 0) {
203
+ state.dtor(state.a, state.b);
204
+ state.a = 0;
205
+ CLOSURE_DTORS.unregister(state);
206
+ }
207
+ };
208
+ CLOSURE_DTORS.register(real, state, state);
209
+ return real;
210
+ }
211
+
212
+ let cachedFloat64ArrayMemory0 = null;
213
+
214
+ function getFloat64ArrayMemory0() {
215
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
216
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
167
217
  }
168
- // errors
169
- if (val instanceof Error) {
170
- return `${val.name}: ${val.message}\n${val.stack}`;
171
- }
172
- // TODO we could test for more things here, like `Set`s and `Map`s.
173
- return className;
218
+ return cachedFloat64ArrayMemory0;
174
219
  }
175
220
 
176
- function isLikeNone(x) {
177
- return x === undefined || x === null;
221
+ function getArrayF64FromWasm0(ptr, len) {
222
+ ptr = ptr >>> 0;
223
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
178
224
  }
179
225
 
180
226
  function _assertClass(instance, klass) {
@@ -200,25 +246,11 @@ function passArray32ToWasm0(arg, malloc) {
200
246
  }
201
247
 
202
248
  function takeFromExternrefTable0(idx) {
203
- const value = wasm.__wbindgen_export_2.get(idx);
249
+ const value = wasm.__wbindgen_externrefs.get(idx);
204
250
  wasm.__externref_table_dealloc(idx);
205
251
  return value;
206
252
  }
207
253
 
208
- let cachedFloat64ArrayMemory0 = null;
209
-
210
- function getFloat64ArrayMemory0() {
211
- if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
212
- cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
213
- }
214
- return cachedFloat64ArrayMemory0;
215
- }
216
-
217
- function getArrayF64FromWasm0(ptr, len) {
218
- ptr = ptr >>> 0;
219
- return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
220
- }
221
-
222
254
  function getArrayU32FromWasm0(ptr, len) {
223
255
  ptr = ptr >>> 0;
224
256
  return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
@@ -230,6 +262,12 @@ export function initEnumerative() {
230
262
  wasm.initEnumerative();
231
263
  }
232
264
 
265
+ function passArrayF64ToWasm0(arg, malloc) {
266
+ const ptr = malloc(arg.length * 8, 8) >>> 0;
267
+ getFloat64ArrayMemory0().set(arg, ptr / 8);
268
+ WASM_VECTOR_LEN = arg.length;
269
+ return ptr;
270
+ }
233
271
  /**
234
272
  * Validate that this module loaded correctly
235
273
  * @returns {boolean}
@@ -239,17 +277,6 @@ export function validate_relativistic_module() {
239
277
  return ret !== 0;
240
278
  }
241
279
 
242
- /**
243
- * Calculate light deflection angle for photon grazing massive object
244
- * @param {number} impact_parameter
245
- * @param {number} mass
246
- * @returns {number}
247
- */
248
- export function light_deflection_angle(impact_parameter, mass) {
249
- const ret = wasm.light_deflection_angle(impact_parameter, mass);
250
- return ret;
251
- }
252
-
253
280
  /**
254
281
  * Convert velocity to Lorentz factor
255
282
  * @param {number} velocity_magnitude
@@ -276,12 +303,17 @@ export function gamma_to_velocity(gamma) {
276
303
  return ret[0];
277
304
  }
278
305
 
279
- function passArrayF64ToWasm0(arg, malloc) {
280
- const ptr = malloc(arg.length * 8, 8) >>> 0;
281
- getFloat64ArrayMemory0().set(arg, ptr / 8);
282
- WASM_VECTOR_LEN = arg.length;
283
- return ptr;
306
+ /**
307
+ * Calculate light deflection angle for photon grazing massive object
308
+ * @param {number} impact_parameter
309
+ * @param {number} mass
310
+ * @returns {number}
311
+ */
312
+ export function light_deflection_angle(impact_parameter, mass) {
313
+ const ret = wasm.light_deflection_angle(impact_parameter, mass);
314
+ return ret;
284
315
  }
316
+
285
317
  /**
286
318
  * Initialize the WASM module
287
319
  */
@@ -307,6 +339,13 @@ function getArrayU8FromWasm0(ptr, len) {
307
339
  ptr = ptr >>> 0;
308
340
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
309
341
  }
342
+ function wasm_bindgen__convert__closures_____invoke__hce8272eee2f071c2(arg0, arg1, arg2) {
343
+ wasm.wasm_bindgen__convert__closures_____invoke__hce8272eee2f071c2(arg0, arg1, arg2);
344
+ }
345
+
346
+ function wasm_bindgen__convert__closures_____invoke__h4ca4ba3872354ffe(arg0, arg1, arg2, arg3) {
347
+ wasm.wasm_bindgen__convert__closures_____invoke__h4ca4ba3872354ffe(arg0, arg1, arg2, arg3);
348
+ }
310
349
 
311
350
  const AutoDiffFinalization = (typeof FinalizationRegistry === 'undefined')
312
351
  ? { register: () => {}, unregister: () => {} }
@@ -2948,7 +2987,85 @@ export class WasmGeometricNetwork {
2948
2987
  return ret >>> 0;
2949
2988
  }
2950
2989
  }
2951
- if (Symbol.dispose) WasmGeometricNetwork.prototype[Symbol.dispose] = WasmGeometricNetwork.prototype.free;
2990
+ if (Symbol.dispose) WasmGeometricNetwork.prototype[Symbol.dispose] = WasmGeometricNetwork.prototype.free;
2991
+
2992
+ const WasmGpuOptimizerFinalization = (typeof FinalizationRegistry === 'undefined')
2993
+ ? { register: () => {}, unregister: () => {} }
2994
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmgpuoptimizer_free(ptr >>> 0, 1));
2995
+ /**
2996
+ * GPU-accelerated optimization wrapper for WASM
2997
+ */
2998
+ export class WasmGpuOptimizer {
2999
+
3000
+ __destroy_into_raw() {
3001
+ const ptr = this.__wbg_ptr;
3002
+ this.__wbg_ptr = 0;
3003
+ WasmGpuOptimizerFinalization.unregister(this);
3004
+ return ptr;
3005
+ }
3006
+
3007
+ free() {
3008
+ const ptr = this.__destroy_into_raw();
3009
+ wasm.__wbg_wasmgpuoptimizer_free(ptr, 0);
3010
+ }
3011
+ /**
3012
+ * Initialize GPU context for optimization
3013
+ * @returns {Promise<boolean>}
3014
+ */
3015
+ initializeGpu() {
3016
+ const ret = wasm.wasmgpuoptimizer_initializeGpu(this.__wbg_ptr);
3017
+ return ret;
3018
+ }
3019
+ /**
3020
+ * Batch optimization with parallel processing simulation
3021
+ * @param {Float64Array} problems_data
3022
+ * @param {number} problem_size
3023
+ * @param {number} num_problems
3024
+ * @param {number} max_iterations
3025
+ * @param {number} tolerance
3026
+ * @returns {Promise<Float64Array>}
3027
+ */
3028
+ optimizeBatch(problems_data, problem_size, num_problems, max_iterations, tolerance) {
3029
+ const ptr0 = passArrayF64ToWasm0(problems_data, wasm.__wbindgen_malloc);
3030
+ const len0 = WASM_VECTOR_LEN;
3031
+ const ret = wasm.wasmgpuoptimizer_optimizeBatch(this.__wbg_ptr, ptr0, len0, problem_size, num_problems, max_iterations, tolerance);
3032
+ return ret;
3033
+ }
3034
+ /**
3035
+ * Check if GPU acceleration is available
3036
+ * @returns {boolean}
3037
+ */
3038
+ isGpuAvailable() {
3039
+ const ret = wasm.wasmgpuoptimizer_isGpuAvailable(this.__wbg_ptr);
3040
+ return ret !== 0;
3041
+ }
3042
+ /**
3043
+ * Optimize a quadratic function with GPU acceleration
3044
+ * @param {Float64Array} coefficients
3045
+ * @param {Float64Array} initial_point
3046
+ * @param {number} max_iterations
3047
+ * @param {number} tolerance
3048
+ * @returns {Promise<WasmOptimizationResult>}
3049
+ */
3050
+ optimizeQuadraticGpu(coefficients, initial_point, max_iterations, tolerance) {
3051
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
3052
+ const len0 = WASM_VECTOR_LEN;
3053
+ const ptr1 = passArrayF64ToWasm0(initial_point, wasm.__wbindgen_malloc);
3054
+ const len1 = WASM_VECTOR_LEN;
3055
+ const ret = wasm.wasmgpuoptimizer_optimizeQuadraticGpu(this.__wbg_ptr, ptr0, len0, ptr1, len1, max_iterations, tolerance);
3056
+ return ret;
3057
+ }
3058
+ /**
3059
+ * Create a new GPU optimizer
3060
+ */
3061
+ constructor() {
3062
+ const ret = wasm.wasmgpuoptimizer_new();
3063
+ this.__wbg_ptr = ret >>> 0;
3064
+ WasmGpuOptimizerFinalization.register(this, this.__wbg_ptr, this);
3065
+ return this;
3066
+ }
3067
+ }
3068
+ if (Symbol.dispose) WasmGpuOptimizer.prototype[Symbol.dispose] = WasmGpuOptimizer.prototype.free;
2952
3069
 
2953
3070
  const WasmGrassmannianFinalization = (typeof FinalizationRegistry === 'undefined')
2954
3071
  ? { register: () => {}, unregister: () => {} }
@@ -3299,6 +3416,108 @@ export class WasmMultiDualNumber {
3299
3416
  }
3300
3417
  if (Symbol.dispose) WasmMultiDualNumber.prototype[Symbol.dispose] = WasmMultiDualNumber.prototype.free;
3301
3418
 
3419
+ const WasmMultiObjectiveOptimizerFinalization = (typeof FinalizationRegistry === 'undefined')
3420
+ ? { register: () => {}, unregister: () => {} }
3421
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultiobjectiveoptimizer_free(ptr >>> 0, 1));
3422
+ /**
3423
+ * Simple multi-objective optimizer for WASM
3424
+ */
3425
+ export class WasmMultiObjectiveOptimizer {
3426
+
3427
+ __destroy_into_raw() {
3428
+ const ptr = this.__wbg_ptr;
3429
+ this.__wbg_ptr = 0;
3430
+ WasmMultiObjectiveOptimizerFinalization.unregister(this);
3431
+ return ptr;
3432
+ }
3433
+
3434
+ free() {
3435
+ const ptr = this.__destroy_into_raw();
3436
+ wasm.__wbg_wasmmultiobjectiveoptimizer_free(ptr, 0);
3437
+ }
3438
+ /**
3439
+ * Optimize a simple bi-objective problem
3440
+ * f1 = sum(x_i^2), f2 = sum((x_i - 1)^2)
3441
+ * @param {number} dimension
3442
+ * @param {number} population_size
3443
+ * @param {number} generations
3444
+ * @returns {WasmMultiObjectiveResult}
3445
+ */
3446
+ optimizeBiObjective(dimension, population_size, generations) {
3447
+ const ret = wasm.wasmmultiobjectiveoptimizer_optimizeBiObjective(this.__wbg_ptr, dimension, population_size, generations);
3448
+ if (ret[2]) {
3449
+ throw takeFromExternrefTable0(ret[1]);
3450
+ }
3451
+ return WasmMultiObjectiveResult.__wrap(ret[0]);
3452
+ }
3453
+ /**
3454
+ * Create a new multi-objective optimizer
3455
+ */
3456
+ constructor() {
3457
+ const ret = wasm.wasmgpuoptimizer_new();
3458
+ this.__wbg_ptr = ret >>> 0;
3459
+ WasmMultiObjectiveOptimizerFinalization.register(this, this.__wbg_ptr, this);
3460
+ return this;
3461
+ }
3462
+ }
3463
+ if (Symbol.dispose) WasmMultiObjectiveOptimizer.prototype[Symbol.dispose] = WasmMultiObjectiveOptimizer.prototype.free;
3464
+
3465
+ const WasmMultiObjectiveResultFinalization = (typeof FinalizationRegistry === 'undefined')
3466
+ ? { register: () => {}, unregister: () => {} }
3467
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultiobjectiveresult_free(ptr >>> 0, 1));
3468
+ /**
3469
+ * Multi-objective optimization result
3470
+ */
3471
+ export class WasmMultiObjectiveResult {
3472
+
3473
+ static __wrap(ptr) {
3474
+ ptr = ptr >>> 0;
3475
+ const obj = Object.create(WasmMultiObjectiveResult.prototype);
3476
+ obj.__wbg_ptr = ptr;
3477
+ WasmMultiObjectiveResultFinalization.register(obj, obj.__wbg_ptr, obj);
3478
+ return obj;
3479
+ }
3480
+
3481
+ __destroy_into_raw() {
3482
+ const ptr = this.__wbg_ptr;
3483
+ this.__wbg_ptr = 0;
3484
+ WasmMultiObjectiveResultFinalization.unregister(this);
3485
+ return ptr;
3486
+ }
3487
+
3488
+ free() {
3489
+ const ptr = this.__destroy_into_raw();
3490
+ wasm.__wbg_wasmmultiobjectiveresult_free(ptr, 0);
3491
+ }
3492
+ /**
3493
+ * Get number of generations
3494
+ * @returns {number}
3495
+ */
3496
+ get generations() {
3497
+ const ret = wasm.wasmmultiobjectiveresult_generations(this.__wbg_ptr);
3498
+ return ret >>> 0;
3499
+ }
3500
+ /**
3501
+ * Get Pareto front as flattened array
3502
+ * @returns {Float64Array}
3503
+ */
3504
+ get pareto_front() {
3505
+ const ret = wasm.wasmmultiobjectiveresult_pareto_front(this.__wbg_ptr);
3506
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3507
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3508
+ return v1;
3509
+ }
3510
+ /**
3511
+ * Check if optimization converged
3512
+ * @returns {boolean}
3513
+ */
3514
+ get converged() {
3515
+ const ret = wasm.wasmmultiobjectiveresult_converged(this.__wbg_ptr);
3516
+ return ret !== 0;
3517
+ }
3518
+ }
3519
+ if (Symbol.dispose) WasmMultiObjectiveResult.prototype[Symbol.dispose] = WasmMultiObjectiveResult.prototype.free;
3520
+
3302
3521
  const WasmMultivectorFinalization = (typeof FinalizationRegistry === 'undefined')
3303
3522
  ? { register: () => {}, unregister: () => {} }
3304
3523
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmmultivector_free(ptr >>> 0, 1));
@@ -3625,6 +3844,126 @@ export class WasmNodeMetadata {
3625
3844
  }
3626
3845
  if (Symbol.dispose) WasmNodeMetadata.prototype[Symbol.dispose] = WasmNodeMetadata.prototype.free;
3627
3846
 
3847
+ const WasmOptimizationResultFinalization = (typeof FinalizationRegistry === 'undefined')
3848
+ ? { register: () => {}, unregister: () => {} }
3849
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmoptimizationresult_free(ptr >>> 0, 1));
3850
+ /**
3851
+ * WASM wrapper for optimization results
3852
+ */
3853
+ export class WasmOptimizationResult {
3854
+
3855
+ static __wrap(ptr) {
3856
+ ptr = ptr >>> 0;
3857
+ const obj = Object.create(WasmOptimizationResult.prototype);
3858
+ obj.__wbg_ptr = ptr;
3859
+ WasmOptimizationResultFinalization.register(obj, obj.__wbg_ptr, obj);
3860
+ return obj;
3861
+ }
3862
+
3863
+ __destroy_into_raw() {
3864
+ const ptr = this.__wbg_ptr;
3865
+ this.__wbg_ptr = 0;
3866
+ WasmOptimizationResultFinalization.unregister(this);
3867
+ return ptr;
3868
+ }
3869
+
3870
+ free() {
3871
+ const ptr = this.__destroy_into_raw();
3872
+ wasm.__wbg_wasmoptimizationresult_free(ptr, 0);
3873
+ }
3874
+ /**
3875
+ * Get number of iterations
3876
+ * @returns {number}
3877
+ */
3878
+ get iterations() {
3879
+ const ret = wasm.wasmoptimizationresult_iterations(this.__wbg_ptr);
3880
+ return ret >>> 0;
3881
+ }
3882
+ /**
3883
+ * Get final objective value
3884
+ * @returns {number}
3885
+ */
3886
+ get objective_value() {
3887
+ const ret = wasm.wasmalphaconnection_getAlpha(this.__wbg_ptr);
3888
+ return ret;
3889
+ }
3890
+ /**
3891
+ * Get solution vector
3892
+ * @returns {Float64Array}
3893
+ */
3894
+ get solution() {
3895
+ const ret = wasm.wasmoptimizationresult_solution(this.__wbg_ptr);
3896
+ var v1 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3897
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3898
+ return v1;
3899
+ }
3900
+ /**
3901
+ * Check if optimization converged
3902
+ * @returns {boolean}
3903
+ */
3904
+ get converged() {
3905
+ const ret = wasm.wasmoptimizationresult_converged(this.__wbg_ptr);
3906
+ return ret !== 0;
3907
+ }
3908
+ }
3909
+ if (Symbol.dispose) WasmOptimizationResult.prototype[Symbol.dispose] = WasmOptimizationResult.prototype.free;
3910
+
3911
+ const WasmOptimizationUtilsFinalization = (typeof FinalizationRegistry === 'undefined')
3912
+ ? { register: () => {}, unregister: () => {} }
3913
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmoptimizationutils_free(ptr >>> 0, 1));
3914
+ /**
3915
+ * Utility functions for optimization
3916
+ */
3917
+ export class WasmOptimizationUtils {
3918
+
3919
+ __destroy_into_raw() {
3920
+ const ptr = this.__wbg_ptr;
3921
+ this.__wbg_ptr = 0;
3922
+ WasmOptimizationUtilsFinalization.unregister(this);
3923
+ return ptr;
3924
+ }
3925
+
3926
+ free() {
3927
+ const ptr = this.__destroy_into_raw();
3928
+ wasm.__wbg_wasmoptimizationutils_free(ptr, 0);
3929
+ }
3930
+ /**
3931
+ * Compute numerical gradient
3932
+ * @param {Float64Array} coefficients
3933
+ * @param {Float64Array} point
3934
+ * @param {number} epsilon
3935
+ * @returns {Float64Array}
3936
+ */
3937
+ static numericalGradient(coefficients, point, epsilon) {
3938
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
3939
+ const len0 = WASM_VECTOR_LEN;
3940
+ const ptr1 = passArrayF64ToWasm0(point, wasm.__wbindgen_malloc);
3941
+ const len1 = WASM_VECTOR_LEN;
3942
+ const ret = wasm.wasmoptimizationutils_numericalGradient(ptr0, len0, ptr1, len1, epsilon);
3943
+ if (ret[3]) {
3944
+ throw takeFromExternrefTable0(ret[2]);
3945
+ }
3946
+ var v3 = getArrayF64FromWasm0(ret[0], ret[1]).slice();
3947
+ wasm.__wbindgen_free(ret[0], ret[1] * 8, 8);
3948
+ return v3;
3949
+ }
3950
+ /**
3951
+ * Check if a point dominates another in multi-objective optimization
3952
+ * @param {Float64Array} objectives1
3953
+ * @param {Float64Array} objectives2
3954
+ * @returns {boolean}
3955
+ */
3956
+ static dominates(objectives1, objectives2) {
3957
+ const ptr0 = passArrayF64ToWasm0(objectives1, wasm.__wbindgen_malloc);
3958
+ const len0 = WASM_VECTOR_LEN;
3959
+ const ptr1 = passArrayF64ToWasm0(objectives2, wasm.__wbindgen_malloc);
3960
+ const len1 = WASM_VECTOR_LEN;
3961
+ const ret = wasm.wasmoptimizationutils_dominates(ptr0, len0, ptr1, len1);
3962
+ return ret !== 0;
3963
+ }
3964
+ }
3965
+ if (Symbol.dispose) WasmOptimizationUtils.prototype[Symbol.dispose] = WasmOptimizationUtils.prototype.free;
3966
+
3628
3967
  const WasmProjectiveSpaceFinalization = (typeof FinalizationRegistry === 'undefined')
3629
3968
  ? { register: () => {}, unregister: () => {} }
3630
3969
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmprojectivespace_free(ptr >>> 0, 1));
@@ -3716,7 +4055,7 @@ export class WasmPropagationAnalysis {
3716
4055
  * @returns {number}
3717
4056
  */
3718
4057
  get convergenceTime() {
3719
- const ret = wasm.wasmpropagationanalysis_convergence_time(this.__wbg_ptr);
4058
+ const ret = wasm.wasmoptimizationresult_iterations(this.__wbg_ptr);
3720
4059
  return ret >>> 0;
3721
4060
  }
3722
4061
  /**
@@ -4228,6 +4567,54 @@ export class WasmSensitivityMap {
4228
4567
  }
4229
4568
  if (Symbol.dispose) WasmSensitivityMap.prototype[Symbol.dispose] = WasmSensitivityMap.prototype.free;
4230
4569
 
4570
+ const WasmSimpleOptimizerFinalization = (typeof FinalizationRegistry === 'undefined')
4571
+ ? { register: () => {}, unregister: () => {} }
4572
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmsimpleoptimizer_free(ptr >>> 0, 1));
4573
+ /**
4574
+ * Simple quadratic optimization problem for WASM demonstration
4575
+ */
4576
+ export class WasmSimpleOptimizer {
4577
+
4578
+ __destroy_into_raw() {
4579
+ const ptr = this.__wbg_ptr;
4580
+ this.__wbg_ptr = 0;
4581
+ WasmSimpleOptimizerFinalization.unregister(this);
4582
+ return ptr;
4583
+ }
4584
+
4585
+ free() {
4586
+ const ptr = this.__destroy_into_raw();
4587
+ wasm.__wbg_wasmsimpleoptimizer_free(ptr, 0);
4588
+ }
4589
+ /**
4590
+ * Optimize a simple quadratic function: minimize sum(c_i * x_i^2)
4591
+ * @param {Float64Array} coefficients
4592
+ * @param {Float64Array} initial_point
4593
+ * @returns {WasmOptimizationResult}
4594
+ */
4595
+ optimizeQuadratic(coefficients, initial_point) {
4596
+ const ptr0 = passArrayF64ToWasm0(coefficients, wasm.__wbindgen_malloc);
4597
+ const len0 = WASM_VECTOR_LEN;
4598
+ const ptr1 = passArrayF64ToWasm0(initial_point, wasm.__wbindgen_malloc);
4599
+ const len1 = WASM_VECTOR_LEN;
4600
+ const ret = wasm.wasmsimpleoptimizer_optimizeQuadratic(this.__wbg_ptr, ptr0, len0, ptr1, len1);
4601
+ if (ret[2]) {
4602
+ throw takeFromExternrefTable0(ret[1]);
4603
+ }
4604
+ return WasmOptimizationResult.__wrap(ret[0]);
4605
+ }
4606
+ /**
4607
+ * Create a new simple optimizer
4608
+ */
4609
+ constructor() {
4610
+ const ret = wasm.wasmgpuoptimizer_new();
4611
+ this.__wbg_ptr = ret >>> 0;
4612
+ WasmSimpleOptimizerFinalization.register(this, this.__wbg_ptr, this);
4613
+ return this;
4614
+ }
4615
+ }
4616
+ if (Symbol.dispose) WasmSimpleOptimizer.prototype[Symbol.dispose] = WasmSimpleOptimizer.prototype.free;
4617
+
4231
4618
  const WasmSpacetimeVectorFinalization = (typeof FinalizationRegistry === 'undefined')
4232
4619
  ? { register: () => {}, unregister: () => {} }
4233
4620
  : new FinalizationRegistry(ptr => wasm.__wbg_wasmspacetimevector_free(ptr >>> 0, 1));
@@ -4883,7 +5270,7 @@ export class WasmTropicalNetwork {
4883
5270
  * @returns {number}
4884
5271
  */
4885
5272
  getSize() {
4886
- const ret = wasm.wasmtropicalnetwork_getSize(this.__wbg_ptr);
5273
+ const ret = wasm.wasmmultiobjectiveresult_generations(this.__wbg_ptr);
4887
5274
  return ret >>> 0;
4888
5275
  }
4889
5276
  /**
@@ -5095,7 +5482,7 @@ export class WasmTropicalPolynomial {
5095
5482
  * @returns {number}
5096
5483
  */
5097
5484
  coefficients_count() {
5098
- const ret = wasm.wasmtropicalpolynomial_coefficients_count(this.__wbg_ptr);
5485
+ const ret = wasm.wasmgpuoptimizer_isGpuAvailable(this.__wbg_ptr);
5099
5486
  return ret >>> 0;
5100
5487
  }
5101
5488
  /**
@@ -5231,10 +5618,45 @@ async function __wbg_load(module, imports) {
5231
5618
  function __wbg_get_imports() {
5232
5619
  const imports = {};
5233
5620
  imports.wbg = {};
5234
- imports.wbg.__wbg_apply_dc50eb58583d2a57 = function() { return handleError(function (arg0, arg1, arg2) {
5621
+ imports.wbg.__wbg___wbindgen_debug_string_df47ffb5e35e6763 = function(arg0, arg1) {
5622
+ const ret = debugString(arg1);
5623
+ const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5624
+ const len1 = WASM_VECTOR_LEN;
5625
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
5626
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
5627
+ };
5628
+ imports.wbg.__wbg___wbindgen_is_function_ee8a6c5833c90377 = function(arg0) {
5629
+ const ret = typeof(arg0) === 'function';
5630
+ return ret;
5631
+ };
5632
+ imports.wbg.__wbg___wbindgen_is_undefined_2d472862bd29a478 = function(arg0) {
5633
+ const ret = arg0 === undefined;
5634
+ return ret;
5635
+ };
5636
+ imports.wbg.__wbg___wbindgen_number_get_a20bf9b85341449d = function(arg0, arg1) {
5637
+ const obj = arg1;
5638
+ const ret = typeof(obj) === 'number' ? obj : undefined;
5639
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
5640
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
5641
+ };
5642
+ imports.wbg.__wbg___wbindgen_throw_b855445ff6a94295 = function(arg0, arg1) {
5643
+ throw new Error(getStringFromWasm0(arg0, arg1));
5644
+ };
5645
+ imports.wbg.__wbg__wbg_cb_unref_2454a539ea5790d9 = function(arg0) {
5646
+ arg0._wbg_cb_unref();
5647
+ };
5648
+ imports.wbg.__wbg_apply_04097a755e1e4a1e = function() { return handleError(function (arg0, arg1, arg2) {
5235
5649
  const ret = arg0.apply(arg1, arg2);
5236
5650
  return ret;
5237
5651
  }, arguments) };
5652
+ imports.wbg.__wbg_call_525440f72fbfc0ea = function() { return handleError(function (arg0, arg1, arg2) {
5653
+ const ret = arg0.call(arg1, arg2);
5654
+ return ret;
5655
+ }, arguments) };
5656
+ imports.wbg.__wbg_call_e762c39fa8ea36bf = function() { return handleError(function (arg0, arg1) {
5657
+ const ret = arg0.call(arg1);
5658
+ return ret;
5659
+ }, arguments) };
5238
5660
  imports.wbg.__wbg_error_7534b8e9a36f1ab4 = function(arg0, arg1) {
5239
5661
  let deferred0_0;
5240
5662
  let deferred0_1;
@@ -5246,50 +5668,83 @@ function __wbg_get_imports() {
5246
5668
  wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
5247
5669
  }
5248
5670
  };
5249
- imports.wbg.__wbg_from_88bc52ce20ba6318 = function(arg0) {
5671
+ imports.wbg.__wbg_from_a4ad7cbddd0d7135 = function(arg0) {
5250
5672
  const ret = Array.from(arg0);
5251
5673
  return ret;
5252
5674
  };
5253
- imports.wbg.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
5675
+ imports.wbg.__wbg_get_7bed016f185add81 = function(arg0, arg1) {
5254
5676
  const ret = arg0[arg1 >>> 0];
5255
5677
  return ret;
5256
5678
  };
5257
- imports.wbg.__wbg_length_186546c51cd61acd = function(arg0) {
5679
+ imports.wbg.__wbg_length_cdd215e10d9dd507 = function(arg0) {
5258
5680
  const ret = arg0.length;
5259
5681
  return ret;
5260
5682
  };
5261
- imports.wbg.__wbg_log_3cc7740e30649ca2 = function(arg0, arg1) {
5262
- console.log(getStringFromWasm0(arg0, arg1));
5263
- };
5264
- imports.wbg.__wbg_log_6c7b5f4f00b8ce3f = function(arg0) {
5683
+ imports.wbg.__wbg_log_8cec76766b8c0e33 = function(arg0) {
5265
5684
  console.log(arg0);
5266
5685
  };
5267
- imports.wbg.__wbg_new_19c25a3f2fa63a02 = function() {
5686
+ imports.wbg.__wbg_log_bc75dce15192515f = function(arg0, arg1) {
5687
+ console.log(getStringFromWasm0(arg0, arg1));
5688
+ };
5689
+ imports.wbg.__wbg_new_1acc0b6eea89d040 = function() {
5268
5690
  const ret = new Object();
5269
5691
  return ret;
5270
5692
  };
5271
- imports.wbg.__wbg_new_1f3a344cf3123716 = function() {
5272
- const ret = new Array();
5273
- return ret;
5693
+ imports.wbg.__wbg_new_3c3d849046688a66 = function(arg0, arg1) {
5694
+ try {
5695
+ var state0 = {a: arg0, b: arg1};
5696
+ var cb0 = (arg0, arg1) => {
5697
+ const a = state0.a;
5698
+ state0.a = 0;
5699
+ try {
5700
+ return wasm_bindgen__convert__closures_____invoke__h4ca4ba3872354ffe(a, state0.b, arg0, arg1);
5701
+ } finally {
5702
+ state0.a = a;
5703
+ }
5704
+ };
5705
+ const ret = new Promise(cb0);
5706
+ return ret;
5707
+ } finally {
5708
+ state0.a = state0.b = 0;
5709
+ }
5274
5710
  };
5275
5711
  imports.wbg.__wbg_new_8a6f238a6ece86ea = function() {
5276
5712
  const ret = new Error();
5277
5713
  return ret;
5278
5714
  };
5279
- imports.wbg.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
5715
+ imports.wbg.__wbg_new_e17d9f43105b08be = function() {
5716
+ const ret = new Array();
5717
+ return ret;
5718
+ };
5719
+ imports.wbg.__wbg_new_no_args_ee98eee5275000a4 = function(arg0, arg1) {
5720
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
5721
+ return ret;
5722
+ };
5723
+ imports.wbg.__wbg_push_df81a39d04db858c = function(arg0, arg1) {
5280
5724
  const ret = arg0.push(arg1);
5281
5725
  return ret;
5282
5726
  };
5727
+ imports.wbg.__wbg_queueMicrotask_34d692c25c47d05b = function(arg0) {
5728
+ const ret = arg0.queueMicrotask;
5729
+ return ret;
5730
+ };
5731
+ imports.wbg.__wbg_queueMicrotask_9d76cacb20c84d58 = function(arg0) {
5732
+ queueMicrotask(arg0);
5733
+ };
5734
+ imports.wbg.__wbg_resolve_caf97c30b83f7053 = function(arg0) {
5735
+ const ret = Promise.resolve(arg0);
5736
+ return ret;
5737
+ };
5283
5738
  imports.wbg.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) {
5284
5739
  arg0[arg1] = arg2;
5285
5740
  };
5286
- imports.wbg.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
5741
+ imports.wbg.__wbg_set_c213c871859d6500 = function(arg0, arg1, arg2) {
5742
+ arg0[arg1 >>> 0] = arg2;
5743
+ };
5744
+ imports.wbg.__wbg_set_c2abbebe8b9ebee1 = function() { return handleError(function (arg0, arg1, arg2) {
5287
5745
  const ret = Reflect.set(arg0, arg1, arg2);
5288
5746
  return ret;
5289
5747
  }, arguments) };
5290
- imports.wbg.__wbg_set_90f6c0f7bd8c0415 = function(arg0, arg1, arg2) {
5291
- arg0[arg1 >>> 0] = arg2;
5292
- };
5293
5748
  imports.wbg.__wbg_stack_0ed75d68575b0f3c = function(arg0, arg1) {
5294
5749
  const ret = arg1.stack;
5295
5750
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -5297,10 +5752,34 @@ function __wbg_get_imports() {
5297
5752
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
5298
5753
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
5299
5754
  };
5755
+ imports.wbg.__wbg_static_accessor_GLOBAL_89e1d9ac6a1b250e = function() {
5756
+ const ret = typeof global === 'undefined' ? null : global;
5757
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5758
+ };
5759
+ imports.wbg.__wbg_static_accessor_GLOBAL_THIS_8b530f326a9e48ac = function() {
5760
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
5761
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5762
+ };
5763
+ imports.wbg.__wbg_static_accessor_SELF_6fdf4b64710cc91b = function() {
5764
+ const ret = typeof self === 'undefined' ? null : self;
5765
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5766
+ };
5767
+ imports.wbg.__wbg_static_accessor_WINDOW_b45bfc5a37f6cfa2 = function() {
5768
+ const ret = typeof window === 'undefined' ? null : window;
5769
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
5770
+ };
5771
+ imports.wbg.__wbg_then_4f46f6544e6b4a28 = function(arg0, arg1) {
5772
+ const ret = arg0.then(arg1);
5773
+ return ret;
5774
+ };
5300
5775
  imports.wbg.__wbg_wasmcommunity_new = function(arg0) {
5301
5776
  const ret = WasmCommunity.__wrap(arg0);
5302
5777
  return ret;
5303
5778
  };
5779
+ imports.wbg.__wbg_wasmoptimizationresult_new = function(arg0) {
5780
+ const ret = WasmOptimizationResult.__wrap(arg0);
5781
+ return ret;
5782
+ };
5304
5783
  imports.wbg.__wbg_wasmspacetimevector_new = function(arg0) {
5305
5784
  const ret = WasmSpacetimeVector.__wrap(arg0);
5306
5785
  return ret;
@@ -5309,22 +5788,6 @@ function __wbg_get_imports() {
5309
5788
  const ret = WasmTropicalNumber.__wrap(arg0);
5310
5789
  return ret;
5311
5790
  };
5312
- imports.wbg.__wbg_wbindgendebugstring_99ef257a3ddda34d = function(arg0, arg1) {
5313
- const ret = debugString(arg1);
5314
- const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
5315
- const len1 = WASM_VECTOR_LEN;
5316
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
5317
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
5318
- };
5319
- imports.wbg.__wbg_wbindgennumberget_f74b4c7525ac05cb = function(arg0, arg1) {
5320
- const obj = arg1;
5321
- const ret = typeof(obj) === 'number' ? obj : undefined;
5322
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
5323
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
5324
- };
5325
- imports.wbg.__wbg_wbindgenthrow_451ec1a8469d7eb6 = function(arg0, arg1) {
5326
- throw new Error(getStringFromWasm0(arg0, arg1));
5327
- };
5328
5791
  imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
5329
5792
  // Cast intrinsic for `Ref(String) -> Externref`.
5330
5793
  const ret = getStringFromWasm0(arg0, arg1);
@@ -5335,13 +5798,25 @@ function __wbg_get_imports() {
5335
5798
  const ret = BigInt.asUintN(64, arg0);
5336
5799
  return ret;
5337
5800
  };
5801
+ imports.wbg.__wbindgen_cast_69f35aa0fcaecc47 = function(arg0, arg1) {
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.wasm_bindgen__closure__destroy__h2186110628e4ed68, wasm_bindgen__convert__closures_____invoke__hce8272eee2f071c2);
5804
+ return ret;
5805
+ };
5806
+ imports.wbg.__wbindgen_cast_b63aeb0d85365734 = function(arg0, arg1) {
5807
+ var v0 = getArrayF64FromWasm0(arg0, arg1).slice();
5808
+ wasm.__wbindgen_free(arg0, arg1 * 8, 8);
5809
+ // Cast intrinsic for `Vector(F64) -> Externref`.
5810
+ const ret = v0;
5811
+ return ret;
5812
+ };
5338
5813
  imports.wbg.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
5339
5814
  // Cast intrinsic for `F64 -> Externref`.
5340
5815
  const ret = arg0;
5341
5816
  return ret;
5342
5817
  };
5343
5818
  imports.wbg.__wbindgen_init_externref_table = function() {
5344
- const table = wasm.__wbindgen_export_2;
5819
+ const table = wasm.__wbindgen_externrefs;
5345
5820
  const offset = table.grow(4);
5346
5821
  table.set(0, undefined);
5347
5822
  table.set(offset + 0, undefined);
@@ -5354,10 +5829,6 @@ function __wbg_get_imports() {
5354
5829
  return imports;
5355
5830
  }
5356
5831
 
5357
- function __wbg_init_memory(imports, memory) {
5358
-
5359
- }
5360
-
5361
5832
  function __wbg_finalize_init(instance, module) {
5362
5833
  wasm = instance.exports;
5363
5834
  __wbg_init.__wbindgen_wasm_module = module;
@@ -5385,8 +5856,6 @@ function initSync(module) {
5385
5856
 
5386
5857
  const imports = __wbg_get_imports();
5387
5858
 
5388
- __wbg_init_memory(imports);
5389
-
5390
5859
  if (!(module instanceof WebAssembly.Module)) {
5391
5860
  module = new WebAssembly.Module(module);
5392
5861
  }
@@ -5417,8 +5886,6 @@ async function __wbg_init(module_or_path) {
5417
5886
  module_or_path = fetch(module_or_path);
5418
5887
  }
5419
5888
 
5420
- __wbg_init_memory(imports);
5421
-
5422
5889
  const { instance, module } = await __wbg_load(await module_or_path, imports);
5423
5890
 
5424
5891
  return __wbg_finalize_init(instance, module);
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.7",
8
+ "version": "0.9.8",
9
9
  "license": "MIT OR Apache-2.0",
10
10
  "repository": {
11
11
  "type": "git",