loop-interpolation-core 0.1.0__tar.gz

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.
Files changed (52) hide show
  1. loop_interpolation_core-0.1.0/CHANGELOG.md +8 -0
  2. loop_interpolation_core-0.1.0/Cargo.lock +355 -0
  3. loop_interpolation_core-0.1.0/Cargo.toml +28 -0
  4. loop_interpolation_core-0.1.0/PKG-INFO +159 -0
  5. loop_interpolation_core-0.1.0/README.md +136 -0
  6. loop_interpolation_core-0.1.0/fixtures/fixture_20.bin +0 -0
  7. loop_interpolation_core-0.1.0/fixtures/make_fixture.py +289 -0
  8. loop_interpolation_core-0.1.0/pyproject.toml +33 -0
  9. loop_interpolation_core-0.1.0/scripts/build_wasm.sh +50 -0
  10. loop_interpolation_core-0.1.0/scripts/check_wasm_size.py +32 -0
  11. loop_interpolation_core-0.1.0/src/admm.rs +579 -0
  12. loop_interpolation_core-0.1.0/src/cg.rs +487 -0
  13. loop_interpolation_core-0.1.0/src/class_stencil.rs +314 -0
  14. loop_interpolation_core-0.1.0/src/error.rs +95 -0
  15. loop_interpolation_core-0.1.0/src/field.rs +99 -0
  16. loop_interpolation_core-0.1.0/src/grid.rs +272 -0
  17. loop_interpolation_core-0.1.0/src/interpolator.rs +4845 -0
  18. loop_interpolation_core-0.1.0/src/lib.rs +66 -0
  19. loop_interpolation_core-0.1.0/src/memory.rs +343 -0
  20. loop_interpolation_core-0.1.0/src/par.rs +65 -0
  21. loop_interpolation_core-0.1.0/src/problem.rs +590 -0
  22. loop_interpolation_core-0.1.0/src/python.rs +405 -0
  23. loop_interpolation_core-0.1.0/src/report.rs +45 -0
  24. loop_interpolation_core-0.1.0/src/scalar.rs +65 -0
  25. loop_interpolation_core-0.1.0/src/session.rs +469 -0
  26. loop_interpolation_core-0.1.0/src/settings.rs +41 -0
  27. loop_interpolation_core-0.1.0/src/stencil.rs +820 -0
  28. loop_interpolation_core-0.1.0/src/wasm.rs +603 -0
  29. loop_interpolation_core-0.1.0/tests/class_stencil.rs +168 -0
  30. loop_interpolation_core-0.1.0/tests/common/mod.rs +75 -0
  31. loop_interpolation_core-0.1.0/tests/constraint_families.rs +213 -0
  32. loop_interpolation_core-0.1.0/tests/edge_cases.rs +444 -0
  33. loop_interpolation_core-0.1.0/tests/input_validation.rs +205 -0
  34. loop_interpolation_core-0.1.0/tests/memory.rs +150 -0
  35. loop_interpolation_core-0.1.0/tests/memory_estimate.rs +202 -0
  36. loop_interpolation_core-0.1.0/tests/parity_fixture.rs +242 -0
  37. loop_interpolation_core-0.1.0/tests/precision_f32.rs +198 -0
  38. loop_interpolation_core-0.1.0/tests/reference_problems.rs +245 -0
  39. loop_interpolation_core-0.1.0/tests/scale_inequality.rs +248 -0
  40. loop_interpolation_core-0.1.0/tests/session_admm.rs +252 -0
  41. loop_interpolation_core-0.1.0/tests/session_cg.rs +276 -0
  42. loop_interpolation_core-0.1.0/tests/warm_start_ridge.rs +278 -0
  43. loop_interpolation_core-0.1.0/tests_web/fixture.spec.js +35 -0
  44. loop_interpolation_core-0.1.0/tests_web/harness.html +178 -0
  45. loop_interpolation_core-0.1.0/tests_web/package-lock.json +93 -0
  46. loop_interpolation_core-0.1.0/tests_web/package.json +13 -0
  47. loop_interpolation_core-0.1.0/tests_web/playwright.config.js +29 -0
  48. loop_interpolation_core-0.1.0/tests_web/reference.spec.js +171 -0
  49. loop_interpolation_core-0.1.0/tests_web/responsiveness.spec.js +221 -0
  50. loop_interpolation_core-0.1.0/web/README.md +136 -0
  51. loop_interpolation_core-0.1.0/web/index.d.ts +311 -0
  52. loop_interpolation_core-0.1.0/web/worker.js +403 -0
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-10-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * **loop-interpolation-core:** add a low-memory native solver for Python and the browser ([#354](https://github.com/Loop3D/LoopStructural/issues/354)) ([e5c7539](https://github.com/Loop3D/LoopStructural/commit/e5c7539c63c64d4cdc18e6b9eb76d44386ad4e92))
@@ -0,0 +1,355 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 4
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.5.1"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
10
+
11
+ [[package]]
12
+ name = "bumpalo"
13
+ version = "3.20.3"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
16
+
17
+ [[package]]
18
+ name = "cfg-if"
19
+ version = "1.0.5"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
22
+
23
+ [[package]]
24
+ name = "crossbeam-deque"
25
+ version = "0.8.8"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "622f3fc73690be383c7214310406f28a90e6edeadc3cea882f9d71e495b9711a"
28
+ dependencies = [
29
+ "crossbeam-epoch",
30
+ "crossbeam-utils",
31
+ ]
32
+
33
+ [[package]]
34
+ name = "crossbeam-epoch"
35
+ version = "0.9.21"
36
+ source = "registry+https://github.com/rust-lang/crates.io-index"
37
+ checksum = "dc74980687109a3b14c72fd458107bf0baa1da1a1a805e178d15501ba9b86d9d"
38
+ dependencies = [
39
+ "crossbeam-utils",
40
+ ]
41
+
42
+ [[package]]
43
+ name = "crossbeam-utils"
44
+ version = "0.8.23"
45
+ source = "registry+https://github.com/rust-lang/crates.io-index"
46
+ checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6"
47
+
48
+ [[package]]
49
+ name = "either"
50
+ version = "1.19.0"
51
+ source = "registry+https://github.com/rust-lang/crates.io-index"
52
+ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
53
+
54
+ [[package]]
55
+ name = "heck"
56
+ version = "0.5.0"
57
+ source = "registry+https://github.com/rust-lang/crates.io-index"
58
+ checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
59
+
60
+ [[package]]
61
+ name = "libc"
62
+ version = "0.2.191"
63
+ source = "registry+https://github.com/rust-lang/crates.io-index"
64
+ checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
65
+
66
+ [[package]]
67
+ name = "loop-interpolation-core"
68
+ version = "0.1.0"
69
+ dependencies = [
70
+ "numpy",
71
+ "pyo3",
72
+ "rayon",
73
+ "wasm-bindgen",
74
+ ]
75
+
76
+ [[package]]
77
+ name = "matrixmultiply"
78
+ version = "0.3.11"
79
+ source = "registry+https://github.com/rust-lang/crates.io-index"
80
+ checksum = "3f607c237553f086e7043417a51df26b2eb899d3caff94e6a67592ff992fedc7"
81
+ dependencies = [
82
+ "autocfg",
83
+ "rawpointer",
84
+ ]
85
+
86
+ [[package]]
87
+ name = "ndarray"
88
+ version = "0.17.2"
89
+ source = "registry+https://github.com/rust-lang/crates.io-index"
90
+ checksum = "520080814a7a6b4a6e9070823bb24b4531daac8c4627e08ba5de8c5ef2f2752d"
91
+ dependencies = [
92
+ "matrixmultiply",
93
+ "num-complex",
94
+ "num-integer",
95
+ "num-traits",
96
+ "portable-atomic",
97
+ "portable-atomic-util",
98
+ "rawpointer",
99
+ ]
100
+
101
+ [[package]]
102
+ name = "num-complex"
103
+ version = "0.4.6"
104
+ source = "registry+https://github.com/rust-lang/crates.io-index"
105
+ checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495"
106
+ dependencies = [
107
+ "num-traits",
108
+ ]
109
+
110
+ [[package]]
111
+ name = "num-integer"
112
+ version = "0.1.47"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b"
115
+ dependencies = [
116
+ "num-traits",
117
+ ]
118
+
119
+ [[package]]
120
+ name = "num-traits"
121
+ version = "0.2.19"
122
+ source = "registry+https://github.com/rust-lang/crates.io-index"
123
+ checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
124
+ dependencies = [
125
+ "autocfg",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "numpy"
130
+ version = "0.29.0"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "6a5b15d63a5ff39e378daed0e1340d3a5964703ea9712eb09a0dc66fade996f4"
133
+ dependencies = [
134
+ "libc",
135
+ "ndarray",
136
+ "num-complex",
137
+ "num-integer",
138
+ "num-traits",
139
+ "pyo3",
140
+ "pyo3-build-config",
141
+ "rustc-hash",
142
+ ]
143
+
144
+ [[package]]
145
+ name = "once_cell"
146
+ version = "1.21.4"
147
+ source = "registry+https://github.com/rust-lang/crates.io-index"
148
+ checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
149
+
150
+ [[package]]
151
+ name = "portable-atomic"
152
+ version = "1.15.0"
153
+ source = "registry+https://github.com/rust-lang/crates.io-index"
154
+ checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
155
+
156
+ [[package]]
157
+ name = "portable-atomic-util"
158
+ version = "0.2.8"
159
+ source = "registry+https://github.com/rust-lang/crates.io-index"
160
+ checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715"
161
+ dependencies = [
162
+ "portable-atomic",
163
+ ]
164
+
165
+ [[package]]
166
+ name = "proc-macro2"
167
+ version = "1.0.107"
168
+ source = "registry+https://github.com/rust-lang/crates.io-index"
169
+ checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
170
+ dependencies = [
171
+ "unicode-ident",
172
+ ]
173
+
174
+ [[package]]
175
+ name = "pyo3"
176
+ version = "0.29.3"
177
+ source = "registry+https://github.com/rust-lang/crates.io-index"
178
+ checksum = "700d18fa267b73b9b521fd7e13580e2f446916f176cacee1ab63fcc8191f1655"
179
+ dependencies = [
180
+ "libc",
181
+ "once_cell",
182
+ "portable-atomic",
183
+ "pyo3-build-config",
184
+ "pyo3-ffi",
185
+ "pyo3-macros",
186
+ ]
187
+
188
+ [[package]]
189
+ name = "pyo3-build-config"
190
+ version = "0.29.3"
191
+ source = "registry+https://github.com/rust-lang/crates.io-index"
192
+ checksum = "7b3fc0c4d08f6bb10e71fe39dfb9e2f59c6eb6854e22ec8092f50c69a4499adb"
193
+ dependencies = [
194
+ "target-lexicon",
195
+ ]
196
+
197
+ [[package]]
198
+ name = "pyo3-ffi"
199
+ version = "0.29.3"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "dfc0b8e19df29aad7086cf977bb0c2a2f143e30567eb113e9cf72b62ca698330"
202
+ dependencies = [
203
+ "libc",
204
+ "pyo3-build-config",
205
+ ]
206
+
207
+ [[package]]
208
+ name = "pyo3-macros"
209
+ version = "0.29.3"
210
+ source = "registry+https://github.com/rust-lang/crates.io-index"
211
+ checksum = "6100e8a4b5eba53afaa5ed078364851a0b2499c553a44c31026b929049b49dc6"
212
+ dependencies = [
213
+ "proc-macro2",
214
+ "pyo3-macros-backend",
215
+ "quote",
216
+ "syn 2.0.119",
217
+ ]
218
+
219
+ [[package]]
220
+ name = "pyo3-macros-backend"
221
+ version = "0.29.3"
222
+ source = "registry+https://github.com/rust-lang/crates.io-index"
223
+ checksum = "6143877a16e82b5a727b7127ff4cd86858a24a28d745d72f43e6f227c7b1bdb3"
224
+ dependencies = [
225
+ "heck",
226
+ "proc-macro2",
227
+ "quote",
228
+ "syn 2.0.119",
229
+ ]
230
+
231
+ [[package]]
232
+ name = "quote"
233
+ version = "1.0.47"
234
+ source = "registry+https://github.com/rust-lang/crates.io-index"
235
+ checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
236
+ dependencies = [
237
+ "proc-macro2",
238
+ ]
239
+
240
+ [[package]]
241
+ name = "rawpointer"
242
+ version = "0.2.1"
243
+ source = "registry+https://github.com/rust-lang/crates.io-index"
244
+ checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
245
+
246
+ [[package]]
247
+ name = "rayon"
248
+ version = "1.12.0"
249
+ source = "registry+https://github.com/rust-lang/crates.io-index"
250
+ checksum = "fb39b166781f92d482534ef4b4b1b2568f42613b53e5b6c160e24cfbfa30926d"
251
+ dependencies = [
252
+ "either",
253
+ "rayon-core",
254
+ ]
255
+
256
+ [[package]]
257
+ name = "rayon-core"
258
+ version = "1.13.0"
259
+ source = "registry+https://github.com/rust-lang/crates.io-index"
260
+ checksum = "22e18b0f0062d30d4230b2e85ff77fdfe4326feb054b9783a3460d8435c8ab91"
261
+ dependencies = [
262
+ "crossbeam-deque",
263
+ "crossbeam-utils",
264
+ ]
265
+
266
+ [[package]]
267
+ name = "rustc-hash"
268
+ version = "2.1.3"
269
+ source = "registry+https://github.com/rust-lang/crates.io-index"
270
+ checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"
271
+
272
+ [[package]]
273
+ name = "rustversion"
274
+ version = "1.0.23"
275
+ source = "registry+https://github.com/rust-lang/crates.io-index"
276
+ checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"
277
+
278
+ [[package]]
279
+ name = "syn"
280
+ version = "2.0.119"
281
+ source = "registry+https://github.com/rust-lang/crates.io-index"
282
+ checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297"
283
+ dependencies = [
284
+ "proc-macro2",
285
+ "quote",
286
+ "unicode-ident",
287
+ ]
288
+
289
+ [[package]]
290
+ name = "syn"
291
+ version = "3.0.9"
292
+ source = "registry+https://github.com/rust-lang/crates.io-index"
293
+ checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
294
+ dependencies = [
295
+ "proc-macro2",
296
+ "quote",
297
+ "unicode-ident",
298
+ ]
299
+
300
+ [[package]]
301
+ name = "target-lexicon"
302
+ version = "0.13.5"
303
+ source = "registry+https://github.com/rust-lang/crates.io-index"
304
+ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
305
+
306
+ [[package]]
307
+ name = "unicode-ident"
308
+ version = "1.0.27"
309
+ source = "registry+https://github.com/rust-lang/crates.io-index"
310
+ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
311
+
312
+ [[package]]
313
+ name = "wasm-bindgen"
314
+ version = "0.2.129"
315
+ source = "registry+https://github.com/rust-lang/crates.io-index"
316
+ checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
317
+ dependencies = [
318
+ "cfg-if",
319
+ "once_cell",
320
+ "rustversion",
321
+ "wasm-bindgen-macro",
322
+ "wasm-bindgen-shared",
323
+ ]
324
+
325
+ [[package]]
326
+ name = "wasm-bindgen-macro"
327
+ version = "0.2.129"
328
+ source = "registry+https://github.com/rust-lang/crates.io-index"
329
+ checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"
330
+ dependencies = [
331
+ "quote",
332
+ "wasm-bindgen-macro-support",
333
+ ]
334
+
335
+ [[package]]
336
+ name = "wasm-bindgen-macro-support"
337
+ version = "0.2.129"
338
+ source = "registry+https://github.com/rust-lang/crates.io-index"
339
+ checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"
340
+ dependencies = [
341
+ "bumpalo",
342
+ "proc-macro2",
343
+ "quote",
344
+ "syn 3.0.9",
345
+ "wasm-bindgen-shared",
346
+ ]
347
+
348
+ [[package]]
349
+ name = "wasm-bindgen-shared"
350
+ version = "0.2.129"
351
+ source = "registry+https://github.com/rust-lang/crates.io-index"
352
+ checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"
353
+ dependencies = [
354
+ "unicode-ident",
355
+ ]
@@ -0,0 +1,28 @@
1
+ [package]
2
+ name = "loop-interpolation-core"
3
+ version = "0.1.0"
4
+ edition = "2024"
5
+ readme = "README.md"
6
+
7
+ [lib]
8
+ name = "loop_interpolation_core"
9
+ crate-type = ["cdylib", "rlib"]
10
+
11
+ [dependencies]
12
+ rayon = { version = "1.10", optional = true }
13
+ pyo3 = { version = "0.29", features = ["extension-module", "abi3-py39"], optional = true }
14
+ numpy = { version = "0.29", optional = true }
15
+ wasm-bindgen = { version = "0.2", optional = true }
16
+
17
+ [features]
18
+ default = []
19
+ parallel = ["dep:rayon"]
20
+ python = ["dep:pyo3", "dep:numpy"]
21
+ wasm = ["dep:wasm-bindgen"]
22
+
23
+ [profile.wasm-size]
24
+ inherits = "release"
25
+ opt-level = "z"
26
+ lto = true
27
+ codegen-units = 1
28
+ panic = "abort"
@@ -0,0 +1,159 @@
1
+ Metadata-Version: 2.4
2
+ Name: loop-interpolation-core
3
+ Version: 0.1.0
4
+ Classifier: Development Status :: 4 - Beta
5
+ Classifier: Intended Audience :: Science/Research
6
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
7
+ Classifier: License :: OSI Approved :: MIT License
8
+ Classifier: Operating System :: Microsoft :: Windows
9
+ Classifier: Operating System :: POSIX :: Linux
10
+ Classifier: Operating System :: MacOS
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Rust
13
+ Requires-Dist: numpy
14
+ Summary: Native (Rust) core for the low-memory LoopStructural interpolator
15
+ Author-email: Lachlan Grose <lachlan.grose@monash.edu>
16
+ License: MIT
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
19
+ Project-URL: Bug Tracker, https://github.com/loop3d/loopstructural/issues
20
+ Project-URL: Documentation, https://Loop3d.org/LoopStructural/
21
+ Project-URL: Source Code, https://github.com/loop3d/loopstructural
22
+
23
+ # loop-interpolation-core
24
+
25
+ ## Purpose
26
+
27
+ This package is the native core of the low-memory interpolator. It is a
28
+ Python extension module, built with maturin. It is named
29
+ `loop_interpolation_core` on import. The package solves the finite
30
+ difference interpolation problem without building the sparse constraint
31
+ rows in Python.
32
+
33
+ The package is optional. The `loop-interpolation` package works without it.
34
+
35
+ ## Specification
36
+
37
+ The requirements and the design are in
38
+ [specs/001-low-memory-interpolator/spec.md](../../specs/001-low-memory-interpolator/spec.md).
39
+
40
+ ## Forms
41
+
42
+ The crate builds in three forms:
43
+
44
+ - Rust library (rlib). Use it from other Rust crates.
45
+ - Python module (PyO3). It uses the abi3 stable ABI, so one wheel works for
46
+ Python 3.9 and later.
47
+ - Browser module (wasm-bindgen). It runs in a Web Worker. The worker code is
48
+ in `web/`.
49
+
50
+ ## Feature flags
51
+
52
+ | Feature | Effect |
53
+ |---|---|
54
+ | `parallel` | Uses rayon threads. Off for cargo by default. On for the Python wheel. |
55
+ | `python` | Builds the PyO3 bindings. |
56
+ | `wasm` | Builds the wasm-bindgen bindings. |
57
+
58
+ With no feature, the code runs on one thread and has no dependency.
59
+
60
+ ## Build commands
61
+
62
+ ### Python module
63
+
64
+ ```text
65
+ pip install maturin
66
+ maturin develop --release -m packages/loop_interpolation_core/Cargo.toml
67
+ ```
68
+
69
+ The `pyproject.toml` sets the features `python` and `parallel`. If you pass
70
+ `--features`, you must list both: `--features python,parallel`. The option
71
+ `--features parallel` alone replaces the list. The build then fails with an
72
+ "install cffi" message.
73
+
74
+ ### Browser module
75
+
76
+ ```text
77
+ bash packages/loop_interpolation_core/scripts/build_wasm.sh
78
+ ```
79
+
80
+ You need these tools:
81
+
82
+ - The `wasm32-unknown-unknown` Rust target.
83
+ - A `wasm-bindgen` CLI with the same version as the `wasm-bindgen` crate in
84
+ `Cargo.lock`. The script stops if the versions differ.
85
+ - `wasm-opt` is optional. If it is missing, the script skips this step.
86
+
87
+ The script writes the output to `packages/loop_interpolation_core/pkg/`.
88
+
89
+ ### Tests and lint
90
+
91
+ Run these commands from `packages/loop_interpolation_core`:
92
+
93
+ ```text
94
+ cargo test --release
95
+ cargo test --release --features parallel
96
+
97
+ cargo clippy --all-targets -- -D warnings
98
+ cargo clippy --all-targets --features python -- -D warnings
99
+ cargo clippy --features wasm --target wasm32-unknown-unknown -- -D warnings
100
+ ```
101
+
102
+ To run the browser tests:
103
+
104
+ ```text
105
+ npm --prefix packages/loop_interpolation_core/tests_web ci
106
+ npm --prefix packages/loop_interpolation_core/tests_web test
107
+ ```
108
+
109
+ ## Contract
110
+
111
+ - Inputs are flat arrays. Points are stored as 3n values, one x, y, z set
112
+ for each point.
113
+ - The grid uses grid coordinates only. The grid has no rotation. The caller
114
+ transforms the coordinates.
115
+ - Node order is x fastest.
116
+ - Errors name the constraint that failed. For example, `value[3]`.
117
+ - A solve is a session. You step the session to advance the solve. To cancel
118
+ it, drop the session.
119
+ - The memory estimate is available before the solve.
120
+ - Set `budget_bytes` to limit the memory of a solve.
121
+
122
+ ## Differences from loop-rs
123
+
124
+ - Grid rotation is removed. The functions `rotation`, `to_local` and
125
+ `direction_to_local` are not in this crate. The `serde` feature is also
126
+ removed.
127
+ - Solve sessions replace the closure-style solvers. A session has step and
128
+ cancel.
129
+ - Memory tracking is new. The crate uses `try_reserve`, a byte budget and a
130
+ memory estimate.
131
+ - Curvature rows are added only at nodes that are interior on all three
132
+ axes. The border rows are centred second derivatives `[1, -2, 1]` on
133
+ layers 1 and n-2. The gradient strike and dip basis is the Python
134
+ strike and dip basis. So the field equals the field of the Python matrix
135
+ solver.
136
+ - Only the ADMM solver is in this crate. There is no active-set solver and
137
+ no hybrid solver. A feasibility check runs before the solve. The solver
138
+ stops when the violation is at most 1e-4 of the field range.
139
+ - Single precision (`f32`) is available. The residual check runs in double
140
+ precision.
141
+
142
+ ## Measured values
143
+
144
+ - Memory: 63 bytes per node for R1, a 100 x 100 x 100 grid with 2000 value
145
+ rows and 500 gradient rows. The value is the peak heap size divided by
146
+ the number of nodes. It does not include the copy of the field that goes
147
+ to JavaScript, which takes 8 bytes per node.
148
+ - Comparison with the Python matrix solver on a 100 x 100 x 100 grid: the
149
+ native solver uses 84 MB where the matrix solver uses 2445 MB (29 times
150
+ less). On one thread it is 10 to 30 percent slower. With the `parallel`
151
+ feature (the default of the Python wheel) it is about 3 times faster. The
152
+ numbers are in `specs/001-low-memory-interpolator/measurements.md`.
153
+ - Browser size: the gzip size of the `.wasm` file is about 92 KB. The
154
+ limit is 2 MB.
155
+
156
+ ## Source
157
+
158
+ Source: loop-rs crates/interpolation-fd, commit bff51342da8ebff7ca3c87e07c1d4fbd31279c8b, branch lachlan/drillhole
159
+
@@ -0,0 +1,136 @@
1
+ # loop-interpolation-core
2
+
3
+ ## Purpose
4
+
5
+ This package is the native core of the low-memory interpolator. It is a
6
+ Python extension module, built with maturin. It is named
7
+ `loop_interpolation_core` on import. The package solves the finite
8
+ difference interpolation problem without building the sparse constraint
9
+ rows in Python.
10
+
11
+ The package is optional. The `loop-interpolation` package works without it.
12
+
13
+ ## Specification
14
+
15
+ The requirements and the design are in
16
+ [specs/001-low-memory-interpolator/spec.md](../../specs/001-low-memory-interpolator/spec.md).
17
+
18
+ ## Forms
19
+
20
+ The crate builds in three forms:
21
+
22
+ - Rust library (rlib). Use it from other Rust crates.
23
+ - Python module (PyO3). It uses the abi3 stable ABI, so one wheel works for
24
+ Python 3.9 and later.
25
+ - Browser module (wasm-bindgen). It runs in a Web Worker. The worker code is
26
+ in `web/`.
27
+
28
+ ## Feature flags
29
+
30
+ | Feature | Effect |
31
+ |---|---|
32
+ | `parallel` | Uses rayon threads. Off for cargo by default. On for the Python wheel. |
33
+ | `python` | Builds the PyO3 bindings. |
34
+ | `wasm` | Builds the wasm-bindgen bindings. |
35
+
36
+ With no feature, the code runs on one thread and has no dependency.
37
+
38
+ ## Build commands
39
+
40
+ ### Python module
41
+
42
+ ```text
43
+ pip install maturin
44
+ maturin develop --release -m packages/loop_interpolation_core/Cargo.toml
45
+ ```
46
+
47
+ The `pyproject.toml` sets the features `python` and `parallel`. If you pass
48
+ `--features`, you must list both: `--features python,parallel`. The option
49
+ `--features parallel` alone replaces the list. The build then fails with an
50
+ "install cffi" message.
51
+
52
+ ### Browser module
53
+
54
+ ```text
55
+ bash packages/loop_interpolation_core/scripts/build_wasm.sh
56
+ ```
57
+
58
+ You need these tools:
59
+
60
+ - The `wasm32-unknown-unknown` Rust target.
61
+ - A `wasm-bindgen` CLI with the same version as the `wasm-bindgen` crate in
62
+ `Cargo.lock`. The script stops if the versions differ.
63
+ - `wasm-opt` is optional. If it is missing, the script skips this step.
64
+
65
+ The script writes the output to `packages/loop_interpolation_core/pkg/`.
66
+
67
+ ### Tests and lint
68
+
69
+ Run these commands from `packages/loop_interpolation_core`:
70
+
71
+ ```text
72
+ cargo test --release
73
+ cargo test --release --features parallel
74
+
75
+ cargo clippy --all-targets -- -D warnings
76
+ cargo clippy --all-targets --features python -- -D warnings
77
+ cargo clippy --features wasm --target wasm32-unknown-unknown -- -D warnings
78
+ ```
79
+
80
+ To run the browser tests:
81
+
82
+ ```text
83
+ npm --prefix packages/loop_interpolation_core/tests_web ci
84
+ npm --prefix packages/loop_interpolation_core/tests_web test
85
+ ```
86
+
87
+ ## Contract
88
+
89
+ - Inputs are flat arrays. Points are stored as 3n values, one x, y, z set
90
+ for each point.
91
+ - The grid uses grid coordinates only. The grid has no rotation. The caller
92
+ transforms the coordinates.
93
+ - Node order is x fastest.
94
+ - Errors name the constraint that failed. For example, `value[3]`.
95
+ - A solve is a session. You step the session to advance the solve. To cancel
96
+ it, drop the session.
97
+ - The memory estimate is available before the solve.
98
+ - Set `budget_bytes` to limit the memory of a solve.
99
+
100
+ ## Differences from loop-rs
101
+
102
+ - Grid rotation is removed. The functions `rotation`, `to_local` and
103
+ `direction_to_local` are not in this crate. The `serde` feature is also
104
+ removed.
105
+ - Solve sessions replace the closure-style solvers. A session has step and
106
+ cancel.
107
+ - Memory tracking is new. The crate uses `try_reserve`, a byte budget and a
108
+ memory estimate.
109
+ - Curvature rows are added only at nodes that are interior on all three
110
+ axes. The border rows are centred second derivatives `[1, -2, 1]` on
111
+ layers 1 and n-2. The gradient strike and dip basis is the Python
112
+ strike and dip basis. So the field equals the field of the Python matrix
113
+ solver.
114
+ - Only the ADMM solver is in this crate. There is no active-set solver and
115
+ no hybrid solver. A feasibility check runs before the solve. The solver
116
+ stops when the violation is at most 1e-4 of the field range.
117
+ - Single precision (`f32`) is available. The residual check runs in double
118
+ precision.
119
+
120
+ ## Measured values
121
+
122
+ - Memory: 63 bytes per node for R1, a 100 x 100 x 100 grid with 2000 value
123
+ rows and 500 gradient rows. The value is the peak heap size divided by
124
+ the number of nodes. It does not include the copy of the field that goes
125
+ to JavaScript, which takes 8 bytes per node.
126
+ - Comparison with the Python matrix solver on a 100 x 100 x 100 grid: the
127
+ native solver uses 84 MB where the matrix solver uses 2445 MB (29 times
128
+ less). On one thread it is 10 to 30 percent slower. With the `parallel`
129
+ feature (the default of the Python wheel) it is about 3 times faster. The
130
+ numbers are in `specs/001-low-memory-interpolator/measurements.md`.
131
+ - Browser size: the gzip size of the `.wasm` file is about 92 KB. The
132
+ limit is 2 MB.
133
+
134
+ ## Source
135
+
136
+ Source: loop-rs crates/interpolation-fd, commit bff51342da8ebff7ca3c87e07c1d4fbd31279c8b, branch lachlan/drillhole