diff --git a/CHANGELOG.md b/CHANGELOG.md index 503d5e604..14f34d143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -186,6 +186,28 @@ +
+ +#### [@stdlib/math/base/special/erf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/erf) + +
+ +
+ +##### Bug Fixes + +- [`3e201d7`](https://github.com/stdlib-js/stdlib/commit/3e201d779fa5844dd5808418f103f37d1a905d61) - update function alias and add WebAssembly configuration + +
+ + + +
+ +
+ + +
#### [@stdlib/math/base/special/erfcx](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/erfcx) @@ -409,6 +431,15 @@ A total of 4 people contributed to this release. Thank you to the following cont
+- [`24fadbf`](https://github.com/stdlib-js/stdlib/commit/24fadbf27f7a01624648ed5bea5cce504b3f65d1) - **bench:** fix runner _(by Athan Reines)_ +- [`8f0f3b6`](https://github.com/stdlib-js/stdlib/commit/8f0f3b65ddcd28963d55d7956a22d801f59155fa) - **bench:** use SpecialFunctions package _(by Athan Reines)_ +- [`c94a8b2`](https://github.com/stdlib-js/stdlib/commit/c94a8b2eee5d00c623ecccbb0aeef4daefb4ed06) - **bench:** update value ranges _(by Athan Reines)_ +- [`2e75575`](https://github.com/stdlib-js/stdlib/commit/2e7557545d196c0af52afe1df1800735d7068836) - **build:** add WebAssembly configuration _(by Athan Reines)_ +- [`4531104`](https://github.com/stdlib-js/stdlib/commit/45311043928ef04b43f9045965c4c5fdacf3f434) - **build:** add WebAssembly configuration _(by Athan Reines)_ +- [`c20c2c3`](https://github.com/stdlib-js/stdlib/commit/c20c2c34c3f7f87ab1902cbbefaffd1729077370) - **build:** add WebAssembly configuration _(by Athan Reines)_ +- [`6b54c29`](https://github.com/stdlib-js/stdlib/commit/6b54c297e4f7eb90c4c6432896a2a62c4cb77de4) - **build:** add WebAssembly configuration _(by Athan Reines)_ +- [`3e201d7`](https://github.com/stdlib-js/stdlib/commit/3e201d779fa5844dd5808418f103f37d1a905d61) - **fix:** update function alias and add WebAssembly configuration _(by Athan Reines)_ +- [`644c390`](https://github.com/stdlib-js/stdlib/commit/644c39075c6d5b630f8d0e2fce1ecbde540a9892) - **build:** add WebAssembly configuration and fix indentation _(by Athan Reines)_ - [`c24de14`](https://github.com/stdlib-js/stdlib/commit/c24de14b9ee9c026f00c40ed378077007a8054b0) - **chore:** clean-up docs, benchmarks, and examples _(by Athan Reines)_ - [`16c903b`](https://github.com/stdlib-js/stdlib/commit/16c903bdbd31c7d81bc3d6811e942e35c6de38e6) - **fix:** add missing `native.js` and fix indentation [(#2975)](https://github.com/stdlib-js/stdlib/pull/2975) _(by Gunj Joshi)_ - [`aa94a37`](https://github.com/stdlib-js/stdlib/commit/aa94a37728cfa9d7356f9a9880bfc411f302443a) - **refactor:** remove hardcoded constant [(#2970)](https://github.com/stdlib-js/stdlib/pull/2970) _(by Gunj Joshi)_ diff --git a/base/special/abs/manifest.json b/base/special/abs/manifest.json index a244297e4..6656f3cb4 100644 --- a/base/special/abs/manifest.json +++ b/base/special/abs/manifest.json @@ -1,75 +1,95 @@ { - "options": { - "task": "build" - }, - "fields": [ - { - "field": "src", - "resolve": true, - "relative": true - }, - { - "field": "include", - "resolve": true, - "relative": true - }, - { - "field": "libraries", - "resolve": false, - "relative": false - }, - { - "field": "libpath", - "resolve": true, - "relative": false - } - ], - "confs": [ - { - "task": "build", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/math/base/napi/unary", - "@stdlib/constants/float64/high-word-abs-mask", + "options": { + "task": "build", + "wasm": false + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/unary", + "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/number/float64/base/to-words" - ] - }, - { - "task": "benchmark", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/constants/float64/high-word-abs-mask", + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/number/float64/base/to-words" - ] - }, - { - "task": "examples", - "src": [ - "./src/main.c" - ], - "include": [ - "./include" - ], - "libraries": [], - "libpath": [], - "dependencies": [ - "@stdlib/constants/float64/high-word-abs-mask", + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float64/high-word-abs-mask", "@stdlib/number/float64/base/to-words" - ] - } - ] + ] + }, + { + "task": "build", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/number/float64/base/to-words" + ] + } + ] } diff --git a/base/special/copysign/manifest.json b/base/special/copysign/manifest.json index 1c7a47f68..40da05258 100644 --- a/base/special/copysign/manifest.json +++ b/base/special/copysign/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,15 +28,14 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/constants/float64/high-word-abs-mask", @@ -48,15 +48,14 @@ }, { "task": "benchmark", + "wasm": false, "src": [ "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/constants/float64/high-word-abs-mask", @@ -68,15 +67,33 @@ }, { "task": "examples", + "wasm": false, "src": [ "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/constants/float64/high-word-abs-mask", + "@stdlib/constants/float64/high-word-sign-mask", + "@stdlib/number/float64/base/to-words", + "@stdlib/number/float64/base/get-high-word", + "@stdlib/number/float64/base/from-words" + ] + }, + { + "task": "build", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/constants/float64/high-word-abs-mask", diff --git a/base/special/erf/benchmark/benchmark.js b/base/special/erf/benchmark/benchmark.js index ce619f47f..76882161e 100644 --- a/base/special/erf/benchmark/benchmark.js +++ b/base/special/erf/benchmark/benchmark.js @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( './../../../../base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var erf = require( './../lib' ); @@ -34,10 +34,13 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = uniform( 10, -1.0, 1.0, { + 'dtype': 'generic' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = erf( x ); + y = erf( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/base/special/erf/benchmark/benchmark.native.js b/base/special/erf/benchmark/benchmark.native.js index 5fb6f18c1..bd0799358 100644 --- a/base/special/erf/benchmark/benchmark.native.js +++ b/base/special/erf/benchmark/benchmark.native.js @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/array/uniform' ); var isnan = require( './../../../../base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,13 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = uniform( 10, -1.0, 1.0, { + 'dtype': 'generic' + }); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = erf( x ); + y = erf( x[ i%x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/base/special/erf/benchmark/c/benchmark.c b/base/special/erf/benchmark/c/benchmark.c index d886cea22..594df4612 100644 --- a/base/special/erf/benchmark/c/benchmark.c +++ b/base/special/erf/benchmark/c/benchmark.c @@ -97,7 +97,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; + x = ( 2.0*rand_double() ) - 1.0; y = erf( x ); if ( y != y ) { printf( "should not return NaN\n" ); diff --git a/base/special/erf/benchmark/c/native/benchmark.c b/base/special/erf/benchmark/c/native/benchmark.c index 48f2f3dec..9c0029ca4 100644 --- a/base/special/erf/benchmark/c/native/benchmark.c +++ b/base/special/erf/benchmark/c/native/benchmark.c @@ -98,7 +98,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; + x = ( 2.0*rand_double() ) - 1.0; y = stdlib_base_erf( x ); if ( y != y ) { printf( "should not return NaN\n" ); diff --git a/base/special/erf/benchmark/cpp/boost/benchmark.cpp b/base/special/erf/benchmark/cpp/boost/benchmark.cpp index d1db77a33..c3cf25777 100644 --- a/base/special/erf/benchmark/cpp/boost/benchmark.cpp +++ b/base/special/erf/benchmark/cpp/boost/benchmark.cpp @@ -95,7 +95,7 @@ double benchmark() { mt19937 rng; // Define a uniform distribution for generating pseudorandom numbers as "doubles" between a minimum value (inclusive) and a maximum value (exclusive): - uniform_real_distribution<> randu( -500.0, 500.0 ); + uniform_real_distribution<> randu( -1.0, 1.0 ); t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { diff --git a/base/special/erf/benchmark/julia/REQUIRE b/base/special/erf/benchmark/julia/REQUIRE index 98645e192..4db98c773 100644 --- a/base/special/erf/benchmark/julia/REQUIRE +++ b/base/special/erf/benchmark/julia/REQUIRE @@ -1,2 +1,3 @@ julia 1.5 BenchmarkTools 0.5.0 +SpecialFunctions 0.10.3 diff --git a/base/special/erf/benchmark/julia/benchmark.jl b/base/special/erf/benchmark/julia/benchmark.jl index d970fa3bd..dc00e68ef 100644 --- a/base/special/erf/benchmark/julia/benchmark.jl +++ b/base/special/erf/benchmark/julia/benchmark.jl @@ -17,6 +17,7 @@ # limitations under the License. import BenchmarkTools +using SpecialFunctions using Printf # Benchmark variables: @@ -107,7 +108,7 @@ julia> out = benchmark(); ``` """ function benchmark() - t = BenchmarkTools.@benchmark erf( (1000.0*rand()) - 500.0 ) samples=1e6 + t = BenchmarkTools.@benchmark erf( (2.0*rand()) - 1.0 ) samples=1e6 # Compute the total "elapsed" time and convert from nanoseconds to seconds: s = sum( t.times ) / 1.0e9; diff --git a/base/special/erf/benchmark/python/benchmark.py b/base/special/erf/benchmark/python/benchmark.py index 70898bd92..ee5b2a6a5 100644 --- a/base/special/erf/benchmark/python/benchmark.py +++ b/base/special/erf/benchmark/python/benchmark.py @@ -73,7 +73,7 @@ def print_results(elapsed): def benchmark(): """Run the benchmark and print benchmark results.""" setup = "from math import erf; from random import random;" - stmt = "y = erf(1000.0*random() - 500.0)" + stmt = "y = erf(2.0*random() - 1.0)" t = timeit.Timer(stmt, setup=setup) diff --git a/base/special/erf/benchmark/python/scipy/benchmark.py b/base/special/erf/benchmark/python/scipy/benchmark.py index 60b0d92c8..9ea541205 100644 --- a/base/special/erf/benchmark/python/scipy/benchmark.py +++ b/base/special/erf/benchmark/python/scipy/benchmark.py @@ -73,7 +73,7 @@ def print_results(elapsed): def benchmark(): """Run the benchmark and print benchmark results.""" setup = "from scipy.special import erf; from random import random;" - stmt = "y = erf(1000.0*random() - 500.0)" + stmt = "y = erf(2.0*random() - 1.0)" t = timeit.Timer(stmt, setup=setup) diff --git a/base/special/erf/benchmark/r/benchmark.R b/base/special/erf/benchmark/r/benchmark.R index 9745244b5..ed03895a0 100644 --- a/base/special/erf/benchmark/r/benchmark.R +++ b/base/special/erf/benchmark/r/benchmark.R @@ -25,7 +25,7 @@ options( digits = 16L ); #' main(); main <- function() { # Define benchmark parameters: - name <- "erf"; + name <- 'erf'; iterations <- 1000000L; repeats <- 3L; @@ -34,7 +34,7 @@ main <- function() { #' @examples #' print_version(); print_version <- function() { - cat( "TAP version 13\n" ); + cat( 'TAP version 13\n' ); } #' Print the TAP summary. @@ -45,12 +45,12 @@ main <- function() { #' @examples #' print_summary( 3, 3 ); print_summary <- function( total, passing ) { - cat( "#\n" ); - cat( paste0( "1..", total, "\n" ) ); # TAP plan - cat( paste0( "# total ", total, "\n" ) ); - cat( paste0( "# pass ", passing, "\n" ) ); - cat( "#\n" ); - cat( "# ok\n" ); + cat( '#\n' ); + cat( paste0( '1..', total, '\n' ) ); # TAP plan + cat( paste0( '# total ', total, '\n' ) ); + cat( paste0( '# pass ', passing, '\n' ) ); + cat( '#\n' ); + cat( '# ok\n' ); } #' Print benchmark results. @@ -62,11 +62,11 @@ main <- function() { #' print_results( 10000L, 0.131009101868 ); print_results <- function( iterations, elapsed ) { rate <- iterations / elapsed; - cat( " ---\n" ); - cat( paste0( " iterations: ", iterations, "\n" ) ); - cat( paste0( " elapsed: ", elapsed, "\n" ) ); - cat( paste0( " rate: ", rate, "\n" ) ); - cat( " ...\n" ); + cat( ' ---\n' ); + cat( paste0( ' iterations: ', iterations, '\n' ) ); + cat( paste0( ' elapsed: ', elapsed, '\n' ) ); + cat( paste0( ' rate: ', rate, '\n' ) ); + cat( ' ...\n' ); } #' Error function. @@ -96,10 +96,10 @@ main <- function() { #' elapsed <- benchmark( 10000L ); benchmark <- function( iterations ) { # Run the benchmarks: - results <- microbenchmark::microbenchmark( erf( (1000.0*runif(1)) - 500.0 ), times = iterations ); + results <- microbenchmark::microbenchmark( erf( (2.0*runif(1L)) - 1.0 ), times = iterations ); # Sum all the raw timing results to get a total "elapsed" time: - elapsed <- sum( results$time ); + elapsed <- sum( results[[ 'time' ]] ); # Convert the elapsed time from nanoseconds to seconds: elapsed <- elapsed / 1.0e9; @@ -108,11 +108,11 @@ main <- function() { } print_version(); - for ( i in 1:repeats ) { - cat( paste0( "# r::", name, "\n" ) ); + for ( i in 1L:repeats ) { + cat( paste0( '# r::', name, '\n' ) ); elapsed <- benchmark( iterations ); print_results( iterations, elapsed ); - cat( paste0( "ok ", i, " benchmark finished", "\n" ) ); + cat( paste0( 'ok ', i, ' benchmark finished', '\n' ) ); } print_summary( repeats, repeats ); } diff --git a/base/special/erf/manifest.json b/base/special/erf/manifest.json index 4c4cf755f..461e8c261 100644 --- a/base/special/erf/manifest.json +++ b/base/special/erf/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,6 +28,7 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], @@ -46,6 +48,7 @@ }, { "task": "benchmark", + "wasm": false, "src": [ "./src/main.c" ], @@ -64,6 +67,26 @@ }, { "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/constants/float64/ninf", + "@stdlib/constants/float64/pinf", + "@stdlib/math/base/special/exp", + "@stdlib/number/float64/base/set-low-word" + ] + }, + { + "task": "build", + "wasm": true, "src": [ "./src/main.c" ], diff --git a/base/special/erf/src/main.c b/base/special/erf/src/main.c index 6c9d49f1e..e2762eab1 100644 --- a/base/special/erf/src/main.c +++ b/base/special/erf/src/main.c @@ -524,7 +524,7 @@ double stdlib_base_erf( const double x ) { } z = ax; stdlib_base_float64_set_low_word( 0, &z ); // pseudo-single (20-bit) precision x - r = stdlib_base_exp( -( z * z ) - 0.5625 ) * exp( ( ( z - ax ) * ( z + ax ) ) + ( r / s ) ); + r = stdlib_base_exp( -( z * z ) - 0.5625 ) * stdlib_base_exp( ( ( z - ax ) * ( z + ax ) ) + ( r / s ) ); if ( sign == 1 ) { return ( r / ax ) - 1.0; } diff --git a/base/special/exp/manifest.json b/base/special/exp/manifest.json index 1d3521600..51b187fce 100644 --- a/base/special/exp/manifest.json +++ b/base/special/exp/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,6 +28,7 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], @@ -46,6 +48,7 @@ }, { "task": "benchmark", + "wasm": false, "src": [ "./src/main.c" ], @@ -64,6 +67,26 @@ }, { "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nan", + "@stdlib/constants/float64/ninf", + "@stdlib/constants/float64/pinf", + "@stdlib/math/base/special/trunc", + "@stdlib/math/base/special/ldexp" + ] + }, + { + "task": "build", + "wasm": true, "src": [ "./src/main.c" ], diff --git a/base/special/ldexp/manifest.json b/base/special/ldexp/manifest.json index ef4b3055a..6ecdff858 100644 --- a/base/special/ldexp/manifest.json +++ b/base/special/ldexp/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,6 +28,7 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/main.c" ], @@ -54,6 +56,7 @@ }, { "task": "examples", + "wasm": false, "src": [ "./src/main.c" ], @@ -84,6 +87,35 @@ }, { "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/abs", + "@stdlib/number/float64/base/normalize", + "@stdlib/number/float64/base/exponent", + "@stdlib/number/float64/base/from-words", + "@stdlib/number/float32/base/to-word", + "@stdlib/math/base/special/copysign", + "@stdlib/constants/float64/ninf", + "@stdlib/constants/float64/pinf", + "@stdlib/constants/float64/min-base2-exponent-subnormal", + "@stdlib/constants/float64/max-base2-exponent", + "@stdlib/constants/float64/max-base2-exponent-subnormal", + "@stdlib/constants/float64/exponent-bias" + ] + }, + { + "task": "build", + "wasm": true, "src": [ "./src/main.c" ], diff --git a/base/special/trunc/manifest.json b/base/special/trunc/manifest.json index b9e5911b6..a0cd7b7a2 100644 --- a/base/special/trunc/manifest.json +++ b/base/special/trunc/manifest.json @@ -1,6 +1,7 @@ { "options": { - "task": "build" + "task": "build", + "wasm": false }, "fields": [ { @@ -27,6 +28,7 @@ "confs": [ { "task": "build", + "wasm": false, "src": [ "./src/trunc.c" ], @@ -43,6 +45,7 @@ }, { "task": "benchmark", + "wasm": false, "src": [ "./src/trunc.c" ], @@ -57,6 +60,22 @@ }, { "task": "examples", + "wasm": false, + "src": [ + "./src/trunc.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [] + }, + { + "task": "build", + "wasm": true, "src": [ "./src/trunc.c" ],