normaliz.wasm 1.0.0
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/LICENSE +682 -0
- package/README.md +85 -0
- package/dist/normaliz.js +4985 -0
- package/dist/normaliz.wasm +0 -0
- package/package.json +30 -0
- package/src/normaliz.js +153 -0
package/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# normaliz.wasm
|
|
2
|
+
|
|
3
|
+
WebAssembly build of [Normaliz](https://github.com/Normaliz/Normaliz), usable from Node.js and the browser.
|
|
4
|
+
|
|
5
|
+
[Normaliz](https://www.normaliz.uni-osnabrueck.de/) is a tool for computations in affine monoids, vector configurations, lattice polytopes, and rational cones. It supports Hilbert bases, Hilbert series, triangulations, volumes, and much more.
|
|
6
|
+
|
|
7
|
+
**[Try it in your browser](https://DominikPeters.github.io/normaliz.wasm)**
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install normaliz.wasm
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage (Node.js)
|
|
16
|
+
|
|
17
|
+
```js
|
|
18
|
+
import { Normaliz } from 'normaliz.wasm';
|
|
19
|
+
|
|
20
|
+
const nmz = await Normaliz.create();
|
|
21
|
+
const result = nmz.run(`amb_space 2
|
|
22
|
+
cone 2
|
|
23
|
+
1 3
|
|
24
|
+
2 1
|
|
25
|
+
`);
|
|
26
|
+
|
|
27
|
+
console.log(result.output); // main .out file contents
|
|
28
|
+
console.log(result.files); // { out: '...', gen: '...', ext: '...', ... }
|
|
29
|
+
console.log(result.console); // verbose log
|
|
30
|
+
console.log(result.exitCode); // 0 on success
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Options
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
// With CLI flags
|
|
37
|
+
const result = nmz.run(input, { flags: ['--verbose', '-a'] });
|
|
38
|
+
|
|
39
|
+
// Stream console output in real time
|
|
40
|
+
const nmz = await Normaliz.create({
|
|
41
|
+
onStdout: (line) => process.stdout.write(line + '\n'),
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Low-level API
|
|
46
|
+
|
|
47
|
+
You can also use the Emscripten module directly:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import createNormaliz from 'normaliz.wasm/dist/normaliz.js';
|
|
51
|
+
|
|
52
|
+
const m = await createNormaliz();
|
|
53
|
+
m.FS.writeFile('test.in', 'amb_space 2\ncone 2\n1 3\n2 1\n');
|
|
54
|
+
m.callMain(['test']);
|
|
55
|
+
const output = m.FS.readFile('test.out', { encoding: 'utf8' });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Browser usage
|
|
59
|
+
|
|
60
|
+
In the browser, run Normaliz in a Web Worker to avoid blocking the main thread. See the [web demo source](web/) for a complete example.
|
|
61
|
+
|
|
62
|
+
## Cross-compiled dependencies
|
|
63
|
+
|
|
64
|
+
| Library | Version | Purpose |
|
|
65
|
+
|---------|---------|---------|
|
|
66
|
+
| [GMP](https://gmplib.org/) | 6.3.0 | Arbitrary-precision arithmetic |
|
|
67
|
+
| [MPFR](https://www.mpfr.org/) | 4.2.2 | Multi-precision floats |
|
|
68
|
+
| [FLINT](https://flintlib.org/) | 3.3.1 | Polynomial arithmetic |
|
|
69
|
+
| [nauty](https://pallini.di.uniroma1.it/) | 2.9.1 | Automorphism groups |
|
|
70
|
+
| [hash-library](https://github.com/stbrumme/hash-library) | 8 | SHA-256 hashing |
|
|
71
|
+
|
|
72
|
+
## Building from source
|
|
73
|
+
|
|
74
|
+
Prerequisites: [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) activated.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
source /path/to/emsdk/emsdk_env.sh
|
|
78
|
+
npm run build
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This cross-compiles all dependencies and Normaliz to WebAssembly. Output goes to `dist/`.
|
|
82
|
+
|
|
83
|
+
## License
|
|
84
|
+
|
|
85
|
+
GPL-3.0-or-later (same as Normaliz)
|