fastlowess-wasm 0.99.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/README.md ADDED
@@ -0,0 +1,617 @@
1
+ <!-- markdownlint-disable MD024 MD033 -->
2
+ # LOWESS Project
3
+
4
+ [![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-blue.svg)](LICENSE-MIT)
5
+ [![Docs](https://img.shields.io/badge/docs-readthedocs-blue.svg)](https://lowess.readthedocs.io/)
6
+ [![Crates.io](https://img.shields.io/crates/v/lowess.svg)](https://crates.io/crates/lowess)
7
+ [![PyPI](https://img.shields.io/pypi/v/fastlowess.svg)](https://pypi.org/project/fastlowess/)
8
+ [![Conda](https://anaconda.org/conda-forge/fastlowess/badges/version.svg)](https://anaconda.org/conda-forge/fastlowess)
9
+ [![R-universe](https://thisisamirv.r-universe.dev/badges/rfastlowess)](https://thisisamirv.r-universe.dev/rfastlowess)
10
+
11
+ <p align="center">
12
+ <img src="https://raw.githubusercontent.com/thisisamirv/lowess-project/main/dev/logo.png" alt="One LOWESS to Rule Them All" width="400">
13
+ <br>
14
+ <em>One LOWESS to Rule Them All</em>
15
+ </p>
16
+
17
+ The fastest, most robust, and most feature-complete language-agnostic LOWESS (Locally Weighted Scatterplot Smoothing) implementation for **Rust**, **Python**, **R**, **Julia**, **JavaScript**, **C++**, and **WebAssembly**.
18
+
19
+ > [!IMPORTANT]
20
+ >
21
+ > The `lowess-project` contains a complete ecosystem for LOWESS smoothing:
22
+ >
23
+ > - **[`lowess`](https://github.com/thisisamirv/lowess-project/tree/main/crates/lowess)** - Core single-threaded Rust implementation with `no_std` support
24
+ > - **[`fastLowess`](https://github.com/thisisamirv/lowess-project/tree/main/crates/fastLowess)** - Parallel CPU and GPU-accelerated Rust wrapper with ndarray integration
25
+ > - **[`R bindings`](https://github.com/thisisamirv/lowess-project/tree/main/bindings/r)** - extendr-based R package
26
+ > - **[`Python bindings`](https://github.com/thisisamirv/lowess-project/tree/main/bindings/python)** - PyO3-based Python package
27
+ > - **[`Julia bindings`](https://github.com/thisisamirv/lowess-project/tree/main/bindings/julia)** - Native Julia package with C FFI
28
+ > - **[`JavaScript bindings`](https://github.com/thisisamirv/lowess-project/tree/main/bindings/nodejs)** - Node.js package
29
+ > - **[`WebAssembly bindings`](https://github.com/thisisamirv/lowess-project/tree/main/bindings/wasm)** - WASM package
30
+ > - **[`C++ bindings`](https://github.com/thisisamirv/lowess-project/tree/main/bindings/cpp)** - Native C++ package with CMake integration
31
+
32
+ ## LOESS vs. LOWESS
33
+
34
+ | Feature | LOESS (This Crate) | LOWESS |
35
+ |-----------------------|-----------------------------------|--------------------------------|
36
+ | **Polynomial Degree** | Linear, Quadratic, Cubic, Quartic | Linear (Degree 1) |
37
+ | **Dimensions** | Multivariate (n-D support) | Univariate (1-D only) |
38
+ | **Flexibility** | High (Distance metrics) | Standard |
39
+ | **Complexity** | Higher (Matrix inversion) | Lower (Weighted average/slope) |
40
+
41
+ > [!TIP]
42
+ > **Note:** For a **LOESS** implementation, use [`loess-project`](https://github.com/thisisamirv/loess-project).
43
+
44
+ ---
45
+
46
+ ## Documentation
47
+
48
+ > [!NOTE]
49
+ >
50
+ > ### 📚 [View the full documentation](https://lowess.readthedocs.io/)
51
+
52
+ ## Why this package?
53
+
54
+ ### Speed
55
+
56
+ The `lowess` project crushes the competition in terms of speed, wether in single-threaded or multi-threaded parallel execution.
57
+
58
+ Speedup relative to Python's `statsmodels.lowess` (higher is better):
59
+
60
+ | Category | statsmodels | R (stats) | Serial | Parallel | GPU |
61
+ |---------------------------------|-------------|-----------|--------|----------|---------|
62
+ | **Clustered** | 163ms | 83× | 203× | **433×** | 32× |
63
+ | **Constant Y** | 134ms | 92× | 212× | **410×** | 18× |
64
+ | **Delta** (large–none) | 105ms | 2× | 4× | 6× | **16×** |
65
+ | **Extreme Outliers** | 489ms | 106× | 201× | **388×** | 29× |
66
+ | **Financial** (500–10K) | 106ms | 105× | 252× | **293×** | 12× |
67
+ | **Fraction** (0.05–0.67) | 221ms | 104× | 228× | **391×** | 22× |
68
+ | **Genomic** (1K–50K) | 1833ms | 7× | 9× | 20× | **95×** |
69
+ | **High Noise** | 435ms | 133× | 134× | **375×** | 32× |
70
+ | **Iterations** (0–10) | 204ms | 115× | 224× | **386×** | 18× |
71
+ | **Scale** (1K–50K) | 1841ms | 264× | 487× | **581×** | 98× |
72
+ | **Scientific** (500–10K) | 167ms | 109× | 205× | **314×** | 15× |
73
+ | **Scale Large**\* (100K–2M) | — | — | 1× | **1.4×** | 0.3× |
74
+
75
+ \*Scale Large benchmarks are relative to Serial (statsmodels cannot handle these sizes)
76
+
77
+ *The numbers are the average across a range of scenarios for each category (e.g., Delta from none, to small, medium, and large).*
78
+
79
+ ### Robustness
80
+
81
+ This implementation is *more robust* than R's `lowess` and Python's `statsmodels` due to two key design choices:
82
+
83
+ **MAD-Based Scale Estimation:**
84
+
85
+ For robustness weight calculations, this crate uses *Median Absolute Deviation (MAD)* for scale estimation:
86
+
87
+ ```text
88
+ s = median(|r_i - median(r)|)
89
+ ```
90
+
91
+ In contrast, `statsmodels` and R's `lowess` uses the median of absolute residuals (MAR):
92
+
93
+ ```text
94
+ s = median(|r_i|)
95
+ ```
96
+
97
+ - MAD is a *breakdown-point-optimal* estimator—it remains valid even when up to 50% of data are outliers.
98
+ - The median-centering step removes asymmetric bias from residual distributions.
99
+ - MAD provides consistent outlier detection regardless of whether residuals are centered around zero.
100
+
101
+ **Boundary Padding:**
102
+
103
+ This crate applies a range of different *boundary policies* at dataset edges:
104
+
105
+ - **Extend**: Repeats edge values to maintain local neighborhood size.
106
+ - **Reflect**: Mirrors data symmetrically around boundaries.
107
+ - **Zero**: Pads with zeros (useful for signal processing).
108
+ - **NoBoundary**: Original Cleveland behavior
109
+
110
+ `statsmodels` and R's `lowess` do not apply boundary padding, which can lead to:
111
+
112
+ - Biased estimates near boundaries due to asymmetric local neighborhoods.
113
+ - Increased variance at the edges of the smoothed curve.
114
+
115
+ ### Features
116
+
117
+ A variety of features, supporting a range of use cases:
118
+
119
+ | Feature | This package | statsmodels | R (stats) |
120
+ |----------------------|:-------------:|:------------:|:------------:|
121
+ | Kernel | 7 options | only Tricube | only Tricube |
122
+ | Robustness Weighting | 3 options | only Huber | only Huber |
123
+ | Scale Estimation | 2 options | only MAR | only MAR |
124
+ | Boundary Padding | 4 options | no padding | no padding |
125
+ | Zero Weight Fallback | 3 options | no | no |
126
+ | Auto Convergence | yes | no | no |
127
+ | Online Mode | yes | no | no |
128
+ | Streaming Mode | yes | no | no |
129
+ | Confidence Intervals | yes | no | no |
130
+ | Prediction Intervals | yes | no | no |
131
+ | Cross-Validation | 2 options | no | no |
132
+ | Parallel Execution | yes | no | no |
133
+ | GPU Acceleration | yes* | no | no |
134
+ | `no-std` Support | yes | no | no |
135
+
136
+ \* GPU acceleration is currently in beta and may not be available on all platforms.
137
+
138
+ ## Validation
139
+
140
+ All implementations are **numerical twins** of R's `lowess`:
141
+
142
+ | Aspect | Status | Details |
143
+ |-----------------|----------------|-----------------------------------------------|
144
+ | **Accuracy** | ✅ EXACT MATCH | Max diff < 1e-12 across all scenarios |
145
+ | **Consistency** | ✅ PERFECT | Multiple scenarios pass with strict tolerance |
146
+ | **Robustness** | ✅ VERIFIED | Robust smoothing matches R exactly |
147
+
148
+ ## Installation
149
+
150
+ Currently available for R, Python, Julia, and Rust:
151
+
152
+ **R** (from R-universe, recommended):
153
+
154
+ ```r
155
+ install.packages("rfastlowess", repos = "https://thisisamirv.r-universe.dev")
156
+ ```
157
+
158
+ **Python** (from PyPI):
159
+
160
+ ```bash
161
+ pip install fastlowess
162
+ ```
163
+
164
+ Or from conda-forge:
165
+
166
+ ```bash
167
+ conda install -c conda-forge fastlowess
168
+ ```
169
+
170
+ **Rust** (lowess, no_std compatible):
171
+
172
+ ```toml
173
+ [dependencies]
174
+ lowess = "0.99"
175
+ ```
176
+
177
+ **Rust** (fastLowess, parallel + GPU):
178
+
179
+ ```toml
180
+ [dependencies]
181
+ fastLowess = { version = "0.99", features = ["cpu"] }
182
+ ```
183
+
184
+ **Julia** (from Julia General Registry):
185
+
186
+ ```julia
187
+ using Pkg
188
+ Pkg.add("fastLowess")
189
+ ```
190
+
191
+ **Node.js** (from npm):
192
+
193
+ ```bash
194
+ npm install fastlowess
195
+ ```
196
+
197
+ **WebAssembly** (from npm):
198
+
199
+ ```bash
200
+ npm install fastlowess-wasm
201
+ ```
202
+
203
+ Or via CDN:
204
+
205
+ ```html
206
+ <script type="module">
207
+ import init, { smooth } from 'https://unpkg.com/fastlowess-wasm@latest';
208
+ await init();
209
+ </script>
210
+ ```
211
+
212
+ **C++** (build from source):
213
+
214
+ ```bash
215
+ make cpp
216
+ # Links against libfastlowess_cpp.so
217
+ ```
218
+
219
+ ## Quick Example
220
+
221
+ **R:**
222
+
223
+ ```r
224
+ library(rfastlowess)
225
+
226
+ x <- c(1, 2, 3, 4, 5)
227
+ y <- c(2.0, 4.1, 5.9, 8.2, 9.8)
228
+
229
+ result <- fastlowess(x, y, fraction = 0.5, iterations = 3)
230
+ print(result$y)
231
+ ```
232
+
233
+ **Python:**
234
+
235
+ ```python
236
+ import fastlowess as fl
237
+ import numpy as np
238
+
239
+ x = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
240
+ y = np.array([2.0, 4.1, 5.9, 8.2, 9.8])
241
+
242
+ result = fl.smooth(x, y, fraction=0.5, iterations=3)
243
+ print(result["y"])
244
+ ```
245
+
246
+ **Rust:**
247
+
248
+ ```rust
249
+ use lowess::prelude::*;
250
+
251
+ let x = vec![1.0, 2.0, 3.0, 4.0, 5.0];
252
+ let y = vec![2.0, 4.1, 5.9, 8.2, 9.8];
253
+
254
+ let model = Lowess::new()
255
+ .fraction(0.5)
256
+ .iterations(3)
257
+ .adapter(Batch)
258
+ .build()?;
259
+
260
+ let result = model.fit(&x, &y)?;
261
+ println!("{}", result);
262
+ ```
263
+
264
+ **Julia:**
265
+
266
+ ```julia
267
+ using fastlowess
268
+
269
+ x = [1.0, 2.0, 3.0, 4.0, 5.0]
270
+ y = [2.0, 4.1, 5.9, 8.2, 9.8]
271
+
272
+ result = smooth(x, y, fraction=0.5, iterations=3)
273
+ println(result.y)
274
+ ```
275
+
276
+ **Node.js:**
277
+
278
+ ```javascript
279
+ const { smooth } = require('fastlowess');
280
+
281
+ const x = [1.0, 2.0, 3.0, 4.0, 5.0];
282
+ const y = [2.0, 4.1, 5.9, 8.2, 9.8];
283
+
284
+ const result = smooth(x, y, { fraction: 0.5, iterations: 3 });
285
+ console.log(result.y);
286
+ ```
287
+
288
+ **WebAssembly:**
289
+
290
+ ```javascript
291
+ import init, { smooth } from 'fastlowess-wasm';
292
+
293
+ await init();
294
+
295
+ const x = new Float64Array([1.0, 2.0, 3.0, 4.0, 5.0]);
296
+ const y = new Float64Array([2.0, 4.1, 5.9, 8.2, 9.8]);
297
+
298
+ const result = smooth(x, y, { fraction: 0.5, iterations: 3 });
299
+ console.log(result.y);
300
+ ```
301
+
302
+ **C++:**
303
+
304
+ ```cpp
305
+ #include <fastlowess.hpp>
306
+
307
+ std::vector<double> x = {1.0, 2.0, 3.0, 4.0, 5.0};
308
+ std::vector<double> y = {2.0, 4.1, 5.9, 8.2, 9.8};
309
+
310
+ fastlowess::LowessOptions options;
311
+ options.fraction = 0.5;
312
+ options.iterations = 3;
313
+
314
+ auto result = fastlowess::smooth(x, y, options);
315
+ for (double val : result.y_vector()) std::cout << val << " ";
316
+ ```
317
+
318
+ ---
319
+
320
+ ## API Reference
321
+
322
+ **R:**
323
+
324
+ ```r
325
+ fastlowess(
326
+ x, y,
327
+ fraction = 0.5,
328
+ iterations = 3L,
329
+ delta = 0.01,
330
+ weight_function = "tricube",
331
+ robustness_method = "bisquare",
332
+ zero_weight_fallback = "use_local_mean",
333
+ boundary_policy = "extend",
334
+ confidence_intervals = 0.95,
335
+ prediction_intervals = 0.95,
336
+ return_diagnostics = TRUE,
337
+ return_residuals = TRUE,
338
+ return_robustness_weights = TRUE,
339
+ cv_fractions = c(0.3, 0.5, 0.7),
340
+ cv_method = "kfold",
341
+ cv_k = 5L,
342
+ auto_converge = 1e-4,
343
+ parallel = TRUE
344
+ )
345
+ ```
346
+
347
+ **Python:**
348
+
349
+ ```python
350
+ fastlowess.smooth(
351
+ x, y,
352
+ fraction=0.5,
353
+ iterations=3,
354
+ delta=0.01,
355
+ weight_function="tricube",
356
+ robustness_method="bisquare",
357
+ zero_weight_fallback="use_local_mean",
358
+ boundary_policy="extend",
359
+ confidence_intervals=0.95,
360
+ prediction_intervals=0.95,
361
+ return_diagnostics=True,
362
+ return_residuals=True,
363
+ return_robustness_weights=True,
364
+ cv_fractions=[0.3, 0.5, 0.7],
365
+ cv_method="kfold",
366
+ cv_k=5,
367
+ auto_converge=1e-4,
368
+ parallel=True
369
+ )
370
+ ```
371
+
372
+ **Rust:**
373
+
374
+ ```rust
375
+ Lowess::new()
376
+ .fraction(0.5) // Smoothing span (0, 1]
377
+ .iterations(3) // Robustness iterations
378
+ .delta(0.01) // Interpolation threshold
379
+ .weight_function(Tricube) // Kernel selection
380
+ .robustness_method(Bisquare)
381
+ .zero_weight_fallback(UseLocalMean)
382
+ .boundary_policy(Extend)
383
+ .confidence_intervals(0.95)
384
+ .prediction_intervals(0.95)
385
+ .return_diagnostics()
386
+ .return_residuals()
387
+ .return_robustness_weights()
388
+ .cross_validate(KFold(5, &[0.3, 0.5, 0.7]).seed(123))
389
+ .auto_converge(1e-4)
390
+ .adapter(Batch) // or Streaming, Online
391
+ .parallel(true) // fastLowess only
392
+ .backend(CPU) // fastLowess only: CPU or GPU
393
+ .build()?;
394
+ ```
395
+
396
+ **Julia:**
397
+
398
+ ```julia
399
+ smooth(
400
+ x, y,
401
+ fraction=0.5,
402
+ iterations=3,
403
+ delta=NaN, # NaN for auto
404
+ weight_function="tricube",
405
+ robustness_method="bisquare",
406
+ zero_weight_fallback="use_local_mean",
407
+ boundary_policy="extend",
408
+ confidence_intervals=0.95,
409
+ prediction_intervals=0.95,
410
+ return_diagnostics=true,
411
+ return_residuals=true,
412
+ return_robustness_weights=true,
413
+ cv_fractions=[0.3, 0.5, 0.7],
414
+ cv_method="kfold",
415
+ cv_k=5,
416
+ auto_converge=1e-4,
417
+ parallel=true
418
+ )
419
+ ```
420
+
421
+ **Node.js:**
422
+
423
+ ```javascript
424
+ smooth(x, y, {
425
+ fraction: 0.5,
426
+ iterations: 3,
427
+ delta: 0.01,
428
+ weightFunction: "tricube",
429
+ robustnessMethod: "bisquare",
430
+ zeroWeightFallback: "use_local_mean",
431
+ boundaryPolicy: "extend",
432
+ confidenceIntervals: 0.95,
433
+ predictionIntervals: 0.95,
434
+ returnDiagnostics: true,
435
+ returnResiduals: true,
436
+ returnRobustnessWeights: true,
437
+ cvFractions: [0.3, 0.5, 0.7],
438
+ cvMethod: "kfold",
439
+ cvK: 5,
440
+ autoConverge: 1e-4,
441
+ parallel: true
442
+ })
443
+ ```
444
+
445
+ **WebAssembly:**
446
+
447
+ ```javascript
448
+ smooth(x, y, {
449
+ fraction: 0.5,
450
+ iterations: 3,
451
+ delta: 0.01,
452
+ weightFunction: "tricube",
453
+ robustnessMethod: "bisquare",
454
+ zeroWeightFallback: "use_local_mean",
455
+ boundaryPolicy: "extend",
456
+ confidenceIntervals: 0.95,
457
+ predictionIntervals: 0.95,
458
+ returnDiagnostics: true,
459
+ returnResiduals: true,
460
+ returnRobustnessWeights: true,
461
+ cvFractions: [0.3, 0.5, 0.7],
462
+ cvMethod: "kfold",
463
+ cvK: 5,
464
+ autoConverge: 1e-4
465
+ })
466
+ ```
467
+
468
+ **C++:**
469
+
470
+ ```cpp
471
+ fastlowess::LowessOptions options;
472
+ options.fraction = 0.5;
473
+ options.iterations = 3;
474
+ options.delta = 0.01;
475
+ options.weight_function = "tricube";
476
+ options.robustness_method = "bisquare";
477
+ options.zero_weight_fallback = "use_local_mean";
478
+ options.boundary_policy = "extend";
479
+ options.confidence_intervals = 0.95;
480
+ options.prediction_intervals = 0.95;
481
+ options.return_diagnostics = true;
482
+ options.return_residuals = true;
483
+ options.return_robustness_weights = true;
484
+ options.cv_fractions = {0.3, 0.5, 0.7};
485
+ options.cv_method = "kfold";
486
+ options.cv_k = 5;
487
+ options.auto_converge = 1e-4;
488
+ options.parallel = true;
489
+
490
+ auto result = fastlowess::smooth(x, y, options);
491
+ ```
492
+
493
+ ## Result Structure
494
+
495
+ **R:**
496
+
497
+ ```r
498
+ result$x, result$y, result$standard_errors
499
+ result$confidence_lower, result$confidence_upper
500
+ result$prediction_lower, result$prediction_upper
501
+ result$residuals, result$robustness_weights
502
+ result$diagnostics, result$iterations_used
503
+ result$fraction_used, result$cv_scores
504
+ ```
505
+
506
+ **Python:**
507
+
508
+ ```python
509
+ result.x, result.y, result.standard_errors
510
+ result.confidence_lower, result.confidence_upper
511
+ result.prediction_lower, result.prediction_upper
512
+ result.residuals, result.robustness_weights
513
+ result.diagnostics, result.iterations_used
514
+ result.fraction_used, result.cv_scores
515
+ ```
516
+
517
+ **Rust:**
518
+
519
+ ```rust
520
+ pub struct LowessResult<T> {
521
+ pub x: Vec<T>, // Sorted x values
522
+ pub y: Vec<T>, // Smoothed y values
523
+ pub standard_errors: Option<Vec<T>>,
524
+ pub confidence_lower: Option<Vec<T>>,
525
+ pub confidence_upper: Option<Vec<T>>,
526
+ pub prediction_lower: Option<Vec<T>>,
527
+ pub prediction_upper: Option<Vec<T>>,
528
+ pub residuals: Option<Vec<T>>,
529
+ pub robustness_weights: Option<Vec<T>>,
530
+ pub diagnostics: Option<Diagnostics<T>>,
531
+ pub iterations_used: Option<usize>,
532
+ pub fraction_used: T,
533
+ pub cv_scores: Option<Vec<T>>,
534
+ }
535
+ ```
536
+
537
+ **Julia:**
538
+
539
+ ```julia
540
+ result.x, result.y, result.standard_errors
541
+ result.confidence_lower, result.confidence_upper
542
+ result.prediction_lower, result.prediction_upper
543
+ result.residuals, result.robustness_weights
544
+ result.diagnostics, result.iterations_used
545
+ result.fraction_used
546
+ ```
547
+
548
+ **Node.js:**
549
+
550
+ ```javascript
551
+ result.x, result.y, result.standardErrors
552
+ result.confidenceLower, result.confidenceUpper
553
+ result.predictionLower, result.predictionUpper
554
+ result.residuals, result.robustnessWeights
555
+ result.diagnostics, result.iterationsUsed
556
+ result.fractionUsed, result.cvScores
557
+ ```
558
+
559
+ **WebAssembly:**
560
+
561
+ ```javascript
562
+ result.x, result.y, result.standardErrors
563
+ result.confidenceLower, result.confidenceUpper
564
+ result.predictionLower, result.predictionUpper
565
+ result.residuals, result.robustnessWeights
566
+ result.diagnostics, result.iterationsUsed
567
+ result.fractionUsed, result.cvScores
568
+ ```
569
+
570
+ **C++:**
571
+
572
+ ```cpp
573
+ result.y_vector() // std::vector<double>
574
+ result.confidence_lower() // std::vector<double>
575
+ result.confidence_upper() // std::vector<double>
576
+ result.prediction_lower() // std::vector<double>
577
+ result.prediction_upper() // std::vector<double>
578
+ result.residuals() // std::vector<double>
579
+ result.robustness_weights() // std::vector<double>
580
+ result.diagnostics() // Diagnostics struct
581
+ result.iterations_used() // size_t
582
+ result.fraction_used() // double
583
+ ```
584
+
585
+ ---
586
+
587
+ ## Contributing
588
+
589
+ Contributions are welcome! Please see the [CONTRIBUTING.md](https://github.com/thisisamirv/lowess-project/blob/main/CONTRIBUTING.md) file for more information.
590
+
591
+ ## License
592
+
593
+ Licensed under either of:
594
+
595
+ - Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or <https://www.apache.org/licenses/LICENSE-2.0>)
596
+ - MIT license ([LICENSE-MIT](LICENSE-MIT) or <https://opensource.org/licenses/MIT>)
597
+
598
+ at your option.
599
+
600
+ ## References
601
+
602
+ - Cleveland, W.S. (1979). "Robust Locally Weighted Regression and Smoothing Scatterplots". *JASA*.
603
+ - Cleveland, W.S. (1981). "LOWESS: A Program for Smoothing Scatterplots". *The American Statistician*.
604
+
605
+ ## Citation
606
+
607
+ If you use this software in your research, please cite it using the [CITATION.cff](https://github.com/thisisamirv/lowess-project/blob/main/CITATION.cff) file or the BibTeX entry below:
608
+
609
+ ```bibtex
610
+ @software{lowess_project,
611
+ author = {Valizadeh, Amir},
612
+ title = {LOWESS Project: High-Performance Locally Weighted Scatterplot Smoothing},
613
+ year = {2026},
614
+ url = {https://github.com/thisisamirv/lowess-project},
615
+ license = {MIT OR Apache-2.0}
616
+ }
617
+ ```
@@ -0,0 +1,126 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ export class Diagnostics {
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ rmse: number;
9
+ mae: number;
10
+ rSquared: number;
11
+ get aic(): number | undefined;
12
+ set aic(value: number | null | undefined);
13
+ get aicc(): number | undefined;
14
+ set aicc(value: number | null | undefined);
15
+ get effectiveDf(): number | undefined;
16
+ set effectiveDf(value: number | null | undefined);
17
+ residualSd: number;
18
+ }
19
+
20
+ export class LowessResultWasm {
21
+ private constructor();
22
+ free(): void;
23
+ [Symbol.dispose](): void;
24
+ readonly diagnostics: Diagnostics | undefined;
25
+ readonly fractionUsed: number;
26
+ readonly iterationsUsed: number | undefined;
27
+ readonly standardErrors: Float64Array | undefined;
28
+ readonly confidenceLower: Float64Array | undefined;
29
+ readonly confidenceUpper: Float64Array | undefined;
30
+ readonly predictionLower: Float64Array | undefined;
31
+ readonly predictionUpper: Float64Array | undefined;
32
+ readonly robustnessWeights: Float64Array | undefined;
33
+ readonly x: Float64Array;
34
+ readonly y: Float64Array;
35
+ readonly cvScores: Float64Array | undefined;
36
+ readonly residuals: Float64Array | undefined;
37
+ }
38
+
39
+ export class OnlineLowessWasm {
40
+ free(): void;
41
+ [Symbol.dispose](): void;
42
+ constructor(options: any, online_opts: any);
43
+ update(x: number, y: number): number | undefined;
44
+ }
45
+
46
+ export class StreamingLowessWasm {
47
+ free(): void;
48
+ [Symbol.dispose](): void;
49
+ processChunk(x: Float64Array, y: Float64Array): LowessResultWasm;
50
+ constructor(options: any, streaming_opts: any);
51
+ finalize(): LowessResultWasm;
52
+ }
53
+
54
+ export function smooth(x: Float64Array, y: Float64Array, options: any): LowessResultWasm;
55
+
56
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
57
+
58
+ export interface InitOutput {
59
+ readonly memory: WebAssembly.Memory;
60
+ readonly __wbg_diagnostics_free: (a: number, b: number) => void;
61
+ readonly __wbg_get_diagnostics_aic: (a: number) => [number, number];
62
+ readonly __wbg_get_diagnostics_aicc: (a: number) => [number, number];
63
+ readonly __wbg_get_diagnostics_effectiveDf: (a: number) => [number, number];
64
+ readonly __wbg_get_diagnostics_mae: (a: number) => number;
65
+ readonly __wbg_get_diagnostics_rSquared: (a: number) => number;
66
+ readonly __wbg_get_diagnostics_residualSd: (a: number) => number;
67
+ readonly __wbg_get_diagnostics_rmse: (a: number) => number;
68
+ readonly __wbg_lowessresultwasm_free: (a: number, b: number) => void;
69
+ readonly __wbg_onlinelowesswasm_free: (a: number, b: number) => void;
70
+ readonly __wbg_set_diagnostics_aic: (a: number, b: number, c: number) => void;
71
+ readonly __wbg_set_diagnostics_aicc: (a: number, b: number, c: number) => void;
72
+ readonly __wbg_set_diagnostics_effectiveDf: (a: number, b: number, c: number) => void;
73
+ readonly __wbg_set_diagnostics_mae: (a: number, b: number) => void;
74
+ readonly __wbg_set_diagnostics_rSquared: (a: number, b: number) => void;
75
+ readonly __wbg_set_diagnostics_residualSd: (a: number, b: number) => void;
76
+ readonly __wbg_set_diagnostics_rmse: (a: number, b: number) => void;
77
+ readonly __wbg_streaminglowesswasm_free: (a: number, b: number) => void;
78
+ readonly lowessresultwasm_confidenceLower: (a: number) => any;
79
+ readonly lowessresultwasm_confidenceUpper: (a: number) => any;
80
+ readonly lowessresultwasm_cvScores: (a: number) => any;
81
+ readonly lowessresultwasm_diagnostics: (a: number) => number;
82
+ readonly lowessresultwasm_fractionUsed: (a: number) => number;
83
+ readonly lowessresultwasm_iterationsUsed: (a: number) => number;
84
+ readonly lowessresultwasm_predictionLower: (a: number) => any;
85
+ readonly lowessresultwasm_predictionUpper: (a: number) => any;
86
+ readonly lowessresultwasm_residuals: (a: number) => any;
87
+ readonly lowessresultwasm_robustnessWeights: (a: number) => any;
88
+ readonly lowessresultwasm_standardErrors: (a: number) => any;
89
+ readonly lowessresultwasm_x: (a: number) => any;
90
+ readonly lowessresultwasm_y: (a: number) => any;
91
+ readonly onlinelowesswasm_new: (a: any, b: any) => [number, number, number];
92
+ readonly onlinelowesswasm_update: (a: number, b: number, c: number) => [number, number, number, number];
93
+ readonly smooth: (a: any, b: any, c: any) => [number, number, number];
94
+ readonly streaminglowesswasm_finalize: (a: number) => [number, number, number];
95
+ readonly streaminglowesswasm_new: (a: any, b: any) => [number, number, number];
96
+ readonly streaminglowesswasm_processChunk: (a: number, b: any, c: any) => [number, number, number];
97
+ readonly __wbindgen_malloc: (a: number, b: number) => number;
98
+ readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
99
+ readonly __wbindgen_exn_store: (a: number) => void;
100
+ readonly __externref_table_alloc: () => number;
101
+ readonly __wbindgen_externrefs: WebAssembly.Table;
102
+ readonly __externref_table_dealloc: (a: number) => void;
103
+ readonly __wbindgen_start: () => void;
104
+ }
105
+
106
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
107
+
108
+ /**
109
+ * Instantiates the given `module`, which can either be bytes or
110
+ * a precompiled `WebAssembly.Module`.
111
+ *
112
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
113
+ *
114
+ * @returns {InitOutput}
115
+ */
116
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
117
+
118
+ /**
119
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
120
+ * for everything else, calls `WebAssembly.instantiate` directly.
121
+ *
122
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
123
+ *
124
+ * @returns {Promise<InitOutput>}
125
+ */
126
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
@@ -0,0 +1,640 @@
1
+ let wasm;
2
+
3
+ function addToExternrefTable0(obj) {
4
+ const idx = wasm.__externref_table_alloc();
5
+ wasm.__wbindgen_externrefs.set(idx, obj);
6
+ return idx;
7
+ }
8
+
9
+ function getArrayF64FromWasm0(ptr, len) {
10
+ ptr = ptr >>> 0;
11
+ return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
12
+ }
13
+
14
+ let cachedDataViewMemory0 = null;
15
+ function getDataViewMemory0() {
16
+ if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) {
17
+ cachedDataViewMemory0 = new DataView(wasm.memory.buffer);
18
+ }
19
+ return cachedDataViewMemory0;
20
+ }
21
+
22
+ let cachedFloat64ArrayMemory0 = null;
23
+ function getFloat64ArrayMemory0() {
24
+ if (cachedFloat64ArrayMemory0 === null || cachedFloat64ArrayMemory0.byteLength === 0) {
25
+ cachedFloat64ArrayMemory0 = new Float64Array(wasm.memory.buffer);
26
+ }
27
+ return cachedFloat64ArrayMemory0;
28
+ }
29
+
30
+ function getStringFromWasm0(ptr, len) {
31
+ ptr = ptr >>> 0;
32
+ return decodeText(ptr, len);
33
+ }
34
+
35
+ let cachedUint8ArrayMemory0 = null;
36
+ function getUint8ArrayMemory0() {
37
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
38
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
39
+ }
40
+ return cachedUint8ArrayMemory0;
41
+ }
42
+
43
+ function handleError(f, args) {
44
+ try {
45
+ return f.apply(this, args);
46
+ } catch (e) {
47
+ const idx = addToExternrefTable0(e);
48
+ wasm.__wbindgen_exn_store(idx);
49
+ }
50
+ }
51
+
52
+ function isLikeNone(x) {
53
+ return x === undefined || x === null;
54
+ }
55
+
56
+ function passStringToWasm0(arg, malloc, realloc) {
57
+ if (realloc === undefined) {
58
+ const buf = cachedTextEncoder.encode(arg);
59
+ const ptr = malloc(buf.length, 1) >>> 0;
60
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
61
+ WASM_VECTOR_LEN = buf.length;
62
+ return ptr;
63
+ }
64
+
65
+ let len = arg.length;
66
+ let ptr = malloc(len, 1) >>> 0;
67
+
68
+ const mem = getUint8ArrayMemory0();
69
+
70
+ let offset = 0;
71
+
72
+ for (; offset < len; offset++) {
73
+ const code = arg.charCodeAt(offset);
74
+ if (code > 0x7F) break;
75
+ mem[ptr + offset] = code;
76
+ }
77
+ if (offset !== len) {
78
+ if (offset !== 0) {
79
+ arg = arg.slice(offset);
80
+ }
81
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
82
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
83
+ const ret = cachedTextEncoder.encodeInto(arg, view);
84
+
85
+ offset += ret.written;
86
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
87
+ }
88
+
89
+ WASM_VECTOR_LEN = offset;
90
+ return ptr;
91
+ }
92
+
93
+ function takeFromExternrefTable0(idx) {
94
+ const value = wasm.__wbindgen_externrefs.get(idx);
95
+ wasm.__externref_table_dealloc(idx);
96
+ return value;
97
+ }
98
+
99
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
100
+ cachedTextDecoder.decode();
101
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
102
+ let numBytesDecoded = 0;
103
+ function decodeText(ptr, len) {
104
+ numBytesDecoded += len;
105
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
106
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
107
+ cachedTextDecoder.decode();
108
+ numBytesDecoded = len;
109
+ }
110
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
111
+ }
112
+
113
+ const cachedTextEncoder = new TextEncoder();
114
+
115
+ if (!('encodeInto' in cachedTextEncoder)) {
116
+ cachedTextEncoder.encodeInto = function (arg, view) {
117
+ const buf = cachedTextEncoder.encode(arg);
118
+ view.set(buf);
119
+ return {
120
+ read: arg.length,
121
+ written: buf.length
122
+ };
123
+ }
124
+ }
125
+
126
+ let WASM_VECTOR_LEN = 0;
127
+
128
+ const DiagnosticsFinalization = (typeof FinalizationRegistry === 'undefined')
129
+ ? { register: () => {}, unregister: () => {} }
130
+ : new FinalizationRegistry(ptr => wasm.__wbg_diagnostics_free(ptr >>> 0, 1));
131
+
132
+ const LowessResultWasmFinalization = (typeof FinalizationRegistry === 'undefined')
133
+ ? { register: () => {}, unregister: () => {} }
134
+ : new FinalizationRegistry(ptr => wasm.__wbg_lowessresultwasm_free(ptr >>> 0, 1));
135
+
136
+ const OnlineLowessWasmFinalization = (typeof FinalizationRegistry === 'undefined')
137
+ ? { register: () => {}, unregister: () => {} }
138
+ : new FinalizationRegistry(ptr => wasm.__wbg_onlinelowesswasm_free(ptr >>> 0, 1));
139
+
140
+ const StreamingLowessWasmFinalization = (typeof FinalizationRegistry === 'undefined')
141
+ ? { register: () => {}, unregister: () => {} }
142
+ : new FinalizationRegistry(ptr => wasm.__wbg_streaminglowesswasm_free(ptr >>> 0, 1));
143
+
144
+ export class Diagnostics {
145
+ static __wrap(ptr) {
146
+ ptr = ptr >>> 0;
147
+ const obj = Object.create(Diagnostics.prototype);
148
+ obj.__wbg_ptr = ptr;
149
+ DiagnosticsFinalization.register(obj, obj.__wbg_ptr, obj);
150
+ return obj;
151
+ }
152
+ __destroy_into_raw() {
153
+ const ptr = this.__wbg_ptr;
154
+ this.__wbg_ptr = 0;
155
+ DiagnosticsFinalization.unregister(this);
156
+ return ptr;
157
+ }
158
+ free() {
159
+ const ptr = this.__destroy_into_raw();
160
+ wasm.__wbg_diagnostics_free(ptr, 0);
161
+ }
162
+ /**
163
+ * @returns {number}
164
+ */
165
+ get rmse() {
166
+ const ret = wasm.__wbg_get_diagnostics_rmse(this.__wbg_ptr);
167
+ return ret;
168
+ }
169
+ /**
170
+ * @param {number} arg0
171
+ */
172
+ set rmse(arg0) {
173
+ wasm.__wbg_set_diagnostics_rmse(this.__wbg_ptr, arg0);
174
+ }
175
+ /**
176
+ * @returns {number}
177
+ */
178
+ get mae() {
179
+ const ret = wasm.__wbg_get_diagnostics_mae(this.__wbg_ptr);
180
+ return ret;
181
+ }
182
+ /**
183
+ * @param {number} arg0
184
+ */
185
+ set mae(arg0) {
186
+ wasm.__wbg_set_diagnostics_mae(this.__wbg_ptr, arg0);
187
+ }
188
+ /**
189
+ * @returns {number}
190
+ */
191
+ get rSquared() {
192
+ const ret = wasm.__wbg_get_diagnostics_rSquared(this.__wbg_ptr);
193
+ return ret;
194
+ }
195
+ /**
196
+ * @param {number} arg0
197
+ */
198
+ set rSquared(arg0) {
199
+ wasm.__wbg_set_diagnostics_rSquared(this.__wbg_ptr, arg0);
200
+ }
201
+ /**
202
+ * @returns {number | undefined}
203
+ */
204
+ get aic() {
205
+ const ret = wasm.__wbg_get_diagnostics_aic(this.__wbg_ptr);
206
+ return ret[0] === 0 ? undefined : ret[1];
207
+ }
208
+ /**
209
+ * @param {number | null} [arg0]
210
+ */
211
+ set aic(arg0) {
212
+ wasm.__wbg_set_diagnostics_aic(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0);
213
+ }
214
+ /**
215
+ * @returns {number | undefined}
216
+ */
217
+ get aicc() {
218
+ const ret = wasm.__wbg_get_diagnostics_aicc(this.__wbg_ptr);
219
+ return ret[0] === 0 ? undefined : ret[1];
220
+ }
221
+ /**
222
+ * @param {number | null} [arg0]
223
+ */
224
+ set aicc(arg0) {
225
+ wasm.__wbg_set_diagnostics_aicc(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0);
226
+ }
227
+ /**
228
+ * @returns {number | undefined}
229
+ */
230
+ get effectiveDf() {
231
+ const ret = wasm.__wbg_get_diagnostics_effectiveDf(this.__wbg_ptr);
232
+ return ret[0] === 0 ? undefined : ret[1];
233
+ }
234
+ /**
235
+ * @param {number | null} [arg0]
236
+ */
237
+ set effectiveDf(arg0) {
238
+ wasm.__wbg_set_diagnostics_effectiveDf(this.__wbg_ptr, !isLikeNone(arg0), isLikeNone(arg0) ? 0 : arg0);
239
+ }
240
+ /**
241
+ * @returns {number}
242
+ */
243
+ get residualSd() {
244
+ const ret = wasm.__wbg_get_diagnostics_residualSd(this.__wbg_ptr);
245
+ return ret;
246
+ }
247
+ /**
248
+ * @param {number} arg0
249
+ */
250
+ set residualSd(arg0) {
251
+ wasm.__wbg_set_diagnostics_residualSd(this.__wbg_ptr, arg0);
252
+ }
253
+ }
254
+ if (Symbol.dispose) Diagnostics.prototype[Symbol.dispose] = Diagnostics.prototype.free;
255
+
256
+ export class LowessResultWasm {
257
+ static __wrap(ptr) {
258
+ ptr = ptr >>> 0;
259
+ const obj = Object.create(LowessResultWasm.prototype);
260
+ obj.__wbg_ptr = ptr;
261
+ LowessResultWasmFinalization.register(obj, obj.__wbg_ptr, obj);
262
+ return obj;
263
+ }
264
+ __destroy_into_raw() {
265
+ const ptr = this.__wbg_ptr;
266
+ this.__wbg_ptr = 0;
267
+ LowessResultWasmFinalization.unregister(this);
268
+ return ptr;
269
+ }
270
+ free() {
271
+ const ptr = this.__destroy_into_raw();
272
+ wasm.__wbg_lowessresultwasm_free(ptr, 0);
273
+ }
274
+ /**
275
+ * @returns {Diagnostics | undefined}
276
+ */
277
+ get diagnostics() {
278
+ const ret = wasm.lowessresultwasm_diagnostics(this.__wbg_ptr);
279
+ return ret === 0 ? undefined : Diagnostics.__wrap(ret);
280
+ }
281
+ /**
282
+ * @returns {number}
283
+ */
284
+ get fractionUsed() {
285
+ const ret = wasm.lowessresultwasm_fractionUsed(this.__wbg_ptr);
286
+ return ret;
287
+ }
288
+ /**
289
+ * @returns {number | undefined}
290
+ */
291
+ get iterationsUsed() {
292
+ const ret = wasm.lowessresultwasm_iterationsUsed(this.__wbg_ptr);
293
+ return ret === 0x100000001 ? undefined : ret;
294
+ }
295
+ /**
296
+ * @returns {Float64Array | undefined}
297
+ */
298
+ get standardErrors() {
299
+ const ret = wasm.lowessresultwasm_standardErrors(this.__wbg_ptr);
300
+ return ret;
301
+ }
302
+ /**
303
+ * @returns {Float64Array | undefined}
304
+ */
305
+ get confidenceLower() {
306
+ const ret = wasm.lowessresultwasm_confidenceLower(this.__wbg_ptr);
307
+ return ret;
308
+ }
309
+ /**
310
+ * @returns {Float64Array | undefined}
311
+ */
312
+ get confidenceUpper() {
313
+ const ret = wasm.lowessresultwasm_confidenceUpper(this.__wbg_ptr);
314
+ return ret;
315
+ }
316
+ /**
317
+ * @returns {Float64Array | undefined}
318
+ */
319
+ get predictionLower() {
320
+ const ret = wasm.lowessresultwasm_predictionLower(this.__wbg_ptr);
321
+ return ret;
322
+ }
323
+ /**
324
+ * @returns {Float64Array | undefined}
325
+ */
326
+ get predictionUpper() {
327
+ const ret = wasm.lowessresultwasm_predictionUpper(this.__wbg_ptr);
328
+ return ret;
329
+ }
330
+ /**
331
+ * @returns {Float64Array | undefined}
332
+ */
333
+ get robustnessWeights() {
334
+ const ret = wasm.lowessresultwasm_robustnessWeights(this.__wbg_ptr);
335
+ return ret;
336
+ }
337
+ /**
338
+ * @returns {Float64Array}
339
+ */
340
+ get x() {
341
+ const ret = wasm.lowessresultwasm_x(this.__wbg_ptr);
342
+ return ret;
343
+ }
344
+ /**
345
+ * @returns {Float64Array}
346
+ */
347
+ get y() {
348
+ const ret = wasm.lowessresultwasm_y(this.__wbg_ptr);
349
+ return ret;
350
+ }
351
+ /**
352
+ * @returns {Float64Array | undefined}
353
+ */
354
+ get cvScores() {
355
+ const ret = wasm.lowessresultwasm_cvScores(this.__wbg_ptr);
356
+ return ret;
357
+ }
358
+ /**
359
+ * @returns {Float64Array | undefined}
360
+ */
361
+ get residuals() {
362
+ const ret = wasm.lowessresultwasm_residuals(this.__wbg_ptr);
363
+ return ret;
364
+ }
365
+ }
366
+ if (Symbol.dispose) LowessResultWasm.prototype[Symbol.dispose] = LowessResultWasm.prototype.free;
367
+
368
+ export class OnlineLowessWasm {
369
+ __destroy_into_raw() {
370
+ const ptr = this.__wbg_ptr;
371
+ this.__wbg_ptr = 0;
372
+ OnlineLowessWasmFinalization.unregister(this);
373
+ return ptr;
374
+ }
375
+ free() {
376
+ const ptr = this.__destroy_into_raw();
377
+ wasm.__wbg_onlinelowesswasm_free(ptr, 0);
378
+ }
379
+ /**
380
+ * @param {any} options
381
+ * @param {any} online_opts
382
+ */
383
+ constructor(options, online_opts) {
384
+ const ret = wasm.onlinelowesswasm_new(options, online_opts);
385
+ if (ret[2]) {
386
+ throw takeFromExternrefTable0(ret[1]);
387
+ }
388
+ this.__wbg_ptr = ret[0] >>> 0;
389
+ OnlineLowessWasmFinalization.register(this, this.__wbg_ptr, this);
390
+ return this;
391
+ }
392
+ /**
393
+ * @param {number} x
394
+ * @param {number} y
395
+ * @returns {number | undefined}
396
+ */
397
+ update(x, y) {
398
+ const ret = wasm.onlinelowesswasm_update(this.__wbg_ptr, x, y);
399
+ if (ret[3]) {
400
+ throw takeFromExternrefTable0(ret[2]);
401
+ }
402
+ return ret[0] === 0 ? undefined : ret[1];
403
+ }
404
+ }
405
+ if (Symbol.dispose) OnlineLowessWasm.prototype[Symbol.dispose] = OnlineLowessWasm.prototype.free;
406
+
407
+ export class StreamingLowessWasm {
408
+ __destroy_into_raw() {
409
+ const ptr = this.__wbg_ptr;
410
+ this.__wbg_ptr = 0;
411
+ StreamingLowessWasmFinalization.unregister(this);
412
+ return ptr;
413
+ }
414
+ free() {
415
+ const ptr = this.__destroy_into_raw();
416
+ wasm.__wbg_streaminglowesswasm_free(ptr, 0);
417
+ }
418
+ /**
419
+ * @param {Float64Array} x
420
+ * @param {Float64Array} y
421
+ * @returns {LowessResultWasm}
422
+ */
423
+ processChunk(x, y) {
424
+ const ret = wasm.streaminglowesswasm_processChunk(this.__wbg_ptr, x, y);
425
+ if (ret[2]) {
426
+ throw takeFromExternrefTable0(ret[1]);
427
+ }
428
+ return LowessResultWasm.__wrap(ret[0]);
429
+ }
430
+ /**
431
+ * @param {any} options
432
+ * @param {any} streaming_opts
433
+ */
434
+ constructor(options, streaming_opts) {
435
+ const ret = wasm.streaminglowesswasm_new(options, streaming_opts);
436
+ if (ret[2]) {
437
+ throw takeFromExternrefTable0(ret[1]);
438
+ }
439
+ this.__wbg_ptr = ret[0] >>> 0;
440
+ StreamingLowessWasmFinalization.register(this, this.__wbg_ptr, this);
441
+ return this;
442
+ }
443
+ /**
444
+ * @returns {LowessResultWasm}
445
+ */
446
+ finalize() {
447
+ const ret = wasm.streaminglowesswasm_finalize(this.__wbg_ptr);
448
+ if (ret[2]) {
449
+ throw takeFromExternrefTable0(ret[1]);
450
+ }
451
+ return LowessResultWasm.__wrap(ret[0]);
452
+ }
453
+ }
454
+ if (Symbol.dispose) StreamingLowessWasm.prototype[Symbol.dispose] = StreamingLowessWasm.prototype.free;
455
+
456
+ /**
457
+ * @param {Float64Array} x
458
+ * @param {Float64Array} y
459
+ * @param {any} options
460
+ * @returns {LowessResultWasm}
461
+ */
462
+ export function smooth(x, y, options) {
463
+ const ret = wasm.smooth(x, y, options);
464
+ if (ret[2]) {
465
+ throw takeFromExternrefTable0(ret[1]);
466
+ }
467
+ return LowessResultWasm.__wrap(ret[0]);
468
+ }
469
+
470
+ const EXPECTED_RESPONSE_TYPES = new Set(['basic', 'cors', 'default']);
471
+
472
+ async function __wbg_load(module, imports) {
473
+ if (typeof Response === 'function' && module instanceof Response) {
474
+ if (typeof WebAssembly.instantiateStreaming === 'function') {
475
+ try {
476
+ return await WebAssembly.instantiateStreaming(module, imports);
477
+ } catch (e) {
478
+ const validResponse = module.ok && EXPECTED_RESPONSE_TYPES.has(module.type);
479
+
480
+ if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
481
+ 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);
482
+
483
+ } else {
484
+ throw e;
485
+ }
486
+ }
487
+ }
488
+
489
+ const bytes = await module.arrayBuffer();
490
+ return await WebAssembly.instantiate(bytes, imports);
491
+ } else {
492
+ const instance = await WebAssembly.instantiate(module, imports);
493
+
494
+ if (instance instanceof WebAssembly.Instance) {
495
+ return { instance, module };
496
+ } else {
497
+ return instance;
498
+ }
499
+ }
500
+ }
501
+
502
+ function __wbg_get_imports() {
503
+ const imports = {};
504
+ imports.wbg = {};
505
+ imports.wbg.__wbg___wbindgen_boolean_get_dea25b33882b895b = function(arg0) {
506
+ const v = arg0;
507
+ const ret = typeof(v) === 'boolean' ? v : undefined;
508
+ return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
509
+ };
510
+ imports.wbg.__wbg___wbindgen_is_null_dfda7d66506c95b5 = function(arg0) {
511
+ const ret = arg0 === null;
512
+ return ret;
513
+ };
514
+ imports.wbg.__wbg___wbindgen_is_undefined_f6b95eab589e0269 = function(arg0) {
515
+ const ret = arg0 === undefined;
516
+ return ret;
517
+ };
518
+ imports.wbg.__wbg___wbindgen_number_get_9619185a74197f95 = function(arg0, arg1) {
519
+ const obj = arg1;
520
+ const ret = typeof(obj) === 'number' ? obj : undefined;
521
+ getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
522
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
523
+ };
524
+ imports.wbg.__wbg___wbindgen_string_get_a2a31e16edf96e42 = function(arg0, arg1) {
525
+ const obj = arg1;
526
+ const ret = typeof(obj) === 'string' ? obj : undefined;
527
+ var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
528
+ var len1 = WASM_VECTOR_LEN;
529
+ getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
530
+ getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
531
+ };
532
+ imports.wbg.__wbg___wbindgen_throw_dd24417ed36fc46e = function(arg0, arg1) {
533
+ throw new Error(getStringFromWasm0(arg0, arg1));
534
+ };
535
+ imports.wbg.__wbg_from_29a8414a7a7cd19d = function(arg0) {
536
+ const ret = Array.from(arg0);
537
+ return ret;
538
+ };
539
+ imports.wbg.__wbg_get_6b7bd52aca3f9671 = function(arg0, arg1) {
540
+ const ret = arg0[arg1 >>> 0];
541
+ return ret;
542
+ };
543
+ imports.wbg.__wbg_get_af9dab7e9603ea93 = function() { return handleError(function (arg0, arg1) {
544
+ const ret = Reflect.get(arg0, arg1);
545
+ return ret;
546
+ }, arguments) };
547
+ imports.wbg.__wbg_length_406f6daaaa453057 = function(arg0) {
548
+ const ret = arg0.length;
549
+ return ret;
550
+ };
551
+ imports.wbg.__wbg_length_d45040a40c570362 = function(arg0) {
552
+ const ret = arg0.length;
553
+ return ret;
554
+ };
555
+ imports.wbg.__wbg_prototypesetcall_d3c4edbb4ef96ca1 = function(arg0, arg1, arg2) {
556
+ Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
557
+ };
558
+ imports.wbg.__wbindgen_cast_2241b6af4c4b2941 = function(arg0, arg1) {
559
+ // Cast intrinsic for `Ref(String) -> Externref`.
560
+ const ret = getStringFromWasm0(arg0, arg1);
561
+ return ret;
562
+ };
563
+ imports.wbg.__wbindgen_cast_4af8e60a922bcf35 = function(arg0, arg1) {
564
+ // Cast intrinsic for `Ref(Slice(F64)) -> NamedExternref("Float64Array")`.
565
+ const ret = getArrayF64FromWasm0(arg0, arg1);
566
+ return ret;
567
+ };
568
+ imports.wbg.__wbindgen_init_externref_table = function() {
569
+ const table = wasm.__wbindgen_externrefs;
570
+ const offset = table.grow(4);
571
+ table.set(0, undefined);
572
+ table.set(offset + 0, undefined);
573
+ table.set(offset + 1, null);
574
+ table.set(offset + 2, true);
575
+ table.set(offset + 3, false);
576
+ };
577
+
578
+ return imports;
579
+ }
580
+
581
+ function __wbg_finalize_init(instance, module) {
582
+ wasm = instance.exports;
583
+ __wbg_init.__wbindgen_wasm_module = module;
584
+ cachedDataViewMemory0 = null;
585
+ cachedFloat64ArrayMemory0 = null;
586
+ cachedUint8ArrayMemory0 = null;
587
+
588
+
589
+ wasm.__wbindgen_start();
590
+ return wasm;
591
+ }
592
+
593
+ function initSync(module) {
594
+ if (wasm !== undefined) return wasm;
595
+
596
+
597
+ if (typeof module !== 'undefined') {
598
+ if (Object.getPrototypeOf(module) === Object.prototype) {
599
+ ({module} = module)
600
+ } else {
601
+ console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
602
+ }
603
+ }
604
+
605
+ const imports = __wbg_get_imports();
606
+ if (!(module instanceof WebAssembly.Module)) {
607
+ module = new WebAssembly.Module(module);
608
+ }
609
+ const instance = new WebAssembly.Instance(module, imports);
610
+ return __wbg_finalize_init(instance, module);
611
+ }
612
+
613
+ async function __wbg_init(module_or_path) {
614
+ if (wasm !== undefined) return wasm;
615
+
616
+
617
+ if (typeof module_or_path !== 'undefined') {
618
+ if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
619
+ ({module_or_path} = module_or_path)
620
+ } else {
621
+ console.warn('using deprecated parameters for the initialization function; pass a single object instead')
622
+ }
623
+ }
624
+
625
+ if (typeof module_or_path === 'undefined') {
626
+ module_or_path = new URL('fastlowess_wasm_bg.wasm', import.meta.url);
627
+ }
628
+ const imports = __wbg_get_imports();
629
+
630
+ if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
631
+ module_or_path = fetch(module_or_path);
632
+ }
633
+
634
+ const { instance, module } = await __wbg_load(await module_or_path, imports);
635
+
636
+ return __wbg_finalize_init(instance, module);
637
+ }
638
+
639
+ export { initSync };
640
+ export default __wbg_init;
Binary file
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "fastlowess-wasm",
3
+ "type": "module",
4
+ "version": "0.99.8",
5
+ "license": "MIT OR Apache-2.0",
6
+ "files": [
7
+ "fastlowess_wasm_bg.wasm",
8
+ "fastlowess_wasm.js",
9
+ "fastlowess_wasm.d.ts"
10
+ ],
11
+ "main": "fastlowess_wasm.js",
12
+ "types": "fastlowess_wasm.d.ts",
13
+ "sideEffects": [
14
+ "./snippets/*"
15
+ ]
16
+ }