From 651fc0a5a55b56dcb5c69b64583ef76c3432cdf9 Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Fri, 19 Apr 2024 21:42:51 +0000 Subject: [PATCH] Auto-generated commit --- base/special/rcbrt/README.md | 8 +- base/special/rcbrt/benchmark/benchmark.js | 4 +- .../rcbrt/benchmark/benchmark.native.js | 2 +- base/special/rcbrt/docs/repl.txt | 2 +- base/special/rcbrt/examples/index.js | 6 +- base/special/rcbrt/manifest.json | 18 +-- base/special/rcbrt/src/addon.c | 1 + base/special/rcbrt/src/{rcbrt.c => main.c} | 4 +- base/special/rcbrt/test/test.js | 152 +++++++++--------- base/special/rcbrt/test/test.native.js | 144 ++++++++--------- 10 files changed, 166 insertions(+), 175 deletions(-) rename base/special/rcbrt/src/{rcbrt.c => main.c} (93%) diff --git a/base/special/rcbrt/README.md b/base/special/rcbrt/README.md index 10cc9eee9..7de83c93e 100644 --- a/base/special/rcbrt/README.md +++ b/base/special/rcbrt/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# Reciprocal Cube Root +# rcbrt > Compute the reciprocal of the principal [cube root][cube-root] of a double-precision floating-point number. @@ -86,15 +86,13 @@ v = rcbrt( Infinity ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var rcbrt = require( '@stdlib/math/base/special/rcbrt' ); var x; var i; - for ( i = 0; i < 100; i++ ) { - x = round( randu() * 100.0 ); + x = discreteUniform( 0.0, 100.0 ); console.log( 'rcbrt(%d) = %d', x, rcbrt( x ) ); } ``` diff --git a/base/special/rcbrt/benchmark/benchmark.js b/base/special/rcbrt/benchmark/benchmark.js index ce37f3ec0..b42bb4c7b 100644 --- a/base/special/rcbrt/benchmark/benchmark.js +++ b/base/special/rcbrt/benchmark/benchmark.js @@ -43,7 +43,7 @@ bench( pkg, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; + x = ( randu() * 100000.0 ) - 0.0; y = rcbrt( x ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); @@ -64,7 +64,7 @@ bench( pkg+'::built-in', opts, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; + x = ( randu() * 100000.0 ) - 0.0; y = 1.0 / Math.cbrt( x ); // eslint-disable-line stdlib/no-builtin-math if ( isnan( y ) ) { b.fail( 'should not return NaN' ); diff --git a/base/special/rcbrt/benchmark/benchmark.native.js b/base/special/rcbrt/benchmark/benchmark.native.js index c95a44361..7f294f7b3 100644 --- a/base/special/rcbrt/benchmark/benchmark.native.js +++ b/base/special/rcbrt/benchmark/benchmark.native.js @@ -45,7 +45,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*100000.0 ) - 0.0; + x = ( randu() * 100000.0 ) - 0.0; y = rcbrt( x ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); diff --git a/base/special/rcbrt/docs/repl.txt b/base/special/rcbrt/docs/repl.txt index 0a0ee1654..644fe4287 100644 --- a/base/special/rcbrt/docs/repl.txt +++ b/base/special/rcbrt/docs/repl.txt @@ -21,7 +21,7 @@ 0.1 > y = {{alias}}( 0.0 ) Infinity - > y = {{alias}}( Infinity ) + > y = {{alias}}( {{alias:@stdlib/constants/float64/pinf}} ) 0.0 > y = {{alias}}( -8.0 ) -0.5 diff --git a/base/special/rcbrt/examples/index.js b/base/special/rcbrt/examples/index.js index 7dbc8e647..be4cf4da9 100644 --- a/base/special/rcbrt/examples/index.js +++ b/base/special/rcbrt/examples/index.js @@ -18,14 +18,12 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( './../../../../base/special/round' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var rcbrt = require( './../lib' ); var x; var i; - for ( i = 0; i < 100; i++ ) { - x = round( randu() * 100.0 ); + x = discreteUniform( 0.0, 100.0 ); console.log( 'rcbrt(%d) = %d', x, rcbrt( x ) ); } diff --git a/base/special/rcbrt/manifest.json b/base/special/rcbrt/manifest.json index 46df9a861..a7b4613be 100644 --- a/base/special/rcbrt/manifest.json +++ b/base/special/rcbrt/manifest.json @@ -28,14 +28,12 @@ { "task": "build", "src": [ - "./src/rcbrt.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/math/base/napi/unary", @@ -45,14 +43,12 @@ { "task": "benchmark", "src": [ - "./src/rcbrt.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/math/base/special/cbrt" @@ -61,14 +57,12 @@ { "task": "examples", "src": [ - "./src/rcbrt.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" - ], + "libraries": [], "libpath": [], "dependencies": [ "@stdlib/math/base/special/cbrt" diff --git a/base/special/rcbrt/src/addon.c b/base/special/rcbrt/src/addon.c index 7b4e129d3..83dfb6865 100644 --- a/base/special/rcbrt/src/addon.c +++ b/base/special/rcbrt/src/addon.c @@ -19,4 +19,5 @@ #include "stdlib/math/base/special/rcbrt.h" #include "stdlib/math/base/napi/unary.h" +// cppcheck-suppress shadowFunction STDLIB_MATH_BASE_NAPI_MODULE_D_D( stdlib_base_rcbrt ) diff --git a/base/special/rcbrt/src/rcbrt.c b/base/special/rcbrt/src/main.c similarity index 93% rename from base/special/rcbrt/src/rcbrt.c rename to base/special/rcbrt/src/main.c index 4af501b7e..7d4849b2b 100644 --- a/base/special/rcbrt/src/rcbrt.c +++ b/base/special/rcbrt/src/main.c @@ -22,8 +22,8 @@ /** * Computes the reciprocal cube root of a double-precision floating-point number. * -* @param x number -* @return reciprocal cube root +* @param x number +* @return reciprocal cube root * * @example * double y = stdlib_base_rcbrt( 8.0 ); diff --git a/base/special/rcbrt/test/test.js b/base/special/rcbrt/test/test.js index 515c37900..2a3f7c770 100644 --- a/base/special/rcbrt/test/test.js +++ b/base/special/rcbrt/test/test.js @@ -66,13 +66,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = veryLargePositive.expected; x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -89,13 +89,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = largePositive.expected; x = largePositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -112,13 +112,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = mediumPositive.expected; x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -135,13 +135,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smallPositive.expected; x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -158,13 +158,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smaller.expected; x = smaller.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -181,13 +181,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = tinyPositive.expected; x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -204,13 +204,13 @@ tape( 'the function evaluates the reciprocal cube root of subnormal `x`', functi expected = subnormal.expected; x = subnormal.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -227,13 +227,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` (huge positive)', expected = hugePositive.expected; x = hugePositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -251,13 +251,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` (huge negative)', x = hugeNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -274,13 +274,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = veryLargeNegative.expected; x = veryLargeNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -297,13 +297,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = largeNegative.expected; x = largeNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -320,13 +320,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = mediumNegative.expected; x = mediumNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -343,13 +343,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smallNegative.expected; x = smallNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -366,13 +366,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smaller.expected; x = smaller.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -389,13 +389,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = tinyNegative.expected; x = tinyNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); diff --git a/base/special/rcbrt/test/test.native.js b/base/special/rcbrt/test/test.native.js index e8bda4b3e..a406b9f32 100644 --- a/base/special/rcbrt/test/test.native.js +++ b/base/special/rcbrt/test/test.native.js @@ -75,13 +75,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = veryLargePositive.expected; x = veryLargePositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -98,13 +98,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = largePositive.expected; x = largePositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -121,13 +121,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = mediumPositive.expected; x = mediumPositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -144,13 +144,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smallPositive.expected; x = smallPositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -167,13 +167,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smaller.expected; x = smaller.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -190,13 +190,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = tinyPositive.expected; x = tinyPositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -213,13 +213,13 @@ tape( 'the function evaluates the reciprocal cube root of subnormal `x`', opts, expected = subnormal.expected; x = subnormal.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -236,13 +236,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` (huge positive)', expected = hugePositive.expected; x = hugePositive.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { - delta = abs( y - expected[i] ); - tol = EPS * abs( expected[i] ); - t.equal( delta <= tol, true, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); + delta = abs( y - expected[ i ] ); + tol = EPS * abs( expected[ i ] ); + t.equal( delta <= tol, true, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. Tolerance: '+tol+'.' ); } } t.end(); @@ -260,13 +260,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` (huge negative)', x = hugeNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -283,13 +283,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = veryLargeNegative.expected; x = veryLargeNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -306,13 +306,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = largeNegative.expected; x = largeNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -329,13 +329,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = mediumNegative.expected; x = mediumNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -352,13 +352,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = smallNegative.expected; x = smallNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end(); @@ -375,13 +375,13 @@ tape( 'the function evaluates the reciprocal cube root of `x` on the interval `[ expected = tinyNegative.expected; x = tinyNegative.x; for ( i = 0; i < x.length; i++ ) { - y = rcbrt( x[i] ); - if ( y === expected[i] ) { - t.equal( y, expected[i], 'x: '+x[i]+', y: '+y+', expected: '+expected[i] ); + y = rcbrt( x[ i ] ); + if ( y === expected[ i ] ) { + t.equal( y, expected[ i ], 'x: '+x[ i ]+', y: '+y+', expected: '+expected[ i ] ); } else { delta = abs( y - expected[ i ] ); tol = EPS * abs( expected[ i ] ); - t.ok( delta <= tol, 'within tolerance. x: '+x[i]+'. y: '+y+'. E: '+expected[i]+'. Δ: '+delta+'. tol: '+tol ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+expected[ i ]+'. Δ: '+delta+'. tol: '+tol ); } } t.end();