zeck 0.1.0 → 0.2.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/README.md +147 -14
- package/package.json +8 -8
- package/{zeckendorf_rs.d.ts → zeck.d.ts} +17 -17
- package/zeck.js +5 -0
- package/{zeckendorf_rs_bg.js → zeck_bg.js} +17 -17
- package/{zeckendorf_rs_bg.wasm → zeck_bg.wasm} +0 -0
- package/zeckendorf_rs.js +0 -5
package/README.md
CHANGED
|
@@ -6,6 +6,8 @@ A Rust library for compressing and decompressing data using the Zeckendorf repre
|
|
|
6
6
|
|
|
7
7
|
The Zeckendorf algorithm represents numbers as a sum of non-consecutive Fibonacci numbers. This library interprets input data as a big integer (either big-endian or little-endian), converts it to its Zeckendorf representation, and sometimes achieves compression. However, compression is not guaranteed; the algorithm may result in a larger representation depending on the input data. The library can automatically try both endian interpretations and select the one that produces the best compression.
|
|
8
8
|
|
|
9
|
+
**Command-line tools** (`zeck-compress` and `zeck-decompress`) are available and can be installed via `cargo install zeck`. See the [Binaries](#binaries) section for usage details.
|
|
10
|
+
|
|
9
11
|
## Features
|
|
10
12
|
|
|
11
13
|
- **Compression & Decompression**: Convert data to/from Zeckendorf representation
|
|
@@ -33,42 +35,59 @@ You can see a live demo of the WebAssembly module in action at <https://prizz.gi
|
|
|
33
35
|
|
|
34
36
|
Run:
|
|
35
37
|
```bash
|
|
36
|
-
cargo add
|
|
38
|
+
cargo add zeck
|
|
37
39
|
```
|
|
38
40
|
|
|
39
41
|
Or add this to your `Cargo.toml`:
|
|
40
42
|
|
|
41
43
|
```toml
|
|
42
44
|
[dependencies]
|
|
43
|
-
|
|
45
|
+
zeck = "0.1.0"
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
For plotting features:
|
|
47
49
|
|
|
48
50
|
```toml
|
|
49
51
|
[dependencies]
|
|
50
|
-
|
|
52
|
+
zeck = { version = "0.1.0", features = ["plotting"] }
|
|
51
53
|
```
|
|
52
54
|
|
|
53
55
|
### Install from GitHub (development version)
|
|
54
56
|
|
|
55
57
|
Run:
|
|
56
58
|
```bash
|
|
57
|
-
cargo add
|
|
59
|
+
cargo add zeck --git https://github.com/pRizz/zeckendorf
|
|
58
60
|
```
|
|
59
61
|
|
|
60
62
|
Or add this to your `Cargo.toml`:
|
|
61
63
|
|
|
62
64
|
```toml
|
|
63
65
|
[dependencies]
|
|
64
|
-
|
|
66
|
+
zeck = { git = "https://github.com/pRizz/zeckendorf" }
|
|
65
67
|
```
|
|
66
68
|
|
|
67
69
|
For plotting features:
|
|
68
70
|
|
|
69
71
|
```toml
|
|
70
72
|
[dependencies]
|
|
71
|
-
|
|
73
|
+
zeck = { git = "https://github.com/pRizz/zeckendorf", features = ["plotting"] }
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Install from npm
|
|
77
|
+
|
|
78
|
+
Run:
|
|
79
|
+
```bash
|
|
80
|
+
npm install zeck
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Or add this to your `package.json`:
|
|
84
|
+
|
|
85
|
+
```json
|
|
86
|
+
{
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"zeck": "^0.1.0"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
72
91
|
```
|
|
73
92
|
|
|
74
93
|
## Usage
|
|
@@ -78,7 +97,7 @@ zeckendorf = { git = "https://github.com/pRizz/zeckendorf", features = ["plottin
|
|
|
78
97
|
#### Big-Endian Interpretation
|
|
79
98
|
|
|
80
99
|
```rust
|
|
81
|
-
use
|
|
100
|
+
use zeck::{zeckendorf_compress_be, zeckendorf_decompress_be};
|
|
82
101
|
|
|
83
102
|
// Compress data (interpreted as big-endian integer)
|
|
84
103
|
let data = vec![12u8];
|
|
@@ -92,7 +111,7 @@ assert_eq!(data, decompressed);
|
|
|
92
111
|
#### Little-Endian Interpretation
|
|
93
112
|
|
|
94
113
|
```rust
|
|
95
|
-
use
|
|
114
|
+
use zeck::{zeckendorf_compress_le, zeckendorf_decompress_le};
|
|
96
115
|
|
|
97
116
|
// Compress data (interpreted as little-endian integer)
|
|
98
117
|
let data = vec![12u8];
|
|
@@ -106,7 +125,7 @@ assert_eq!(data, decompressed);
|
|
|
106
125
|
#### Automatic Best Compression
|
|
107
126
|
|
|
108
127
|
```rust
|
|
109
|
-
use
|
|
128
|
+
use zeck::{zeckendorf_compress_best, zeckendorf_decompress_be, zeckendorf_decompress_le, CompressionResult};
|
|
110
129
|
|
|
111
130
|
// Try both endian interpretations and get the best result
|
|
112
131
|
let data = vec![1, 0];
|
|
@@ -133,20 +152,20 @@ match result {
|
|
|
133
152
|
### Fibonacci Numbers
|
|
134
153
|
|
|
135
154
|
```rust
|
|
136
|
-
use
|
|
155
|
+
use zeck::memoized_slow_fibonacci_recursive;
|
|
137
156
|
|
|
138
157
|
// Calculate Fibonacci numbers (for indices up to 93)
|
|
139
158
|
let fib_10 = memoized_slow_fibonacci_recursive(10); // Returns 55
|
|
140
159
|
|
|
141
160
|
// For larger numbers, use BigInt versions
|
|
142
|
-
use
|
|
161
|
+
use zeck::fast_doubling_fibonacci_bigint;
|
|
143
162
|
let fib_100 = fast_doubling_fibonacci_bigint(100);
|
|
144
163
|
```
|
|
145
164
|
|
|
146
165
|
### Zeckendorf Representation
|
|
147
166
|
|
|
148
167
|
```rust
|
|
149
|
-
use
|
|
168
|
+
use zeck::memoized_zeckendorf_list_descending_for_integer;
|
|
150
169
|
|
|
151
170
|
// Get Zeckendorf representation as a list of Fibonacci indices
|
|
152
171
|
let zld = memoized_zeckendorf_list_descending_for_integer(12);
|
|
@@ -155,12 +174,126 @@ let zld = memoized_zeckendorf_list_descending_for_integer(12);
|
|
|
155
174
|
|
|
156
175
|
## Binaries
|
|
157
176
|
|
|
158
|
-
The project includes several utility binaries:
|
|
177
|
+
The project includes several utility binaries. The command-line compression tools (`zeck-compress` and `zeck-decompress`) can be installed globally via:
|
|
178
|
+
|
|
179
|
+
### Install from crates.io
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
cargo install zeck
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### Install from GitHub (development version)
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
cargo install --git https://github.com/pRizz/zeckendorf zeck
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
After installation, you can use `zeck-compress` and `zeck-decompress` directly from your command line.
|
|
192
|
+
|
|
193
|
+
### Compression/Decompression Tools
|
|
194
|
+
|
|
195
|
+
#### zeck-compress
|
|
196
|
+
|
|
197
|
+
Compresses data using the Zeckendorf representation algorithm. Automatically adds `.zbe` extension for big-endian compression and `.zle` extension for little-endian compression.
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
zeck-compress [INPUT] [-o OUTPUT] [--endian ENDIAN] [-v]
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
**Options:**
|
|
204
|
+
- `INPUT`: Input file path (optional, reads from stdin if not specified)
|
|
205
|
+
- Shows a warning if reading from stdin and no data was piped in
|
|
206
|
+
- `-o, --output FILE`: Output file path (optional)
|
|
207
|
+
- If not specified and input is a file, uses the input filename with the appropriate extension (`.zbe` or `.zle`) appended
|
|
208
|
+
- If not specified and reading from stdin, writes to stdout
|
|
209
|
+
- The appropriate extension (`.zbe` for big-endian, `.zle` for little-endian) is automatically added unless the file already ends with `.zbe` or `.zle`
|
|
210
|
+
- `--endian ENDIAN`: Endianness to use (`big`, `little`, or `best`). Default: `best`
|
|
211
|
+
- `big`: Use big-endian interpretation (output will have `.zbe` extension)
|
|
212
|
+
- `little`: Use little-endian interpretation (output will have `.zle` extension)
|
|
213
|
+
- `best`: Try both and use the best result (default, extension added based on which was used)
|
|
214
|
+
- **Note:** When using `best`, if neither method produces compression (both result in larger or equal output), the tool will exit with an error showing compression statistics
|
|
215
|
+
- `-v, --verbose`: Show compression statistics (default: true, use `--no-verbose` to disable)
|
|
216
|
+
|
|
217
|
+
**Examples:**
|
|
218
|
+
```bash
|
|
219
|
+
# Compress a file (output filename automatically created from input with extension)
|
|
220
|
+
zeck-compress input.bin
|
|
221
|
+
# Creates input.bin.zbe or input.bin.zle depending on which endianness was used
|
|
222
|
+
|
|
223
|
+
# Compress with best endianness (statistics shown by default)
|
|
224
|
+
zeck-compress input.bin --endian best
|
|
225
|
+
|
|
226
|
+
# Compress with specific endianness (creates input.bin.zbe)
|
|
227
|
+
zeck-compress input.bin --endian big
|
|
228
|
+
|
|
229
|
+
# Compress to a specific output file
|
|
230
|
+
zeck-compress input.bin -o output
|
|
231
|
+
# Creates output.zbe or output.zle depending on which endianness was used
|
|
232
|
+
|
|
233
|
+
# Compress from stdin to stdout
|
|
234
|
+
cat input.bin | zeck-compress
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
**Note:** When writing to a file, the output filename is printed to stdout (e.g., "Compressed to: input.bin.zbe"). Verbose statistics are shown by default and include descriptive messages about compression ratios (e.g., "File was compressed by X.XX% (Y bytes -> Z bytes)"). A warning is shown when reading from stdin if no data was piped in.
|
|
238
|
+
|
|
239
|
+
#### zeck-decompress
|
|
240
|
+
|
|
241
|
+
Decompresses data that was compressed using the Zeckendorf representation algorithm. Automatically detects endianness from file extension (`.zbe` for big-endian, `.zle` for little-endian).
|
|
242
|
+
|
|
243
|
+
```bash
|
|
244
|
+
zeck-decompress [INPUT] [-o OUTPUT] [--endian ENDIAN] [-v]
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Options:**
|
|
248
|
+
- `INPUT`: Input file path (optional, reads from stdin if not specified)
|
|
249
|
+
- When reading from a file, endianness is automatically detected from file extension (`.zbe` for big-endian, `.zle` for little-endian)
|
|
250
|
+
- **If extension is not recognized, `--endian` is REQUIRED** (exits with error if not specified)
|
|
251
|
+
- **When reading from stdin, `--endian` is REQUIRED**
|
|
252
|
+
- Shows a warning if reading from stdin and no data was piped in
|
|
253
|
+
- `-o, --output FILE`: Output file path (optional)
|
|
254
|
+
- If not specified and input is a file, uses the input filename with `.zbe` or `.zle` extension removed
|
|
255
|
+
- If not specified and reading from stdin, writes to stdout
|
|
256
|
+
- `--endian ENDIAN`: Endianness used during compression (`big` or `little`)
|
|
257
|
+
- `big`: Decompress as big-endian
|
|
258
|
+
- `little`: Decompress as little-endian
|
|
259
|
+
- **REQUIRED when reading from stdin** (no input file specified)
|
|
260
|
+
- When reading from a file, this option overrides automatic detection from file extension
|
|
261
|
+
- `-v, --verbose`: Show decompression statistics (default: true, use `--no-verbose` to disable)
|
|
262
|
+
|
|
263
|
+
**Examples:**
|
|
264
|
+
```bash
|
|
265
|
+
# Decompress a file (endianness detected from .zbe extension, output filename automatically created)
|
|
266
|
+
zeck-decompress input.zbe
|
|
267
|
+
# Automatically uses big-endian decompression, creates output file "input"
|
|
268
|
+
|
|
269
|
+
# Decompress with little-endian file
|
|
270
|
+
zeck-decompress input.zle
|
|
271
|
+
# Automatically uses little-endian decompression, creates output file "input"
|
|
272
|
+
|
|
273
|
+
# Decompress to a specific output file
|
|
274
|
+
zeck-decompress input.zbe -o output.bin
|
|
275
|
+
# Automatically uses big-endian decompression
|
|
276
|
+
|
|
277
|
+
# Override automatic detection
|
|
278
|
+
zeck-decompress input.zbe --endian little -o output.bin
|
|
279
|
+
# Overrides the .zbe extension and uses little-endian
|
|
280
|
+
|
|
281
|
+
# Decompress from stdin to stdout (--endian is required)
|
|
282
|
+
cat input.zbe | zeck-decompress --endian big
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**Note:** The endianness used for decompression must match the endianness used during compression. The file extension (`.zbe` or `.zle`) indicates which endianness was used, so decompression will automatically use the correct endianness when reading from a file. **If the input file doesn't have a recognized extension, `--endian` must be explicitly specified** (the tool will exit with an error if not provided). You can override automatic detection with the `--endian` flag if needed. **When reading from stdin, `--endian` must be explicitly specified** since there's no file extension to detect from.
|
|
286
|
+
|
|
287
|
+
**Additional features:**
|
|
288
|
+
- When writing to a file, the output filename is printed to stdout (e.g., "Compressed to: input.bin.zbe" or "Decompressed to: output.bin")
|
|
289
|
+
- Verbose statistics are shown by default (use `--no-verbose` to disable) and include descriptive messages about compression/decompression ratios
|
|
290
|
+
- Compression will exit with an error if the data cannot be compressed (when using `--endian best` and neither method produces compression)
|
|
291
|
+
- A warning is shown when reading from stdin if no data was piped in
|
|
159
292
|
|
|
160
293
|
### Main Playground
|
|
161
294
|
|
|
162
295
|
```bash
|
|
163
|
-
cargo run --release --bin
|
|
296
|
+
cargo run --release --bin zeck
|
|
164
297
|
```
|
|
165
298
|
|
|
166
299
|
A playground/scratchpad for testing library functions.
|
package/package.json
CHANGED
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
"Peter Ryszkiewicz"
|
|
6
6
|
],
|
|
7
7
|
"description": "A Rust library for compressing and decompressing data using the Zeckendorf representation algorithm",
|
|
8
|
-
"version": "0.
|
|
8
|
+
"version": "0.2.0",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
12
|
"url": "https://github.com/pRizz/zeckendorf"
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
15
|
+
"zeck_bg.wasm",
|
|
16
|
+
"zeck.js",
|
|
17
|
+
"zeck_bg.js",
|
|
18
|
+
"zeck.d.ts",
|
|
19
19
|
"LICENSE.txt"
|
|
20
20
|
],
|
|
21
|
-
"main": "
|
|
22
|
-
"types": "
|
|
21
|
+
"main": "zeck.js",
|
|
22
|
+
"types": "zeck.d.ts",
|
|
23
23
|
"sideEffects": [
|
|
24
|
-
"./
|
|
24
|
+
"./zeck.js",
|
|
25
25
|
"./snippets/*"
|
|
26
26
|
],
|
|
27
27
|
"keywords": [
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* # Examples
|
|
8
8
|
*
|
|
9
9
|
* ```
|
|
10
|
-
* # use
|
|
10
|
+
* # use zeck::bit_count_for_number;
|
|
11
11
|
* assert_eq!(bit_count_for_number(0), 0);
|
|
12
12
|
* assert_eq!(bit_count_for_number(1), 1); // 0b1
|
|
13
13
|
* assert_eq!(bit_count_for_number(2), 2); // 0b10
|
|
@@ -23,7 +23,7 @@ export function bit_count_for_number(n: number): number;
|
|
|
23
23
|
* # Examples
|
|
24
24
|
*
|
|
25
25
|
* ```
|
|
26
|
-
* # use
|
|
26
|
+
* # use zeck::efi_to_fi;
|
|
27
27
|
* assert_eq!(efi_to_fi(0), 2);
|
|
28
28
|
* assert_eq!(efi_to_fi(1), 3);
|
|
29
29
|
* assert_eq!(efi_to_fi(2), 4);
|
|
@@ -45,7 +45,7 @@ export function efi_to_fi(efi: bigint): bigint;
|
|
|
45
45
|
* # Examples
|
|
46
46
|
*
|
|
47
47
|
* ```
|
|
48
|
-
* # use
|
|
48
|
+
* # use zeck::ezba_from_ezld;
|
|
49
49
|
* assert_eq!(ezba_from_ezld(&[]), vec![0]);
|
|
50
50
|
* assert_eq!(ezba_from_ezld(&[0]), vec![1]); // 0th EFI is 2nd FI, which is 1
|
|
51
51
|
* assert_eq!(ezba_from_ezld(&[1]), vec![0, 1]); // 1st EFI is 3rd FI, which is 2
|
|
@@ -63,7 +63,7 @@ export function ezba_from_ezld(effective_zeckendorf_list_descending: BigUint64Ar
|
|
|
63
63
|
* # Examples
|
|
64
64
|
*
|
|
65
65
|
* ```
|
|
66
|
-
* # use
|
|
66
|
+
* # use zeck::ezba_to_ezla;
|
|
67
67
|
* assert_eq!(ezba_to_ezla(&[0, 0, 0, 0, 0, 0, 0, 0]), vec![]);
|
|
68
68
|
* assert_eq!(ezba_to_ezla(&[1, 0, 0, 0, 0, 0, 0, 0]), vec![0]);
|
|
69
69
|
* assert_eq!(ezba_to_ezla(&[1, 1, 1, 0, 0, 0, 0, 0]), vec![0, 2, 4]);
|
|
@@ -78,7 +78,7 @@ export function ezba_to_ezla(ezba_bits: Uint8Array): BigUint64Array;
|
|
|
78
78
|
* # Examples
|
|
79
79
|
*
|
|
80
80
|
* ```
|
|
81
|
-
* # use
|
|
81
|
+
* # use zeck::ezl_to_zl;
|
|
82
82
|
* assert_eq!(ezl_to_zl(&[0]), vec![2]);
|
|
83
83
|
* assert_eq!(ezl_to_zl(&[1]), vec![3]);
|
|
84
84
|
* assert_eq!(ezl_to_zl(&[2]), vec![4]);
|
|
@@ -92,7 +92,7 @@ export function ezl_to_zl(ezl: BigUint64Array): BigUint64Array;
|
|
|
92
92
|
* # Examples
|
|
93
93
|
*
|
|
94
94
|
* ```
|
|
95
|
-
* # use
|
|
95
|
+
* # use zeck::fi_to_efi;
|
|
96
96
|
* # use num_bigint::BigUint;
|
|
97
97
|
* # use num_traits::{One, Zero};
|
|
98
98
|
* assert_eq!(fi_to_efi(2), 0);
|
|
@@ -108,7 +108,7 @@ export function fi_to_efi(fi: bigint): bigint;
|
|
|
108
108
|
* # Examples
|
|
109
109
|
*
|
|
110
110
|
* ```
|
|
111
|
-
* # use
|
|
111
|
+
* # use zeck::highest_one_bit;
|
|
112
112
|
* assert_eq!(highest_one_bit(0), 0);
|
|
113
113
|
* assert_eq!(highest_one_bit(1), 1);
|
|
114
114
|
* assert_eq!(highest_one_bit(2), 2);
|
|
@@ -134,7 +134,7 @@ export function highest_one_bit(n: bigint): bigint;
|
|
|
134
134
|
* # Examples
|
|
135
135
|
*
|
|
136
136
|
* ```
|
|
137
|
-
* # use
|
|
137
|
+
* # use zeck::memoized_effective_fibonacci;
|
|
138
138
|
* # use num_bigint::BigUint;
|
|
139
139
|
* # use num_traits::{One, Zero};
|
|
140
140
|
* assert_eq!(memoized_effective_fibonacci(0), 1);
|
|
@@ -164,7 +164,7 @@ export function memoized_effective_fibonacci(efi: bigint): bigint;
|
|
|
164
164
|
* # Examples
|
|
165
165
|
*
|
|
166
166
|
* ```
|
|
167
|
-
* # use
|
|
167
|
+
* # use zeck::memoized_slow_fibonacci_recursive;
|
|
168
168
|
* // Base cases
|
|
169
169
|
* assert_eq!(memoized_slow_fibonacci_recursive(0), 0);
|
|
170
170
|
* assert_eq!(memoized_slow_fibonacci_recursive(1), 1);
|
|
@@ -192,7 +192,7 @@ export function memoized_slow_fibonacci_recursive(fi: bigint): bigint;
|
|
|
192
192
|
* # Examples
|
|
193
193
|
*
|
|
194
194
|
* ```
|
|
195
|
-
* # use
|
|
195
|
+
* # use zeck::memoized_zeckendorf_list_descending_for_integer;
|
|
196
196
|
* // Base cases
|
|
197
197
|
* assert_eq!(memoized_zeckendorf_list_descending_for_integer(0), vec![]);
|
|
198
198
|
* assert_eq!(memoized_zeckendorf_list_descending_for_integer(1), vec![2]);
|
|
@@ -225,7 +225,7 @@ export function memoized_zeckendorf_list_descending_for_integer(n: bigint): BigU
|
|
|
225
225
|
* # Examples
|
|
226
226
|
*
|
|
227
227
|
* ```
|
|
228
|
-
* # use
|
|
228
|
+
* # use zeck::pack_ezba_bits_to_bytes;
|
|
229
229
|
* assert_eq!(pack_ezba_bits_to_bytes(&[0]), vec![0]);
|
|
230
230
|
* assert_eq!(pack_ezba_bits_to_bytes(&[1]), vec![1]);
|
|
231
231
|
* assert_eq!(pack_ezba_bits_to_bytes(&[0, 1]), vec![0b10]);
|
|
@@ -241,7 +241,7 @@ export function pack_ezba_bits_to_bytes(ezba: Uint8Array): Uint8Array;
|
|
|
241
241
|
* # Examples
|
|
242
242
|
*
|
|
243
243
|
* ```
|
|
244
|
-
* # use
|
|
244
|
+
* # use zeck::unpack_bytes_to_ezba_bits;
|
|
245
245
|
* assert_eq!(unpack_bytes_to_ezba_bits(&[0]), vec![0, 0, 0, 0, 0, 0, 0, 0]);
|
|
246
246
|
* assert_eq!(unpack_bytes_to_ezba_bits(&[1]), vec![1, 0, 0, 0, 0, 0, 0, 0]);
|
|
247
247
|
* assert_eq!(unpack_bytes_to_ezba_bits(&[0b111]), vec![1, 1, 1, 0, 0, 0, 0, 0]);
|
|
@@ -260,7 +260,7 @@ export function unpack_bytes_to_ezba_bits(bytes: Uint8Array): Uint8Array;
|
|
|
260
260
|
* # Examples
|
|
261
261
|
*
|
|
262
262
|
* ```
|
|
263
|
-
* # use
|
|
263
|
+
* # use zeck::zeckendorf_compress_be;
|
|
264
264
|
* assert_eq!(zeckendorf_compress_be(&[0]), vec![0]);
|
|
265
265
|
* assert_eq!(zeckendorf_compress_be(&[1]), vec![1]);
|
|
266
266
|
* assert_eq!(zeckendorf_compress_be(&[12]), vec![0b111]);
|
|
@@ -280,7 +280,7 @@ export function zeckendorf_compress_be(data: Uint8Array): Uint8Array;
|
|
|
280
280
|
* # Examples
|
|
281
281
|
*
|
|
282
282
|
* ```
|
|
283
|
-
* # use
|
|
283
|
+
* # use zeck::zeckendorf_compress_le;
|
|
284
284
|
* assert_eq!(zeckendorf_compress_le(&[0]), vec![0]);
|
|
285
285
|
* assert_eq!(zeckendorf_compress_le(&[1]), vec![1]);
|
|
286
286
|
* assert_eq!(zeckendorf_compress_le(&[12]), vec![0b111]);
|
|
@@ -300,7 +300,7 @@ export function zeckendorf_compress_le(data: Uint8Array): Uint8Array;
|
|
|
300
300
|
* # Examples
|
|
301
301
|
*
|
|
302
302
|
* ```
|
|
303
|
-
* # use
|
|
303
|
+
* # use zeck::zeckendorf_decompress_be;
|
|
304
304
|
* assert_eq!(zeckendorf_decompress_be(&[0]), vec![0]);
|
|
305
305
|
* assert_eq!(zeckendorf_decompress_be(&[1]), vec![1]);
|
|
306
306
|
* assert_eq!(zeckendorf_decompress_be(&[0b111]), vec![12]);
|
|
@@ -316,7 +316,7 @@ export function zeckendorf_decompress_be(compressed_data: Uint8Array): Uint8Arra
|
|
|
316
316
|
* # Examples
|
|
317
317
|
*
|
|
318
318
|
* ```
|
|
319
|
-
* # use
|
|
319
|
+
* # use zeck::zeckendorf_decompress_le;
|
|
320
320
|
* assert_eq!(zeckendorf_decompress_le(&[0]), vec![0]);
|
|
321
321
|
* assert_eq!(zeckendorf_decompress_le(&[1]), vec![1]);
|
|
322
322
|
* assert_eq!(zeckendorf_decompress_le(&[0b111]), vec![12]);
|
|
@@ -337,7 +337,7 @@ export function zeckendorf_decompress_le(compressed_data: Uint8Array): Uint8Arra
|
|
|
337
337
|
* # Examples
|
|
338
338
|
*
|
|
339
339
|
* ```
|
|
340
|
-
* # use
|
|
340
|
+
* # use zeck::zl_to_ezl;
|
|
341
341
|
* assert_eq!(zl_to_ezl(&[2]), vec![0]);
|
|
342
342
|
* assert_eq!(zl_to_ezl(&[3]), vec![1]);
|
|
343
343
|
* assert_eq!(zl_to_ezl(&[4]), vec![2]);
|
package/zeck.js
ADDED
|
@@ -51,7 +51,7 @@ let WASM_VECTOR_LEN = 0;
|
|
|
51
51
|
* # Examples
|
|
52
52
|
*
|
|
53
53
|
* ```
|
|
54
|
-
* # use
|
|
54
|
+
* # use zeck::bit_count_for_number;
|
|
55
55
|
* assert_eq!(bit_count_for_number(0), 0);
|
|
56
56
|
* assert_eq!(bit_count_for_number(1), 1); // 0b1
|
|
57
57
|
* assert_eq!(bit_count_for_number(2), 2); // 0b10
|
|
@@ -72,7 +72,7 @@ export function bit_count_for_number(n) {
|
|
|
72
72
|
* # Examples
|
|
73
73
|
*
|
|
74
74
|
* ```
|
|
75
|
-
* # use
|
|
75
|
+
* # use zeck::efi_to_fi;
|
|
76
76
|
* assert_eq!(efi_to_fi(0), 2);
|
|
77
77
|
* assert_eq!(efi_to_fi(1), 3);
|
|
78
78
|
* assert_eq!(efi_to_fi(2), 4);
|
|
@@ -99,7 +99,7 @@ export function efi_to_fi(efi) {
|
|
|
99
99
|
* # Examples
|
|
100
100
|
*
|
|
101
101
|
* ```
|
|
102
|
-
* # use
|
|
102
|
+
* # use zeck::ezba_from_ezld;
|
|
103
103
|
* assert_eq!(ezba_from_ezld(&[]), vec![0]);
|
|
104
104
|
* assert_eq!(ezba_from_ezld(&[0]), vec![1]); // 0th EFI is 2nd FI, which is 1
|
|
105
105
|
* assert_eq!(ezba_from_ezld(&[1]), vec![0, 1]); // 1st EFI is 3rd FI, which is 2
|
|
@@ -126,7 +126,7 @@ export function ezba_from_ezld(effective_zeckendorf_list_descending) {
|
|
|
126
126
|
* # Examples
|
|
127
127
|
*
|
|
128
128
|
* ```
|
|
129
|
-
* # use
|
|
129
|
+
* # use zeck::ezba_to_ezla;
|
|
130
130
|
* assert_eq!(ezba_to_ezla(&[0, 0, 0, 0, 0, 0, 0, 0]), vec![]);
|
|
131
131
|
* assert_eq!(ezba_to_ezla(&[1, 0, 0, 0, 0, 0, 0, 0]), vec![0]);
|
|
132
132
|
* assert_eq!(ezba_to_ezla(&[1, 1, 1, 0, 0, 0, 0, 0]), vec![0, 2, 4]);
|
|
@@ -150,7 +150,7 @@ export function ezba_to_ezla(ezba_bits) {
|
|
|
150
150
|
* # Examples
|
|
151
151
|
*
|
|
152
152
|
* ```
|
|
153
|
-
* # use
|
|
153
|
+
* # use zeck::ezl_to_zl;
|
|
154
154
|
* assert_eq!(ezl_to_zl(&[0]), vec![2]);
|
|
155
155
|
* assert_eq!(ezl_to_zl(&[1]), vec![3]);
|
|
156
156
|
* assert_eq!(ezl_to_zl(&[2]), vec![4]);
|
|
@@ -173,7 +173,7 @@ export function ezl_to_zl(ezl) {
|
|
|
173
173
|
* # Examples
|
|
174
174
|
*
|
|
175
175
|
* ```
|
|
176
|
-
* # use
|
|
176
|
+
* # use zeck::fi_to_efi;
|
|
177
177
|
* # use num_bigint::BigUint;
|
|
178
178
|
* # use num_traits::{One, Zero};
|
|
179
179
|
* assert_eq!(fi_to_efi(2), 0);
|
|
@@ -194,7 +194,7 @@ export function fi_to_efi(fi) {
|
|
|
194
194
|
* # Examples
|
|
195
195
|
*
|
|
196
196
|
* ```
|
|
197
|
-
* # use
|
|
197
|
+
* # use zeck::highest_one_bit;
|
|
198
198
|
* assert_eq!(highest_one_bit(0), 0);
|
|
199
199
|
* assert_eq!(highest_one_bit(1), 1);
|
|
200
200
|
* assert_eq!(highest_one_bit(2), 2);
|
|
@@ -225,7 +225,7 @@ export function highest_one_bit(n) {
|
|
|
225
225
|
* # Examples
|
|
226
226
|
*
|
|
227
227
|
* ```
|
|
228
|
-
* # use
|
|
228
|
+
* # use zeck::memoized_effective_fibonacci;
|
|
229
229
|
* # use num_bigint::BigUint;
|
|
230
230
|
* # use num_traits::{One, Zero};
|
|
231
231
|
* assert_eq!(memoized_effective_fibonacci(0), 1);
|
|
@@ -260,7 +260,7 @@ export function memoized_effective_fibonacci(efi) {
|
|
|
260
260
|
* # Examples
|
|
261
261
|
*
|
|
262
262
|
* ```
|
|
263
|
-
* # use
|
|
263
|
+
* # use zeck::memoized_slow_fibonacci_recursive;
|
|
264
264
|
* // Base cases
|
|
265
265
|
* assert_eq!(memoized_slow_fibonacci_recursive(0), 0);
|
|
266
266
|
* assert_eq!(memoized_slow_fibonacci_recursive(1), 1);
|
|
@@ -293,7 +293,7 @@ export function memoized_slow_fibonacci_recursive(fi) {
|
|
|
293
293
|
* # Examples
|
|
294
294
|
*
|
|
295
295
|
* ```
|
|
296
|
-
* # use
|
|
296
|
+
* # use zeck::memoized_zeckendorf_list_descending_for_integer;
|
|
297
297
|
* // Base cases
|
|
298
298
|
* assert_eq!(memoized_zeckendorf_list_descending_for_integer(0), vec![]);
|
|
299
299
|
* assert_eq!(memoized_zeckendorf_list_descending_for_integer(1), vec![2]);
|
|
@@ -333,7 +333,7 @@ export function memoized_zeckendorf_list_descending_for_integer(n) {
|
|
|
333
333
|
* # Examples
|
|
334
334
|
*
|
|
335
335
|
* ```
|
|
336
|
-
* # use
|
|
336
|
+
* # use zeck::pack_ezba_bits_to_bytes;
|
|
337
337
|
* assert_eq!(pack_ezba_bits_to_bytes(&[0]), vec![0]);
|
|
338
338
|
* assert_eq!(pack_ezba_bits_to_bytes(&[1]), vec![1]);
|
|
339
339
|
* assert_eq!(pack_ezba_bits_to_bytes(&[0, 1]), vec![0b10]);
|
|
@@ -358,7 +358,7 @@ export function pack_ezba_bits_to_bytes(ezba) {
|
|
|
358
358
|
* # Examples
|
|
359
359
|
*
|
|
360
360
|
* ```
|
|
361
|
-
* # use
|
|
361
|
+
* # use zeck::unpack_bytes_to_ezba_bits;
|
|
362
362
|
* assert_eq!(unpack_bytes_to_ezba_bits(&[0]), vec![0, 0, 0, 0, 0, 0, 0, 0]);
|
|
363
363
|
* assert_eq!(unpack_bytes_to_ezba_bits(&[1]), vec![1, 0, 0, 0, 0, 0, 0, 0]);
|
|
364
364
|
* assert_eq!(unpack_bytes_to_ezba_bits(&[0b111]), vec![1, 1, 1, 0, 0, 0, 0, 0]);
|
|
@@ -386,7 +386,7 @@ export function unpack_bytes_to_ezba_bits(bytes) {
|
|
|
386
386
|
* # Examples
|
|
387
387
|
*
|
|
388
388
|
* ```
|
|
389
|
-
* # use
|
|
389
|
+
* # use zeck::zeckendorf_compress_be;
|
|
390
390
|
* assert_eq!(zeckendorf_compress_be(&[0]), vec![0]);
|
|
391
391
|
* assert_eq!(zeckendorf_compress_be(&[1]), vec![1]);
|
|
392
392
|
* assert_eq!(zeckendorf_compress_be(&[12]), vec![0b111]);
|
|
@@ -415,7 +415,7 @@ export function zeckendorf_compress_be(data) {
|
|
|
415
415
|
* # Examples
|
|
416
416
|
*
|
|
417
417
|
* ```
|
|
418
|
-
* # use
|
|
418
|
+
* # use zeck::zeckendorf_compress_le;
|
|
419
419
|
* assert_eq!(zeckendorf_compress_le(&[0]), vec![0]);
|
|
420
420
|
* assert_eq!(zeckendorf_compress_le(&[1]), vec![1]);
|
|
421
421
|
* assert_eq!(zeckendorf_compress_le(&[12]), vec![0b111]);
|
|
@@ -444,7 +444,7 @@ export function zeckendorf_compress_le(data) {
|
|
|
444
444
|
* # Examples
|
|
445
445
|
*
|
|
446
446
|
* ```
|
|
447
|
-
* # use
|
|
447
|
+
* # use zeck::zeckendorf_decompress_be;
|
|
448
448
|
* assert_eq!(zeckendorf_decompress_be(&[0]), vec![0]);
|
|
449
449
|
* assert_eq!(zeckendorf_decompress_be(&[1]), vec![1]);
|
|
450
450
|
* assert_eq!(zeckendorf_decompress_be(&[0b111]), vec![12]);
|
|
@@ -469,7 +469,7 @@ export function zeckendorf_decompress_be(compressed_data) {
|
|
|
469
469
|
* # Examples
|
|
470
470
|
*
|
|
471
471
|
* ```
|
|
472
|
-
* # use
|
|
472
|
+
* # use zeck::zeckendorf_decompress_le;
|
|
473
473
|
* assert_eq!(zeckendorf_decompress_le(&[0]), vec![0]);
|
|
474
474
|
* assert_eq!(zeckendorf_decompress_le(&[1]), vec![1]);
|
|
475
475
|
* assert_eq!(zeckendorf_decompress_le(&[0b111]), vec![12]);
|
|
@@ -499,7 +499,7 @@ export function zeckendorf_decompress_le(compressed_data) {
|
|
|
499
499
|
* # Examples
|
|
500
500
|
*
|
|
501
501
|
* ```
|
|
502
|
-
* # use
|
|
502
|
+
* # use zeck::zl_to_ezl;
|
|
503
503
|
* assert_eq!(zl_to_ezl(&[2]), vec![0]);
|
|
504
504
|
* assert_eq!(zl_to_ezl(&[3]), vec![1]);
|
|
505
505
|
* assert_eq!(zl_to_ezl(&[4]), vec![2]);
|
|
Binary file
|