Git Product home page Git Product logo

0joshuaolson1 / factoradic Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 49 KB

Invertible transformations on permutation representations, including an RNG-free in-place Fisher-Yates-Knuth shuffle https://www.npmjs.com/package/factoradic

Home Page: https://www.npmjs.com/package/factoradic

License: Apache License 2.0

JavaScript 100.00%
factoradic-base factoradic-number-system factorial-base factorial-number-system fisher-yates-shuffle in-place in-place-shuffle permutation permutation-algorithms permutation-number

factoradic's People

Contributors

0joshuaolson1 avatar

Watchers

 avatar

factoradic's Issues

asm.js style

The WebAssembly<->js interface might have too much overhead, but even ignoring asm.js support, simple optimizations like <uint variable> |= 0 give modern JS engines hints.

Add helper/docs for permuting array with a Permutation?

A more efficient atop(ptoa(p), wantPermuted) would be

function(p, wantPermuted){return p.map(function(i){return wantPermuted[i];});}

This makes a new array instead of permuting wantPermuted, but if Factoradic used an indexof reverse index here and a user wanted (to pass in) a wantPermuted copy anyway, that'd be two new arrays...

...I'll just write the indexof approach here sometime.

Add additional resources

to the readme, or a separate file? Which are relevant enough to Factoradic?

  • comparison of randomness sources
  • derangement
  • bigint library/website recommendation (#19 <- not very good; I may need to supplement its poor docs) (see usage example linked in last bullet)
  • products of factorials
  • utilities in issue 25

Minify

Note that jsdelivr tries to use a bad minifier for you. I don't know if creating a index.min.js would change that. (EDIT: jsDelivr upgraded UglifyJS and may be nice now; index.min.js is still a good idea)

Should test.js be the one to test the minified version as well?

wzrd.in started trying to minify from 1.1.0 onward. Naturally it doesn't know about alternative loop strategies and stuff that shortens the code further. (EDIT: They don't respond to open issues well.)

Decompose n into array of factor 'chunks' of n!

Create an alternative ntop (and associated entropy estimator) that can easily pull from arrays (not like a) of 2^x, [21*23*25 /*< 2**53*/], etc.

Note to self: see if any (odd-number double) factorial identities in https://arxiv.org/abs/0906.1317 could help; or see:

Other identities?

Array.apply is limited to small arrays

Functional is not first class - thanks, unoptimized call stack implementation detail leakage. Instead:

function P(l){var a = Array(l); loop(0, l-1, function(l){a[l] = l;}); return a;}

, or equally

function P(l){for(var a = Array(l); a[--l] = l;); return a;}

Combine ntop's maxRadix and p into same argument

Since they're mutually exclusive, this might have a net benefit of removing the documented falsy complication, enforcing the exclusivity, and side-stepping the question of what happens when both are given.

ES5?

Literally the only advantage here of ES6 is brevity.

Literally the only advantages of ES5 are use in bad browsers and readability for those unfamiliar or uncomfortable with ES2015.

Use better documentation style

E.g.:


atop(array[, permutable])

Converts/transform array into a permutation of [0, 1...]
(unless permutable is provided, in which case...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.