Skip to content

Commit

Permalink
Fix typos and work around MarkDown junk
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Olson committed Sep 5, 2017
1 parent b19052f commit ede6c61
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 32 deletions.
101 changes: 70 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,55 +1,94 @@
##Factoradic
# Factoradic

semantic version 1.0.0

Apache 2.0 license

This ES6 Node package contains and exports four functions (and a test) providing invertible transformations on permutation representations:

- [`ntoa`]() takes a permutation Number and returns its corresponding factorial number system (mixed radix) Array
- [`ntoa`](https://github.com/0joshuaolson1/factoradic/blob/master/index.js#L1) takes a permutation Number and returns its corresponding mixed radix (factorial number system) Array

- inputs:
1. a non-negative integer ('uint') of JavaScript or bignum-like type (the permutation number's 'number type')

(1) a non-negative integer ('uint') of JavaScript or bignum-like type (the permutation number's 'number type')

- if this is an object, it will be modified
- JS uints greater than 2^53 (9007199254740992) lose precision
- 18! (7387354275840000) < 2^53 << 19! (140359731240960000)
2. a JS uint >= 2 specifying the maximum radix
- e.g. 4 means interpret the first argument in the range [0, 4!)
3. the number type's integer divmod function

- JS uints greater than `2^53 (9007199254740992)` lose precision

- `18! (7387354275840000) < 2^53 << 19! (140359731240960000)`

(2) a JS uint `>= 2` specifying the maximum radix

- e.g. `4` means interpret the first argument in the range `[0, 4!)`

(3) the number type's integer divmod function

- inputs:
1. a uint <= the permutation number
2. a JS uint divisor in the range [2, max radix]

(1) a uint `<=` the permutation number

(2) a JS uint divisor in the range `[2, max radix]`

- output: a map with JS uint values

- 'div' indexes the division result

- 'mod' indexes the remainder
- output: a nonempty array of JS uints where 0 <= a[i] < i+2
- e.g. ntoa(5, 4, divmod) -> [1, 2, 0], where 1 is base 2 and 0 is base 4
- [`aton`]() takes a mixed radix Array and returns its corresponding permutation Number

- output: a nonempty array of JS uints where `0 <= a[i] < i+2`

- e.g. `ntoa(5, 4, divmod)` -> `[1, 2, 0]`, where `1` is base 2 and `0` is base 4

- [`aton`](https://github.com/0joshuaolson1/factoradic/blob/master/index.js#L10) takes a mixed radix Array and returns its corresponding permutation Number

- inputs:
1. the array (not modified)
2. the number type's constructor function given a JS uint less than the max radix
3. the number type's multiply-then-add function

(1) the array (not modified)

(2) the number type's constructor function given a JS uint less than the max radix

(3) the number type's multiply-then-add function

- inputs:
1. a uint of number type
2. a JS uint multiplicand in the range [2, max radix]
3. a JS uint addihend in the range [0, multiplicand)
- output: (number * multiplicand) + addihend
- output: a uint of number type
- [`atop`]() takes a mixed radix array and optional array to permute in place and returns their corresponding permutation

(1) a uint

(2) a JS uint multiplier in the range `[2, max radix]`

(3) a JS uint addend in the range `[0, multiplier)`

- output: `(number * multiplier) + addend`

- output: a uint

- [`atop`](https://github.com/0joshuaolson1/factoradic/blob/master/index.js#L15) takes a mixed radix Array and optional array to permute in place and returns their corresponding Permutation

- inputs:
1. the mixed radix array (not modified)
2. the array to permute in place (defaults to [0, 1, 2...]

(1) the mixed radix array (not modified)

(2) the array to permute in place (defaults to `[0, 1, 2...]`

- this is one element longer than the mixed radix array

- the highest element is one less than the max radix

- output: the in-place Fisher-Yates-Knuth shuffled array (not a copy)
- [`ptoa`]() takes a permutation of [0, 1, 2...] (will be modified) and returns its corresponding mixed radix array
- [`test`]() tests that all four transformations are invertible, but read it yourself:

- [`ptoa`](https://github.com/0joshuaolson1/factoradic/blob/master/index.js#L25) takes a Permutation of `[0, 1, 2...]` (will be modified) and returns its corresponding mixed radix Array

- [`test`](https://github.com/0joshuaolson1/factoradic/blob/master/index.js#L31) tests that all four transformations are invertible, but read it yourself:

- for example code

- to understand test use (e.g. test.js) and limitations

#Note
## Note

One reason for the particular choice of permutation-number bijection is the 'zero-extensibility property' (please tell me if you may know its or ptoa's algorithm's actual names):
One reason for the particular choice of permutation-number bijection is the 'zero-extensibility property' (please tell me if you may know its actual name):

- atop([1, 1], [1, 2, 3]) -> [2, 3, 1]
- atop([1, 1, 0, 0], [1, 2, 3, 4, 5]) -> [2, 3, 1, 4, 5]
- `atop([1, 1], [1, 2, 3])` -> `[2, 3, 1]`
- `atop([1, 1, 0, 0], [1, 2, 3, 4, 5])` -> `[2, 3, 1, 4, 5]`

The facts that 4 and 5 are untouched and 1-3's new order is independent of maximum radix are analogous to any finite number's infinite implicit leading zeroes.
The facts that `4` and `5` are untouched and `1-3`'s new order is independent of maximum radix are analogous to a finite number's implicit leading zeroes.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"in-place",
"Knuth",
"number",
"permute",
"permutation",
"permutations",
"permute",
"shuffle",
"system"
],
Expand Down

0 comments on commit ede6c61

Please sign in to comment.