From efe25e5f8c0adc4446efecffd9eb80ce859a5f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Ooms?= Date: Sun, 6 Nov 2016 01:32:03 +0100 Subject: [PATCH] upgrade progress --- .codeclimate.yml | 5 +- .gitignore | 33 +- .groc.json | 7 - .travis.yml | 28 +- README.md | 7 +- bower.json | 21 - component.json | 11 - doc/css/style.css | 52 +++ doc/manual/example.md | 0 doc/manual/installation.md | 13 + doc/manual/overview.md | 0 doc/manual/usage.md | 14 + doc/scripts/header.js | 34 ++ esdoc.json | 37 ++ inch.json | 5 - js/dist/prime.js | 515 ------------------------ js/dist/prime.js.map | 1 - js/dist/prime.min.js | 2 - js/index.js | 15 - js/src/sieve/itop.js | 6 - js/src/sieve/itop2.js | 6 - js/src/sieve/itop23.js | 6 - js/src/sieve/itop230.js | 6 - js/src/sieve/itop231.js | 6 - js/src/sieve/ptoi.js | 6 - js/src/sieve/ptoi2.js | 6 - js/src/sieve/ptoi23.js | 6 - js/src/sieve/ptoi230.js | 6 - js/src/sieve/ptoi231.js | 6 - package.json | 98 +++-- pkg.json | 17 - {js/src => src}/analyze/factorize.js | 6 +- src/analyze/index.js | 1 + src/index.js | 4 + src/limits/index.js | 1 + {js/src => src}/limits/upperbound.js | 6 +- {js/src => src}/sieve/eratosthenes.js | 6 +- {js/src => src}/sieve/eratosthenes2.js | 6 +- {js/src => src}/sieve/eratosthenes23.js | 6 +- {js/src => src}/sieve/gothrough.js | 6 +- src/sieve/index.js | 14 + src/sieve/itop.js | 4 + src/sieve/itop2.js | 4 + src/sieve/itop23.js | 4 + src/sieve/itop230.js | 4 + src/sieve/itop231.js | 4 + src/sieve/ptoi.js | 4 + src/sieve/ptoi2.js | 4 + src/sieve/ptoi23.js | 4 + src/sieve/ptoi230.js | 4 + src/sieve/ptoi231.js | 4 + {js/src => src}/ulam/atos.js | 6 +- src/ulam/index.js | 2 + {js/src => src}/ulam/stoa.js | 5 +- test/{js => }/data/1000.json | 0 test/js/index.js | 10 - test/js/src/analyze/factorize.js | 25 -- test/js/src/limits/upperbound.js | 19 - test/js/src/sieve/sieves.js | 47 --- test/js/src/ulam/convert.js | 79 ---- test/src/analyze/factorize.js | 17 + test/src/limits/upperbound.js | 17 + test/src/sieve/sieves.js | 42 ++ test/src/ulam/convert.js | 76 ++++ 64 files changed, 472 insertions(+), 944 deletions(-) delete mode 100644 .groc.json delete mode 100644 bower.json delete mode 100644 component.json create mode 100644 doc/css/style.css create mode 100644 doc/manual/example.md create mode 100644 doc/manual/installation.md create mode 100644 doc/manual/overview.md create mode 100644 doc/manual/usage.md create mode 100644 doc/scripts/header.js create mode 100644 esdoc.json delete mode 100644 inch.json delete mode 100644 js/dist/prime.js delete mode 100644 js/dist/prime.js.map delete mode 100644 js/dist/prime.min.js delete mode 100644 js/index.js delete mode 100644 js/src/sieve/itop.js delete mode 100644 js/src/sieve/itop2.js delete mode 100644 js/src/sieve/itop23.js delete mode 100644 js/src/sieve/itop230.js delete mode 100644 js/src/sieve/itop231.js delete mode 100644 js/src/sieve/ptoi.js delete mode 100644 js/src/sieve/ptoi2.js delete mode 100644 js/src/sieve/ptoi23.js delete mode 100644 js/src/sieve/ptoi230.js delete mode 100644 js/src/sieve/ptoi231.js delete mode 100644 pkg.json rename {js/src => src}/analyze/factorize.js (77%) create mode 100644 src/analyze/index.js create mode 100644 src/index.js create mode 100644 src/limits/index.js rename {js/src => src}/limits/upperbound.js (82%) rename {js/src => src}/sieve/eratosthenes.js (82%) rename {js/src => src}/sieve/eratosthenes2.js (84%) rename {js/src => src}/sieve/eratosthenes23.js (93%) rename {js/src => src}/sieve/gothrough.js (78%) create mode 100644 src/sieve/index.js create mode 100644 src/sieve/itop.js create mode 100644 src/sieve/itop2.js create mode 100644 src/sieve/itop23.js create mode 100644 src/sieve/itop230.js create mode 100644 src/sieve/itop231.js create mode 100644 src/sieve/ptoi.js create mode 100644 src/sieve/ptoi2.js create mode 100644 src/sieve/ptoi23.js create mode 100644 src/sieve/ptoi230.js create mode 100644 src/sieve/ptoi231.js rename {js/src => src}/ulam/atos.js (90%) create mode 100644 src/ulam/index.js rename {js/src => src}/ulam/stoa.js (91%) rename test/{js => }/data/1000.json (100%) delete mode 100644 test/js/index.js delete mode 100644 test/js/src/analyze/factorize.js delete mode 100644 test/js/src/limits/upperbound.js delete mode 100644 test/js/src/sieve/sieves.js delete mode 100644 test/js/src/ulam/convert.js create mode 100644 test/src/analyze/factorize.js create mode 100644 test/src/limits/upperbound.js create mode 100644 test/src/sieve/sieves.js create mode 100644 test/src/ulam/convert.js diff --git a/.codeclimate.yml b/.codeclimate.yml index 0672c33..0913fd6 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,7 +1,6 @@ languages: JavaScript: true exclude_paths: -- "js/dist/*.js" -- "js/dist/**/*.js" -- "test/*.js" +- "doc/**/*.js" - "test/**/*.js" +- "lib/**/*.js" diff --git a/.gitignore b/.gitignore index 4f0e82e..be10dca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,31 +1,10 @@ -# Logs -logs -*.log - -# Runtime data -pids -*.pid -*.seed - -# Directory for instrumented libs generated by jscoverage/JSCover -lib-cov - -# Coverage directory used by tools like istanbul -coverage - -# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) -.grunt - -# Compiled binary addons (http://nodejs.org/api/addons.html) -build/Release - # Dependency directory -# Commenting this out is preferred by some people, see -# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- node_modules +jspm_packages -# Users Environment Variables -.lock-wscript +# Coverage directory used by nyc +coverage +.nyc_output -# groc -doc +# Documentation +gh-pages diff --git a/.groc.json b/.groc.json deleted file mode 100644 index 56e8333..0000000 --- a/.groc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "glob": [ - "js/src/**/*.js", - "README.md" - ], - "github": true -} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9a0746b..903d73f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,25 @@ +env: + - CXX=g++-4.8 + +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 + language: node_js + node_js: - - "iojs" - - "0.12" - - "0.11" - - "0.10" + - node + install: - - npm -d install + - npm install + script: - - npm test + - npm run cover + after_success: - - ./node_modules/.bin/coveralls < coverage/lcov.info || true - - ./node_modules/.bin/codeclimate < coverage/lcov.info || true + - bash <(curl -s https://codecov.io/bash) || true + - coveralls < coverage/lcov.info || true + - codeclimate-test-reporter < coverage/lcov.info || true diff --git a/README.md b/README.md index 73ef6a5..21cec6e 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ [js-prime](http://aureooms.github.io/js-prime) == -prime numbers code bricks for JavaScript +Prime numbers algorithms for JavaScript. [![NPM license](http://img.shields.io/npm/l/aureooms-js-prime.svg?style=flat)](https://raw.githubusercontent.com/aureooms/js-prime/master/LICENSE) [![NPM version](http://img.shields.io/npm/v/aureooms-js-prime.svg?style=flat)](https://www.npmjs.org/package/aureooms-js-prime) -[![Bower version](http://img.shields.io/bower/v/aureooms-js-prime.svg?style=flat)](http://bower.io/search/?q=aureooms-js-prime) [![Build Status](http://img.shields.io/travis/aureooms/js-prime.svg?style=flat)](https://travis-ci.org/aureooms/js-prime) [![Coverage Status](http://img.shields.io/coveralls/aureooms/js-prime.svg?style=flat)](https://coveralls.io/r/aureooms/js-prime) [![Dependencies Status](http://img.shields.io/david/aureooms/js-prime.svg?style=flat)](https://david-dm.org/aureooms/js-prime#info=dependencies) @@ -13,9 +12,9 @@ prime numbers code bricks for JavaScript [![Code Climate](http://img.shields.io/codeclimate/github/aureooms/js-prime.svg?style=flat)](https://codeclimate.com/github/aureooms/js-prime) [![NPM downloads per month](http://img.shields.io/npm/dm/aureooms-js-prime.svg?style=flat)](https://www.npmjs.org/package/aureooms-js-prime) [![GitHub issues](http://img.shields.io/github/issues/aureooms/js-prime.svg?style=flat)](https://github.com/aureooms/js-prime/issues) -[![Inline docs](http://inch-ci.org/github/aureooms/js-prime.svg?branch=master&style=shields)](http://inch-ci.org/github/aureooms/js-prime) +[![Documentation](https://aureooms.github.io/js-prime/badge.svg)](https://aureooms.github.io/js-prime/source.html) -reference: +## Reference - http://cr.yp.to/primegen.html - https://github.com/jbarham/primegen.go diff --git a/bower.json b/bower.json deleted file mode 100644 index 591dc81..0000000 --- a/bower.json +++ /dev/null @@ -1,21 +0,0 @@ -{ - "name": "aureooms-js-prime", - "version": "1.0.2", - "ignore": [ - "js/index.js", - "js/src", - "test", - "pkg.json", - "package.json", - ".groc.json", - ".travis.yml", - ".gitignore", - "README.md", - "inch.json", - ".codeclimate.yml" - ], - "license": "AGPL-3.0", - "description": "prime numbers code bricks for JavaScript", - "homepage": "http://aureooms.github.io/js-prime/", - "main": "js/dist/prime.js" -} diff --git a/component.json b/component.json deleted file mode 100644 index 9ba47ff..0000000 --- a/component.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "description": "prime numbers code bricks for JavaScript", - "version": "1.0.2", - "repo": "aureooms/js-prime", - "scripts": [ - "js/dist/prime.js" - ], - "name": "aureooms-js-prime", - "license": "AGPL-3.0", - "main": "js/dist/prime.js" -} \ No newline at end of file diff --git a/doc/css/style.css b/doc/css/style.css new file mode 100644 index 0000000..ed56934 --- /dev/null +++ b/doc/css/style.css @@ -0,0 +1,52 @@ +h1, +h2, +.navigation, +.layout-container > header, +footer +{ + border: none; +} + +.project-name { + color: #FC913A; + font-weight: bold; +} + +.layout-container > header > a.repo-url-github { + font-size: inherit; + display: inline; + background: none; + vertical-align: inherit; +} + +.search-box img { + display: none; +} + +.search-box::before{ + content: "search"; +} + +.search-input-edge { + height: 0px; +} + +.search-result { + width: 300px; + margin-left: 42px; + box-shadow: 1px 1px 13px rgba(0,0,0,0.2); +} + +.search-input { + visibility: visible; +} + +.search-result li.search-separator { + text-transform: capitalize; + background-color: #ccc; +} + +span[data-ice="signature"] > span { + /*font-weight: bold;*/ + font-style: italic; +} diff --git a/doc/manual/example.md b/doc/manual/example.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/manual/installation.md b/doc/manual/installation.md new file mode 100644 index 0000000..dc2fffb --- /dev/null +++ b/doc/manual/installation.md @@ -0,0 +1,13 @@ +Can be managed using +[jspm](http://jspm.io) +or [npm](https://github.com/npm/npm). + +### jspm +```terminal +jspm install npm:aureooms-js-prime +``` + +### npm +```terminal +npm install aureooms-js-prime --save +``` diff --git a/doc/manual/overview.md b/doc/manual/overview.md new file mode 100644 index 0000000..e69de29 diff --git a/doc/manual/usage.md b/doc/manual/usage.md new file mode 100644 index 0000000..b1ed3fc --- /dev/null +++ b/doc/manual/usage.md @@ -0,0 +1,14 @@ +The code needs a ES2015+ polyfill to work, for example +[babel-polyfill](https://babeljs.io/docs/usage/polyfill). +```js +require( 'babel-polyfill' ) ; +// or +import 'babel-polyfill' ; +``` + +Then +```js +const measure = require( 'aureooms-js-prime' ) ; +// or +import measure from 'aureooms-js-prime' ; +``` diff --git a/doc/scripts/header.js b/doc/scripts/header.js new file mode 100644 index 0000000..45be57a --- /dev/null +++ b/doc/scripts/header.js @@ -0,0 +1,34 @@ +var domReady = function(callback) { + var state = document.readyState ; + if ( state === 'interactive' || state === 'complete' ) { + callback() ; + } + else { + document.addEventListener('DOMContentLoaded', callback); + } +} ; + + +domReady(function(){ + + var projectname = document.createElement('a'); + projectname.classList.add('project-name'); + projectname.text = 'aureooms/js-prime'; + projectname.href = './index.html' ; + + var header = document.getElementsByTagName('header')[0] ; + header.insertBefore(projectname,header.firstChild); + + var testlink = document.querySelector('header > a[data-ice="testLink"]') ; + testlink.href = 'https://coveralls.io/github/aureooms/js-prime' ; + testlink.target = '_BLANK' ; + + var searchBox = document.querySelector('.search-box'); + var input = document.querySelector('.search-input'); + + // active search box when focus on searchBox. + input.addEventListener('focus', function(){ + searchBox.classList.add('active'); + }); + +}); diff --git a/esdoc.json b/esdoc.json new file mode 100644 index 0000000..5b0aa6d --- /dev/null +++ b/esdoc.json @@ -0,0 +1,37 @@ +{ + "source": "./src", + "destination": "./gh-pages", + "access": [ + "public", + "protected", + "private" + ], + "debug": false, + "index": "./README.md", + "package": "./package.json", + "title": "aureooms/js-prime", + "test": { + "type": "ava", + "source": "./test/src" + }, + "manual": { + "overview": [ + "./doc/manual/overview.md" + ], + "installation": [ + "./doc/manual/installation.md" + ], + "usage": [ + "./doc/manual/usage.md" + ], + "example": [ + "./doc/manual/example.md" + ] + }, + "styles": [ + "./doc/css/style.css" + ], + "scripts": [ + "./doc/scripts/header.js" + ] +} diff --git a/inch.json b/inch.json deleted file mode 100644 index bb05fa6..0000000 --- a/inch.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "files" : { - "included": [ "js/src/**/*.js" ] - } -} diff --git a/js/dist/prime.js b/js/dist/prime.js deleted file mode 100644 index 33a2617..0000000 --- a/js/dist/prime.js +++ /dev/null @@ -1,515 +0,0 @@ -(function(exports, undefined){ - - 'use strict'; - - -/* js/src/analyze */ -/* js/src/analyze/factorize.js */ - -var __factorize__ = function ( two, iaddone, iszero, gtone, divmod ) { - - var factorize = function ( n, factors ) { - - var divisor , qr , q , r ; - - divisor = two ( ) ; - - while ( gtone ( n ) ) { - - // [ q , r ] = divmod ( n , divisor ) ; FOR ES6 - qr = divmod ( n , divisor ) ; - - q = qr[0] ; - r = qr[1] ; - - if ( iszero ( r ) ) { - - factors . push ( divisor ) ; - - n = q ; - - } - - else { - divisor = iaddone ( divisor ) ; - } - - } - - } ; - - return factorize ; - -} ; - -exports.__factorize__ = __factorize__; - -/* js/src/limits */ -/* js/src/limits/upperbound.js */ - -/** - * Upper bound for computing the nth prime number. - * - * see http://math.univ-lille1.fr/~ramare/TME-EMT/Articles/Art01.html - * - * /!\ n = 1 will work only if loglog(0) returns 0 - * - */ - -var __upperbound__ = function ( log , loglog ) { - - var upperbound = function ( n ) { - if ( n < 55 ) { - return n * ( log( n ) + loglog( n ) ) + 3 ; - } - else if ( n < 39018 ) { - return n * ( log( n ) + loglog( n ) - 0.5 ) ; - } - else{ - return n * ( log( n ) + loglog( n ) - 0.9484 ) ; - } - } ; - - return upperbound ; - -} ; - -exports.__upperbound__ = __upperbound__ ; - -/* js/src/sieve */ -/* js/src/sieve/eratosthenes.js */ - -/** - * Sieve of Eratosthenes. - */ - -var __eratosthenes__ = function ( alloc , fill , get , gothrough , usqrt ) { - - var first = 2 ; - - var eratosthenes = function ( n , callback ) { - - var size , sieve , m , i , p ; - - if ( n <= 2 ) { - return null ; - } - - size = ptoi( n ) ; - - sieve = alloc( size ) ; - fill( sieve , 0 , size , true ) ; - - m = ptoi( usqrt( n ) ) ; - - for ( i = ptoi( first ) ; i < m ; ++i ) { - if ( get( sieve , i ) ) { - p = itop( i ) ; - callback( p ) ; - gothrough( sieve , ptoi( p * p ) , size , p ) ; - } - } - - for ( i = m ; i < size ; ++i ) { - if ( get( sieve , i ) ) { - callback( itop( i ) ) ; - } - } - - return sieve ; - } ; - - return eratosthenes ; - -} ; - -exports.__eratosthenes__ = __eratosthenes__ ; - -/* js/src/sieve/eratosthenes2.js */ - -/** - * Sieve of Eratosthenes skipping all multiples of 2. - */ - -var __eratosthenes2__ = function ( alloc , fill , get , gothrough , usqrt ) { - - var first = 3 ; - - var eratosthenes2 = function ( n , callback ) { - - var size , sieve , m , i , p ; - - if ( n <= 2 ) { - return null ; - } - - callback( 2 ) ; - - if ( n <= 3 ) { - return null ; - } - - size = ptoi2( n ) ; - - sieve = alloc( size ) ; - fill( sieve , 0 , size , true ) ; - - m = ptoi2( usqrt( n ) ) ; - - for ( i = ptoi2( first ) ; i < m ; ++i ) { - if ( get( sieve , i ) ) { - p = itop2( i ) ; - callback( p ) ; - gothrough( sieve , ptoi2( p * p ) , size , p ) ; - } - } - - for ( i = m ; i < size ; ++i ) { - if ( get( sieve , i ) ) { - callback( itop2( i ) ) ; - } - } - - return sieve ; - } ; - - return eratosthenes2 ; - -} ; - -exports.__eratosthenes2__ = __eratosthenes2__ ; - -/* js/src/sieve/eratosthenes23.js */ - -/** - * Sieve of Eratosthenes skipping all multiples of 2 and 3. - * - * 5 7 11 13 17 19 23 25 29 31 35 37 41 43 47 49 53 55 59 61 65 67 71 73 77 79 - * 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 - * - * 83 85 89 91 95 97 101 103 107 109 113 115 119 121 125 127 131 133 137 139 - * 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 - * - * 143 145 149 151 155 157 161 163 167 169 173 175 179 181 185 187 191 - * 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 - * - * - * - * i( 5) = 0 - * i(25) = 7 - * i(35) = 10 = 7 + 5 - 2 - * - * i( 7) = 1 - * i(49) = 15 - * i(77) = 24 = 15 + 7 + 2 - * - * i( 11) = 2 - * i(121) = 39 - * i(143) = 46 = 39 + 11 - 4 - * - * i( 13) = 3 - * i(139) = 45 - * i(191) = 62 = 45 + 13 + 4 - */ - -var __eratosthenes23__ = function ( alloc , fill , get , gothrough , usqrt ) { - - var first = 5 ; - - var eratosthenes23 = function ( n , callback ) { - - var size , sieve , m , i , j , p , l ; - - if ( n <= 2 ) { - return null ; - } - - callback( 2 ) ; - - if ( n <= 3 ) { - return null ; - } - - callback( 3 ) ; - - if ( n <= 5 ) { - return null ; - } - - size = ptoi23( n ) ; - - sieve = alloc( size ) ; - fill( sieve , 0 , size , true ) ; - - m = ptoi23( usqrt( n ) ) ; - i = ptoi230( first ) ; - - for ( l = 2 ; ; l += 2 ) { - - if ( i >= m ) { - break ; - } - - if ( get( sieve , i ) ) { - - p = itop230( i ) ; - - callback( p ) ; - - j = ptoi231( p * p ) ; - - gothrough( sieve , j , size , 2 * p ) ; - gothrough( sieve , j + p - l , size , 2 * p ) ; - - } - - ++i ; - - - if ( i >= m ) { - break ; - } - - if ( get( sieve , i ) ) { - - p = itop231( i ) ; - - callback( p ) ; - - j = ptoi231( p * p ) ; - - gothrough( sieve , j , size , 2 * p ) ; - gothrough( sieve , j + p + l , size , 2 * p ) ; - - } - - ++i ; - - } - - i = m ; - - for ( ; ; ) { - - if ( i >= size ) { - break ; - } - - if ( get( sieve , i ) ) { - callback( itop23( i ) ) ; - } - - ++i ; - - - if ( i >= size ) { - break ; - } - - if ( get( sieve , i ) ) { - callback( itop23( i ) ) ; - } - - ++i ; - } - - return sieve ; - } ; - - return eratosthenes23 ; - -} ; - -exports.__eratosthenes23__ = __eratosthenes23__ ; - -/* js/src/sieve/gothrough.js */ - -/** - * Goes through an array and crosses out non prime numbers. - * - * @param {setter} set function ( a , i , v ) that sets value v at index i in array a - */ -var __gothrough__ = function ( set ) { - - var gothrough = function ( prime , i , j , k ) { - - for ( ; i < j ; i += k ) { - set( prime , i , false ) ; - } - - }; - - return gothrough ; - -}; - -exports.__gothrough__ = __gothrough__ ; - -/* js/src/sieve/itop.js */ - -var itop = function ( i ) { - return i ; -} ; - -exports.itop = itop ; - -/* js/src/sieve/itop2.js */ - -var itop2 = function (i) { - return i * 2 + 1; -}; - -exports.itop2 = itop2; - -/* js/src/sieve/itop23.js */ - -var itop23 = function ( i ) { - return ( i % 2 === 0 ) ? itop230( i ) : itop231( i ) ; -}; - -exports.itop23 = itop23; - -/* js/src/sieve/itop230.js */ - -var itop230 = function ( i ) { - return 6 * ( ( i / 2 | 0 ) + 1 ) - 1 ; -}; - -exports.itop230 = itop230; - -/* js/src/sieve/itop231.js */ - -var itop231 = function ( i ) { - return 6 * ( ( i / 2 | 0 ) + 1 ) + 1 ; -}; - -exports.itop231 = itop231; - -/* js/src/sieve/ptoi.js */ - -var ptoi = function ( p ) { - return p ; -} ; - -exports.ptoi = ptoi ; - -/* js/src/sieve/ptoi2.js */ - -var ptoi2 = function (p) { - return p / 2 | 0; -}; - -exports.ptoi2 = ptoi2; - -/* js/src/sieve/ptoi23.js */ - -var ptoi23 = function ( p ) { - return ( p % 6 > 4 ) ? ptoi230( p ) : ptoi231( p ) ; -}; - -exports.ptoi23 = ptoi23; - -/* js/src/sieve/ptoi230.js */ - -var ptoi230 = function ( p ) { - return Math.ceil( ( p + 1 ) / 3 ) - 2 ; -}; - -exports.ptoi230 = ptoi230; - -/* js/src/sieve/ptoi231.js */ - -var ptoi231 = function ( p ) { - return Math.ceil( ( p - 1 ) / 3 ) - 1 ; -}; - -exports.ptoi231 = ptoi231; - -/* js/src/ulam */ -/* js/src/ulam/atos.js */ - -/** - * Converts a square Ulam spiral index to an array index. - * - */ - -var atos = function ( i , n ) { - - var s, l, r, L, R, x, y; - - s = Math.sqrt(i) | 0; - l = s; - r = s + 1; - L = l * l; - R = r * r; - x = (n - 1) / 2 | 0; - y = n / 2 | 0; - - if (s % 2 === 1) { - if (i < (L + R) / 2 | 0) { - x += (s / 2 | 0) + 1; - y += (l / 2 | 0) + L - i; - } - else { - x -= (r / 2 | 0) - R + i; - y -= (s / 2 | 0) + 1; - } - } - else { - if (i < (L + R) / 2 | 0) { - x -= (s / 2 | 0); - y -= (l / 2 | 0) + L - i; - } - else { - x += (r / 2 | 0) + 1 - R + i; - y += (s / 2 | 0); - } - } - - return n * y + x; -}; - -exports.atos = atos; - -/* js/src/ulam/stoa.js */ - -/** - * Converts an array index to a square Ulam spiral index. - * - */ - -var stoa = function ( i , n ) { - - var line, col, ring_index, side_col, side_line, sub_size; - - line = i / n | 0; - col = i % n; - - if (n % 2 === 0) { - line = n - line - 1; - col = n - col - 1; - } - - side_col = 1; - side_line = 1; - - if (col < n - line) { - ring_index = Math.min(line, col); - } - else if (col > line) { - ring_index = n - col - 1; - side_line = -1; - } - else{ - ring_index = n - line - 1; - side_col = -1; - } - - sub_size = n - ring_index * 2; - - return sub_size * sub_size - (sub_size - 1) * 2 + side_line * (line - ring_index) - side_col * (col - ring_index) - 1; -}; - -exports.stoa = stoa; - -})(typeof exports === 'undefined' ? this['prime'] = {} : exports); diff --git a/js/dist/prime.js.map b/js/dist/prime.js.map deleted file mode 100644 index ceda44c..0000000 --- a/js/dist/prime.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"js/dist//prime.js.map","sources":["js/dist//prime.js"],"names":["exports","__factorize__","two","iaddone","iszero","gtone","divmod","factorize","n","factors","divisor","qr","q","r","push","__upperbound__","log","loglog","upperbound","__eratosthenes__","alloc","fill","get","gothrough","usqrt","first","eratosthenes","callback","size","sieve","m","i","p","ptoi","itop","__eratosthenes2__","eratosthenes2","ptoi2","itop2","__eratosthenes23__","eratosthenes23","j","l","ptoi23","ptoi230","itop230","ptoi231","itop231","itop23","__gothrough__","set","prime","k","Math","ceil","atos","s","L","R","x","y","sqrt","stoa","line","col","ring_index","side_col","side_line","sub_size","min","this"],"mappings":"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"} \ No newline at end of file diff --git a/js/dist/prime.min.js b/js/dist/prime.min.js deleted file mode 100644 index e34c75b..0000000 --- a/js/dist/prime.min.js +++ /dev/null @@ -1,2 +0,0 @@ -!function(r){"use strict";var n=function(r,n,t,u,o){var i=function(i,e){var f,a,v,c;for(f=r();u(i);)a=o(i,f),v=a[0],c=a[1],t(c)?(e.push(f),i=v):f=n(f)};return i};r.__factorize__=n;var t=function(r,n){var t=function(t){return 55>t?t*(r(t)+n(t))+3:39018>t?t*(r(t)+n(t)-.5):t*(r(t)+n(t)-.9484)};return t};r.__upperbound__=t;var u=function(r,n,t,u,o){var i=2,e=function(e,a){var v,c,_,s,l;if(2>=e)return null;for(v=p(e),c=r(v),n(c,0,v,!0),_=p(o(e)),s=p(i);_>s;++s)t(c,s)&&(l=f(s),a(l),u(c,p(l*l),v,l));for(s=_;v>s;++s)t(c,s)&&a(f(s));return c};return e};r.__eratosthenes__=u;var o=function(r,n,t,u,o){var i=3,e=function(e,f){var v,c,_,p,l;if(2>=e)return null;if(f(2),3>=e)return null;for(v=s(e),c=r(v),n(c,0,v,!0),_=s(o(e)),p=s(i);_>p;++p)t(c,p)&&(l=a(p),f(l),u(c,s(l*l),v,l));for(p=_;v>p;++p)t(c,p)&&f(a(p));return c};return e};r.__eratosthenes2__=o;var i=function(r,n,t,u,o){var i=5,e=function(e,f){var a,p,s,d,g,m,x;if(2>=e)return null;if(f(2),3>=e)return null;if(f(3),5>=e)return null;for(a=l(e),p=r(a),n(p,0,a,!0),s=l(o(e)),d=h(i),x=2;!(d>=s)&&(t(p,d)&&(m=c(d),f(m),g=M(m*m),u(p,g,a,2*m),u(p,g+m-x,a,2*m)),++d,!(d>=s));x+=2)t(p,d)&&(m=_(d),f(m),g=M(m*m),u(p,g,a,2*m),u(p,g+m+x,a,2*m)),++d;for(d=s;!(d>=a)&&(t(p,d)&&f(v(d)),++d,!(d>=a));)t(p,d)&&f(v(d)),++d;return p};return e};r.__eratosthenes23__=i;var e=function(r){var n=function(n,t,u,o){for(;u>t;t+=o)r(n,t,!1)};return n};r.__gothrough__=e;var f=function(r){return r};r.itop=f;var a=function(r){return 2*r+1};r.itop2=a;var v=function(r){return r%2===0?c(r):_(r)};r.itop23=v;var c=function(r){return 6*((r/2|0)+1)-1};r.itop230=c;var _=function(r){return 6*((r/2|0)+1)+1};r.itop231=_;var p=function(r){return r};r.ptoi=p;var s=function(r){return r/2|0};r.ptoi2=s;var l=function(r){return r%6>4?h(r):M(r)};r.ptoi23=l;var h=function(r){return Math.ceil((r+1)/3)-2};r.ptoi230=h;var M=function(r){return Math.ceil((r-1)/3)-1};r.ptoi231=M;var d=function(r,n){var t,u,o,i,e,f,a;return t=0|Math.sqrt(r),u=t,o=t+1,i=u*u,e=o*o,f=(n-1)/2|0,a=n/2|0,t%2===1?(i+e)/2>r|0?(f+=(t/2|0)+1,a+=(u/2|0)+i-r):(f-=(o/2|0)-e+r,a-=(t/2|0)+1):(i+e)/2>r|0?(f-=t/2|0,a-=(u/2|0)+i-r):(f+=(o/2|0)+1-e+r,a+=t/2|0),n*a+f};r.atos=d;var g=function(r,n){var t,u,o,i,e,f;return t=r/n|0,u=r%n,n%2===0&&(t=n-t-1,u=n-u-1),i=1,e=1,n-t>u?o=Math.min(t,u):u>t?(o=n-u-1,e=-1):(o=n-t-1,i=-1),f=n-2*o,f*f-2*(f-1)+e*(t-o)-i*(u-o)-1};r.stoa=g}("undefined"==typeof exports?this.prime={}:exports); -//# sourceMappingURL=js/dist//prime.js.map \ No newline at end of file diff --git a/js/index.js b/js/index.js deleted file mode 100644 index 6432512..0000000 --- a/js/index.js +++ /dev/null @@ -1,15 +0,0 @@ -var pkg = require('aureooms-node-package'); - -var fs = require('fs'); -var data = fs.readFileSync(pkg.config, 'utf8'); -var opt = JSON.parse(data); - -opt = { - ns : opt.ns, - src : __dirname + '/src/', - exports : module.exports, - base : 0, - debug : opt.debug -}; - -pkg.include(opt); diff --git a/js/src/sieve/itop.js b/js/src/sieve/itop.js deleted file mode 100644 index c1a9f83..0000000 --- a/js/src/sieve/itop.js +++ /dev/null @@ -1,6 +0,0 @@ - -var itop = function ( i ) { - return i ; -} ; - -exports.itop = itop ; diff --git a/js/src/sieve/itop2.js b/js/src/sieve/itop2.js deleted file mode 100644 index c520acc..0000000 --- a/js/src/sieve/itop2.js +++ /dev/null @@ -1,6 +0,0 @@ - -var itop2 = function (i) { - return i * 2 + 1; -}; - -exports.itop2 = itop2; diff --git a/js/src/sieve/itop23.js b/js/src/sieve/itop23.js deleted file mode 100644 index 2a885c5..0000000 --- a/js/src/sieve/itop23.js +++ /dev/null @@ -1,6 +0,0 @@ - -var itop23 = function ( i ) { - return ( i % 2 === 0 ) ? itop230( i ) : itop231( i ) ; -}; - -exports.itop23 = itop23; diff --git a/js/src/sieve/itop230.js b/js/src/sieve/itop230.js deleted file mode 100644 index 8ab5532..0000000 --- a/js/src/sieve/itop230.js +++ /dev/null @@ -1,6 +0,0 @@ - -var itop230 = function ( i ) { - return 6 * ( ( i / 2 | 0 ) + 1 ) - 1 ; -}; - -exports.itop230 = itop230; diff --git a/js/src/sieve/itop231.js b/js/src/sieve/itop231.js deleted file mode 100644 index 8fb1b86..0000000 --- a/js/src/sieve/itop231.js +++ /dev/null @@ -1,6 +0,0 @@ - -var itop231 = function ( i ) { - return 6 * ( ( i / 2 | 0 ) + 1 ) + 1 ; -}; - -exports.itop231 = itop231; diff --git a/js/src/sieve/ptoi.js b/js/src/sieve/ptoi.js deleted file mode 100644 index 7885001..0000000 --- a/js/src/sieve/ptoi.js +++ /dev/null @@ -1,6 +0,0 @@ - -var ptoi = function ( p ) { - return p ; -} ; - -exports.ptoi = ptoi ; diff --git a/js/src/sieve/ptoi2.js b/js/src/sieve/ptoi2.js deleted file mode 100644 index d198ea2..0000000 --- a/js/src/sieve/ptoi2.js +++ /dev/null @@ -1,6 +0,0 @@ - -var ptoi2 = function (p) { - return p / 2 | 0; -}; - -exports.ptoi2 = ptoi2; diff --git a/js/src/sieve/ptoi23.js b/js/src/sieve/ptoi23.js deleted file mode 100644 index bac10e9..0000000 --- a/js/src/sieve/ptoi23.js +++ /dev/null @@ -1,6 +0,0 @@ - -var ptoi23 = function ( p ) { - return ( p % 6 > 4 ) ? ptoi230( p ) : ptoi231( p ) ; -}; - -exports.ptoi23 = ptoi23; diff --git a/js/src/sieve/ptoi230.js b/js/src/sieve/ptoi230.js deleted file mode 100644 index 90600f1..0000000 --- a/js/src/sieve/ptoi230.js +++ /dev/null @@ -1,6 +0,0 @@ - -var ptoi230 = function ( p ) { - return Math.ceil( ( p + 1 ) / 3 ) - 2 ; -}; - -exports.ptoi230 = ptoi230; diff --git a/js/src/sieve/ptoi231.js b/js/src/sieve/ptoi231.js deleted file mode 100644 index 3d7473d..0000000 --- a/js/src/sieve/ptoi231.js +++ /dev/null @@ -1,6 +0,0 @@ - -var ptoi231 = function ( p ) { - return Math.ceil( ( p - 1 ) / 3 ) - 1 ; -}; - -exports.ptoi231 = ptoi231; diff --git a/package.json b/package.json index fd94282..fc93be3 100644 --- a/package.json +++ b/package.json @@ -1,38 +1,62 @@ { - "version": "1.0.2", - "repository": { - "type": "git", - "url": "https://github.com/aureooms/js-prime.git" - }, - "bugs": { - "url": "https://github.com/aureooms/js-prime/issues" - }, - "license": "AGPL-3.0", - "scripts": { - "test": "./node_modules/.bin/aureooms-node-package-test", - "build": "./node_modules/.bin/aureooms-node-package-build", - "doc": "./node_modules/.bin/groc" - }, - "homepage": "http://aureooms.github.io/js-prime/", - "author": "aureooms", - "name": "aureooms-js-prime", - "devDependencies": { - "aureooms-node-package": "^1.1.3", - "aureooms-js-functools": "^1.0.0", - "aureooms-js-itertools": "^0.2.0", - "aureooms-js-number": "^1.2.0", - "aureooms-js-uint32": "^0.1.1", - "aureooms-js-array": "^1.1.0" - }, - "dependencies": {}, - "description": "prime numbers code bricks for JavaScript", - "main": "js/dist/prime.js", - "keywords": [ - "bricks", - "factorization", - "javascript", - "js", - "number", - "prime" - ] -} \ No newline at end of file + "name": "aureooms-js-prime", + "description": "prime numbers code bricks for JavaScript", + "version": "1.0.2", + "author": "Aurélien Ooms ", + "ava": { + "require": [ + "babel-polyfill", + "babel-register" + ] + }, + "babel": { + "presets": [ + "latest" + ], + "env": { + "development": { + "sourceMaps": "inline" + } + } + }, + "bugs": { + "url": "https://github.com/aureooms/js-prime/issues" + }, + "dependencies": {}, + "devDependencies": { + "aureooms-js-array": "^1.1.0", + "aureooms-js-functools": "^1.0.0", + "aureooms-js-itertools": "^0.2.0", + "aureooms-js-number": "^1.2.0", + "aureooms-js-uint32": "^0.1.1", + "ava": "^0.16.0", + "babel-cli": "^6.16.0", + "babel-polyfill": "^6.16.0", + "babel-preset-latest": "^6.16.0", + "codeclimate-test-reporter": "^0.4.0", + "coveralls": "^2.11.14", + "esdoc": "^0.4.8", + "nyc": "^8.3.1" + }, + "homepage": "http://aureooms.github.io/js-prime/", + "keywords": [ + "bricks", + "factorization", + "javascript", + "js", + "number", + "prime" + ], + "license": "AGPL-3.0", + "main": "lib/index.js", + "repository": { + "type": "git", + "url": "https://github.com/aureooms/js-prime.git" + }, + "scripts": { + "build": "babel src -d lib", + "cover": "nyc --reporter=lcov npm test", + "prepublish": "npm run build", + "test": "ava ./test/src" + } +} diff --git a/pkg.json b/pkg.json deleted file mode 100644 index ba12d46..0000000 --- a/pkg.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "code": { - "test": [ - "test", - "js" - ], - "main": [ - "js", - "dist", - "prime.js" - ] - }, - "debug": false, - "out": "js/dist/", - "src": "js/src/", - "ns": "prime" -} \ No newline at end of file diff --git a/js/src/analyze/factorize.js b/src/analyze/factorize.js similarity index 77% rename from js/src/analyze/factorize.js rename to src/analyze/factorize.js index c30aa8f..282590b 100644 --- a/js/src/analyze/factorize.js +++ b/src/analyze/factorize.js @@ -1,5 +1,5 @@ -var __factorize__ = function ( two, iaddone, iszero, gtone, divmod ) { +export function __factorize__ ( two, iaddone, iszero, gtone, divmod ) { var factorize = function ( n, factors ) { @@ -33,6 +33,4 @@ var __factorize__ = function ( two, iaddone, iszero, gtone, divmod ) { return factorize ; -} ; - -exports.__factorize__ = __factorize__; +} diff --git a/src/analyze/index.js b/src/analyze/index.js new file mode 100644 index 0000000..4bee176 --- /dev/null +++ b/src/analyze/index.js @@ -0,0 +1 @@ +export * from './factorize' ; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..615f80d --- /dev/null +++ b/src/index.js @@ -0,0 +1,4 @@ +export * from './analyze' ; +export * from './limits' ; +export * from './sieve' ; +export * from './ulam' ; diff --git a/src/limits/index.js b/src/limits/index.js new file mode 100644 index 0000000..4d421ce --- /dev/null +++ b/src/limits/index.js @@ -0,0 +1 @@ +export * from './upperbound' ; diff --git a/js/src/limits/upperbound.js b/src/limits/upperbound.js similarity index 82% rename from js/src/limits/upperbound.js rename to src/limits/upperbound.js index 7ed25ff..999ca6e 100644 --- a/js/src/limits/upperbound.js +++ b/src/limits/upperbound.js @@ -8,7 +8,7 @@ * */ -var __upperbound__ = function ( log , loglog ) { +export function __upperbound__ ( log , loglog ) { var upperbound = function ( n ) { if ( n < 55 ) { @@ -24,6 +24,4 @@ var __upperbound__ = function ( log , loglog ) { return upperbound ; -} ; - -exports.__upperbound__ = __upperbound__ ; +} diff --git a/js/src/sieve/eratosthenes.js b/src/sieve/eratosthenes.js similarity index 82% rename from js/src/sieve/eratosthenes.js rename to src/sieve/eratosthenes.js index 14a69e1..954f2ad 100644 --- a/js/src/sieve/eratosthenes.js +++ b/src/sieve/eratosthenes.js @@ -3,7 +3,7 @@ * Sieve of Eratosthenes. */ -var __eratosthenes__ = function ( alloc , fill , get , gothrough , usqrt ) { +export function __eratosthenes__ ( alloc , fill , get , gothrough , usqrt ) { var first = 2 ; @@ -41,6 +41,4 @@ var __eratosthenes__ = function ( alloc , fill , get , gothrough , usqrt ) { return eratosthenes ; -} ; - -exports.__eratosthenes__ = __eratosthenes__ ; +} diff --git a/js/src/sieve/eratosthenes2.js b/src/sieve/eratosthenes2.js similarity index 84% rename from js/src/sieve/eratosthenes2.js rename to src/sieve/eratosthenes2.js index 8c2b459..34960e4 100644 --- a/js/src/sieve/eratosthenes2.js +++ b/src/sieve/eratosthenes2.js @@ -3,7 +3,7 @@ * Sieve of Eratosthenes skipping all multiples of 2. */ -var __eratosthenes2__ = function ( alloc , fill , get , gothrough , usqrt ) { +export function __eratosthenes2__ ( alloc , fill , get , gothrough , usqrt ) { var first = 3 ; @@ -47,6 +47,4 @@ var __eratosthenes2__ = function ( alloc , fill , get , gothrough , usqrt ) { return eratosthenes2 ; -} ; - -exports.__eratosthenes2__ = __eratosthenes2__ ; +} diff --git a/js/src/sieve/eratosthenes23.js b/src/sieve/eratosthenes23.js similarity index 93% rename from js/src/sieve/eratosthenes23.js rename to src/sieve/eratosthenes23.js index 60367b5..9a6974e 100644 --- a/js/src/sieve/eratosthenes23.js +++ b/src/sieve/eratosthenes23.js @@ -30,7 +30,7 @@ * i(191) = 62 = 45 + 13 + 4 */ -var __eratosthenes23__ = function ( alloc , fill , get , gothrough , usqrt ) { +export function __eratosthenes23__ ( alloc , fill , get , gothrough , usqrt ) { var first = 5 ; @@ -136,6 +136,4 @@ var __eratosthenes23__ = function ( alloc , fill , get , gothrough , usqrt ) { return eratosthenes23 ; -} ; - -exports.__eratosthenes23__ = __eratosthenes23__ ; +} diff --git a/js/src/sieve/gothrough.js b/src/sieve/gothrough.js similarity index 78% rename from js/src/sieve/gothrough.js rename to src/sieve/gothrough.js index 449b65d..5b2cb58 100644 --- a/js/src/sieve/gothrough.js +++ b/src/sieve/gothrough.js @@ -4,7 +4,7 @@ * * @param {setter} set function ( a , i , v ) that sets value v at index i in array a */ -var __gothrough__ = function ( set ) { +export function __gothrough__ ( set ) { var gothrough = function ( prime , i , j , k ) { @@ -16,6 +16,4 @@ var __gothrough__ = function ( set ) { return gothrough ; -}; - -exports.__gothrough__ = __gothrough__ ; +} diff --git a/src/sieve/index.js b/src/sieve/index.js new file mode 100644 index 0000000..e6858f8 --- /dev/null +++ b/src/sieve/index.js @@ -0,0 +1,14 @@ +export * from './eratosthenes' ; +export * from './eratosthenes2' ; +export * from './eratosthenes23' ; +export * from './gothrough' ; +export * from './itop' ; +export * from './itop2' ; +export * from './itop23' ; +export * from './itop230' ; +export * from './itop231' ; +export * from './ptoi' ; +export * from './ptoi2' ; +export * from './ptoi23' ; +export * from './ptoi230' ; +export * from './ptoi231' ; diff --git a/src/sieve/itop.js b/src/sieve/itop.js new file mode 100644 index 0000000..e474178 --- /dev/null +++ b/src/sieve/itop.js @@ -0,0 +1,4 @@ + +export function itop ( i ) { + return i ; +} diff --git a/src/sieve/itop2.js b/src/sieve/itop2.js new file mode 100644 index 0000000..e052126 --- /dev/null +++ b/src/sieve/itop2.js @@ -0,0 +1,4 @@ + +export function itop2 (i) { + return i * 2 + 1; +} diff --git a/src/sieve/itop23.js b/src/sieve/itop23.js new file mode 100644 index 0000000..c1c45b7 --- /dev/null +++ b/src/sieve/itop23.js @@ -0,0 +1,4 @@ + +export function itop23 ( i ) { + return ( i % 2 === 0 ) ? itop230( i ) : itop231( i ) ; +} diff --git a/src/sieve/itop230.js b/src/sieve/itop230.js new file mode 100644 index 0000000..269861b --- /dev/null +++ b/src/sieve/itop230.js @@ -0,0 +1,4 @@ + +export function itop230 ( i ) { + return 6 * ( ( i / 2 | 0 ) + 1 ) - 1 ; +} diff --git a/src/sieve/itop231.js b/src/sieve/itop231.js new file mode 100644 index 0000000..48a8af4 --- /dev/null +++ b/src/sieve/itop231.js @@ -0,0 +1,4 @@ + +export function itop231 ( i ) { + return 6 * ( ( i / 2 | 0 ) + 1 ) + 1 ; +} diff --git a/src/sieve/ptoi.js b/src/sieve/ptoi.js new file mode 100644 index 0000000..95ada0c --- /dev/null +++ b/src/sieve/ptoi.js @@ -0,0 +1,4 @@ + +export function ptoi ( p ) { + return p ; +} diff --git a/src/sieve/ptoi2.js b/src/sieve/ptoi2.js new file mode 100644 index 0000000..e908e1e --- /dev/null +++ b/src/sieve/ptoi2.js @@ -0,0 +1,4 @@ + +export function ptoi2 (p) { + return p / 2 | 0; +} diff --git a/src/sieve/ptoi23.js b/src/sieve/ptoi23.js new file mode 100644 index 0000000..1072ff7 --- /dev/null +++ b/src/sieve/ptoi23.js @@ -0,0 +1,4 @@ + +export function ptoi23 ( p ) { + return ( p % 6 > 4 ) ? ptoi230( p ) : ptoi231( p ) ; +} diff --git a/src/sieve/ptoi230.js b/src/sieve/ptoi230.js new file mode 100644 index 0000000..d75dda5 --- /dev/null +++ b/src/sieve/ptoi230.js @@ -0,0 +1,4 @@ + +export function ptoi230 ( p ) { + return Math.ceil( ( p + 1 ) / 3 ) - 2 ; +} diff --git a/src/sieve/ptoi231.js b/src/sieve/ptoi231.js new file mode 100644 index 0000000..4c11a3f --- /dev/null +++ b/src/sieve/ptoi231.js @@ -0,0 +1,4 @@ + +export function ptoi231 ( p ) { + return Math.ceil( ( p - 1 ) / 3 ) - 1 ; +} diff --git a/js/src/ulam/atos.js b/src/ulam/atos.js similarity index 90% rename from js/src/ulam/atos.js rename to src/ulam/atos.js index f21ea12..cf8e950 100644 --- a/js/src/ulam/atos.js +++ b/src/ulam/atos.js @@ -4,7 +4,7 @@ * */ -var atos = function ( i , n ) { + export function atos ( i , n ) { var s, l, r, L, R, x, y; @@ -38,6 +38,4 @@ var atos = function ( i , n ) { } return n * y + x; -}; - -exports.atos = atos; +} diff --git a/src/ulam/index.js b/src/ulam/index.js new file mode 100644 index 0000000..8e9aaf0 --- /dev/null +++ b/src/ulam/index.js @@ -0,0 +1,2 @@ +export * from './atos' ; +export * from './stoa' ; diff --git a/js/src/ulam/stoa.js b/src/ulam/stoa.js similarity index 91% rename from js/src/ulam/stoa.js rename to src/ulam/stoa.js index de59e4d..93455f8 100644 --- a/js/src/ulam/stoa.js +++ b/src/ulam/stoa.js @@ -4,7 +4,7 @@ * */ -var stoa = function ( i , n ) { +export function stoa ( i , n ) { var line, col, ring_index, side_col, side_line, sub_size; @@ -34,6 +34,5 @@ var stoa = function ( i , n ) { sub_size = n - ring_index * 2; return sub_size * sub_size - (sub_size - 1) * 2 + side_line * (line - ring_index) - side_col * (col - ring_index) - 1; -}; -exports.stoa = stoa; +} diff --git a/test/js/data/1000.json b/test/data/1000.json similarity index 100% rename from test/js/data/1000.json rename to test/data/1000.json diff --git a/test/js/index.js b/test/js/index.js deleted file mode 100644 index 869a49d..0000000 --- a/test/js/index.js +++ /dev/null @@ -1,10 +0,0 @@ -var pkg = require('aureooms-node-package'); - - -var opt = { - src : __dirname + '/src/', - exports : module.exports, - base : 0 -}; - -pkg.include(opt); diff --git a/test/js/src/analyze/factorize.js b/test/js/src/analyze/factorize.js deleted file mode 100644 index 7349865..0000000 --- a/test/js/src/analyze/factorize.js +++ /dev/null @@ -1,25 +0,0 @@ - -var number , two , iaddone , iszero , gtone , divmod ; - -number = require ( "aureooms-js-number" ) ; - -two = number . two ; -iaddone = number . iaddone ; -iszero = number . iszero ; -gtone = number . gtone ; -divmod = number . divmod ; - - -test ( "factorize" , function ( ) { - - var factorize , factors ; - - factorize = prime . __factorize__ ( two, iaddone, iszero, gtone, divmod ) ; - - factors = [ ] ; - - factorize ( 15, factors ) ; - - deepEqual ( factors , [ 3 , 5 ] , "15 is 3 * 5" ) ; - -} ) ; diff --git a/test/js/src/limits/upperbound.js b/test/js/src/limits/upperbound.js deleted file mode 100644 index 32bd1eb..0000000 --- a/test/js/src/limits/upperbound.js +++ /dev/null @@ -1,19 +0,0 @@ - -var number ; - -number = require( "aureooms-js-number" ) ; - -test( "limits" , function ( ) { - - var upperbound ; - - upperbound = prime.__upperbound__( number.loge , number.logloge ) ; - - ok( upperbound( 54 ) > 251 , "54" ) ; - ok( upperbound( 55 ) > 257 , "55" ) ; - ok( upperbound( 1000 ) > 7919 , "1000" ) ; - ok( upperbound( 39017 ) > 467473 , "39017" ) ; - ok( upperbound( 39018 ) > 467477 , "39018" ) ; - - -} ) ; diff --git a/test/js/src/sieve/sieves.js b/test/js/src/sieve/sieves.js deleted file mode 100644 index 39874dd..0000000 --- a/test/js/src/sieve/sieves.js +++ /dev/null @@ -1,47 +0,0 @@ - -var run , array , uint32 , functools , itertools , data , alloc , fill , get , gothrough , usqrt; - -array = require( "aureooms-js-array" ) ; -uint32 = require( "aureooms-js-uint32") ; -functools = require( "aureooms-js-functools" ) ; -itertools = require( "aureooms-js-itertools" ) ; - -data = require( "../../data/1000.json" ) ; - -alloc = array.alloc ; -fill = array.fill ; -get = array.get ; -gothrough = prime.__gothrough__( array.set ) ; -usqrt = uint32.usqrt ; - -run = function ( sievename , sieve , n ) { - - test( sievename + " " + n , function ( ) { - - var i , primes , len ; - - primes = [] ; - - sieve( n , functools.bind( primes.push , primes , [] ) ) ; - - len = primes.length ; - - deepEqual( primes , data.slice( 0 , len ) , "set contains the first " + len + " prime numbers" ) ; - ok( data[len] >= n , "found all primes below " + n + ", next is " + data[len] ) ; - - - } ) ; - -} ; - - -itertools.product( [ - - [ - [ "Eratosthenes" , prime.__eratosthenes__( alloc , fill , get , gothrough , usqrt ) ], - [ "Eratosthenes - 2" , prime.__eratosthenes2__( alloc , fill , get , gothrough , usqrt ) ], - [ "Eratosthenes - 2 , 3" , prime.__eratosthenes23__( alloc , fill , get , gothrough , usqrt ) ] - ], - [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 10 , 15 , 49 ,100 , 200 , 1000 , 7919 ] - -] , 1 , [] ).forEach( functools.partial( functools.star , run ) ) ; diff --git a/test/js/src/ulam/convert.js b/test/js/src/ulam/convert.js deleted file mode 100644 index 6716a68..0000000 --- a/test/js/src/ulam/convert.js +++ /dev/null @@ -1,79 +0,0 @@ - -/** -* Converts an array index to a square Ulam spiral index. -* -* n = 1 -* -* 1 -* -* n = 2 -* -* 4 3 -* 1 2 -* -* n = 3 -* -* 5 4 3 -* 6 1 2 -* 7 8 9 -* -* n = 4 -* -* 16 15 14 13 -* 5 4 3 12 -* 6 1 2 11 -* 7 8 9 10 -* -* n = 5 -* -* 17 16 15 14 13 -* 18 5 4 3 12 -* 19 6 1 2 11 -* 20 7 8 9 10 -* 21 22 23 24 25 -* -*/ - -test( "ulam convert" , function ( ) { - - var i , atos , stoa , as , sa , backandforth ; - - atos = prime.atos ; - stoa = prime.stoa ; - - deepEqual( atos( 0 , 1 ) , 0 * 1 + 0 , "1 should be the only element ( n = 1 )" ) ; - deepEqual( atos( 0 , 2 ) , 1 * 2 + 0 , "1 should be in the upper left corner ( n = 2 )" ) ; - deepEqual( atos( 0 , 3 ) , 1 * 3 + 1 , "1 should be in the center ( n = 3 )" ) ; - deepEqual( atos( 0 , 4 ) , 2 * 4 + 1 , "1 should be in the upper left of the center ( n = 4 )" ) ; - deepEqual( atos( 0 , 5 ) , 2 * 5 + 2 , "1 should be in the center ( n = 5 )" ) ; - - deepEqual( stoa( 0 * 1 + 0 , 1 ) , 0 , "the only element should be 1 ( n = 1 )" ) ; - deepEqual( stoa( 1 * 2 + 0 , 2 ) , 0 , "the upper left corner should contain 1 ( n = 2 )" ) ; - deepEqual( stoa( 1 * 3 + 1 , 3 ) , 0 , "the center should contain 1 ( n = 3 )" ) ; - deepEqual( stoa( 2 * 4 + 1 , 4 ) , 0 , "the upper left of the center should contain 1 ( n = 4 )" ) ; - deepEqual( stoa( 2 * 5 + 2 , 5 ) , 0 , "the center should contain 1 ( n = 5 )" ) ; - - as = function ( i , n ) { - return atos( stoa( i , n ) , n ) ; - } ; - - sa = function ( i , n ) { - return stoa( atos( i , n ) , n ) ; - } ; - - backandforth = function ( n ) { - - for ( i = 0 ; i < n * n ; ++i ) { - deepEqual( as( i , n ) , i , "as( " + i + " , 3 )" ) ; - deepEqual( sa( i , n ) , i , "sa( " + i + " , 3 )" ) ; - } - - } ; - - backandforth( 1 ) ; - backandforth( 2 ) ; - backandforth( 3 ) ; - backandforth( 4 ) ; - backandforth( 5 ) ; - -} ) ; diff --git a/test/src/analyze/factorize.js b/test/src/analyze/factorize.js new file mode 100644 index 0000000..cb11ce4 --- /dev/null +++ b/test/src/analyze/factorize.js @@ -0,0 +1,17 @@ +import test from 'ava' ; + +import { two, iaddone, iszero, gtone, divmod } from "aureooms-js-number" ; + +import * as prime from '../../../src' ; + +test ( "factorize" , t => { + + const factorize = prime . __factorize__ ( two, iaddone, iszero, gtone, divmod ) ; + + const factors = [ ] ; + + factorize ( 15, factors ) ; + + t.deepEqual ( factors , [ 3 , 5 ] , "15 is 3 * 5" ) ; + +} ) ; diff --git a/test/src/limits/upperbound.js b/test/src/limits/upperbound.js new file mode 100644 index 0000000..6627b4d --- /dev/null +++ b/test/src/limits/upperbound.js @@ -0,0 +1,17 @@ +import test from 'ava' ; + +import { loge , logloge } from "aureooms-js-number" ; + +import * as prime from '../../../src' ; + +test( "limits" , t => { + + const upperbound = prime.__upperbound__( loge , logloge ) ; + + t.true( upperbound( 54 ) > 251 , "54" ) ; + t.true( upperbound( 55 ) > 257 , "55" ) ; + t.true( upperbound( 1000 ) > 7919 , "1000" ) ; + t.true( upperbound( 39017 ) > 467473 , "39017" ) ; + t.true( upperbound( 39018 ) > 467477 , "39018" ) ; + +} ) ; diff --git a/test/src/sieve/sieves.js b/test/src/sieve/sieves.js new file mode 100644 index 0000000..008683a --- /dev/null +++ b/test/src/sieve/sieves.js @@ -0,0 +1,42 @@ +import test from 'ava' ; + +import { alloc , fill , get , set } from "aureooms-js-array" ; +import { usqrt } from "aureooms-js-uint32" ; +import functools from "aureooms-js-functools" ; +import * as itertools from "aureooms-js-itertools" ; + +const data = require( "../../data/1000.json" ) ; + +import * as prime from '../../../src' ; + +const gothrough = prime.__gothrough__( set ) ; + +function run ( [ [ sievename , sieve ] , n ] ) { + + test( sievename + " " + n , t => { + + const primes = [] ; + + sieve( n , functools.bind( primes.push , primes , [] ) ) ; + + const len = primes.length ; + + t.deepEqual( primes , data.slice( 0 , len ) , "set contains the first " + len + " prime numbers" ) ; + t.true( data[len] >= n , "found all primes below " + n + ", next is " + data[len] ) ; + + } ) ; + +} ; + +const inputs = itertools.product( [ + + [ + [ "Eratosthenes" , prime.__eratosthenes__( alloc , fill , get , gothrough , usqrt ) ], + [ "Eratosthenes - 2" , prime.__eratosthenes2__( alloc , fill , get , gothrough , usqrt ) ], + [ "Eratosthenes - 2 , 3" , prime.__eratosthenes23__( alloc , fill , get , gothrough , usqrt ) ] + ], + [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 10 , 15 , 49 ,100 , 200 , 1000 , 7919 ] + +] , 1 ) ; + +for ( const x of inputs ) run( x ) ; diff --git a/test/src/ulam/convert.js b/test/src/ulam/convert.js new file mode 100644 index 0000000..7af7d6d --- /dev/null +++ b/test/src/ulam/convert.js @@ -0,0 +1,76 @@ + +/** +* Converts an array index to a square Ulam spiral index. +* +* n = 1 +* +* 1 +* +* n = 2 +* +* 4 3 +* 1 2 +* +* n = 3 +* +* 5 4 3 +* 6 1 2 +* 7 8 9 +* +* n = 4 +* +* 16 15 14 13 +* 5 4 3 12 +* 6 1 2 11 +* 7 8 9 10 +* +* n = 5 +* +* 17 16 15 14 13 +* 18 5 4 3 12 +* 19 6 1 2 11 +* 20 7 8 9 10 +* 21 22 23 24 25 +* +*/ +import test from 'ava' ; +import { atos , stoa } from '../../../src' ; + +test( "ulam convert" , t => { + + t.is( atos( 0 , 1 ) , 0 * 1 + 0 , "1 should be the only element ( n = 1 )" ) ; + t.is( atos( 0 , 2 ) , 1 * 2 + 0 , "1 should be in the upper left corner ( n = 2 )" ) ; + t.is( atos( 0 , 3 ) , 1 * 3 + 1 , "1 should be in the center ( n = 3 )" ) ; + t.is( atos( 0 , 4 ) , 2 * 4 + 1 , "1 should be in the upper left of the center ( n = 4 )" ) ; + t.is( atos( 0 , 5 ) , 2 * 5 + 2 , "1 should be in the center ( n = 5 )" ) ; + + t.is( stoa( 0 * 1 + 0 , 1 ) , 0 , "the only element should be 1 ( n = 1 )" ) ; + t.is( stoa( 1 * 2 + 0 , 2 ) , 0 , "the upper left corner should contain 1 ( n = 2 )" ) ; + t.is( stoa( 1 * 3 + 1 , 3 ) , 0 , "the center should contain 1 ( n = 3 )" ) ; + t.is( stoa( 2 * 4 + 1 , 4 ) , 0 , "the upper left of the center should contain 1 ( n = 4 )" ) ; + t.is( stoa( 2 * 5 + 2 , 5 ) , 0 , "the center should contain 1 ( n = 5 )" ) ; + + const as = function ( i , n ) { + return atos( stoa( i , n ) , n ) ; + } ; + + const sa = function ( i , n ) { + return stoa( atos( i , n ) , n ) ; + } ; + + const backandforth = function ( n ) { + + for ( let i = 0 ; i < n * n ; ++i ) { + t.is( as( i , n ) , i , "as( " + i + " , 3 )" ) ; + t.is( sa( i , n ) , i , "sa( " + i + " , 3 )" ) ; + } + + } ; + + backandforth( 1 ) ; + backandforth( 2 ) ; + backandforth( 3 ) ; + backandforth( 4 ) ; + backandforth( 5 ) ; + +} ) ;