From 7824100bfca4d9f5f5fe332cd89d0e08382c1b54 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 12:41:02 -0700 Subject: [PATCH 01/15] feat: initial commit for feedback --- .../stdlib/math/base/special/heaviside.h | 53 ++++++++++++++++ .../math/base/special/heaviside/lib/native.js | 63 +++++++++++++++++++ .../math/base/special/heaviside/src/addon.c | 42 +++++++++++++ .../math/base/special/heaviside/src/main.c | 56 +++++++++++++++++ 4 files changed, 214 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h b/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h new file mode 100644 index 000000000000..4e25d2addbb7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h @@ -0,0 +1,53 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#ifndef STDLIB_MATH_BASE_SPECIAL_HEAVISIDE_H +#define STDLIB_MATH_BASE_SPECIAL_HEAVISIDE_H + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +// Enumeration of function continuity: +typedef enum STDLIB_MATH_CONTINUITY { + // Half-maximum: + STDLIB_MATH_HALF_MAXIMUM = 0, + + // Left-continuous: + STDLIB_MATH_LEFT_CONTINUOUS = 1, + + // Right-continuous: + STDLIB_MATH_RIGHT_CONTINUOUS = 2, + + // Discontinuous: + STDLIB_MATH_DISCONTINUOUS = 3 +} STDLIB_MATH_CONTINUITY; + +/** +* Evaluates the Heaviside function. +*/ +double stdlib_base_heaviside( const double x, const STDLIB_MATH_CONTINUITY continuity ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_HEAVISIDE_H diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js new file mode 100644 index 000000000000..a9e76d0372e9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Evaluates the Heaviside function. +* +* @private +* @param {number} x - input value +* @param {string} [continuity] - continuity option +* @returns {number} function value +* +* @example +* var v = heaviside( 0.0, 0 ); +* // returns 0.5 +* +* @example +* var v = heaviside( 0.0, 1 ); +* // returns 0.0 +* +* @example +* var v = heaviside( 0.0, 2 ); +* // returns 1.0 +* +* @example +* var v = heaviside( 0.0, 3 ); +* // returns NaN +* +* @example +* var v = heaviside( NaN, 2 ); +* // returns NaN +*/ +function heaviside( x, continuity ) { + return addon( x, continuity ); +} + + +// EXPORTS // + +module.exports = heaviside; diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c b/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c new file mode 100644 index 000000000000..f5d7ae37a3dd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/heaviside.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int32.h" +#include "stdlib/napi/argv_double.h" +#include "stdlib/napi/create_double.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 2 ); + STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_INT32( env, continuity, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_heaviside( x, (STDLIB_MATH_CONTINUITY)continuity ), out ); + return out; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c b/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c new file mode 100644 index 000000000000..41e0ad742174 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/heaviside.h" +#include "stdlib/math/base/assert/is_nan.h" + +/** +* Evaluates the Heaviside function. +* +* @param x input value +* @param continuity continuity option +* @return function value +* +* @example +* double y = stdlib_base_heaviside( 0.0, STDLIB_MATH_HALF_MAXIMUM ); +* // returns 0.5 +*/ +double stdlib_base_heaviside( const double x, const STDLIB_MATH_CONTINUITY continuity ) { + if ( stdlib_base_is_nan( x ) ) { + return 0.0 / 0.0; // NaN + } + if ( x > 0.0 ) { + return 1.0; + } + // Handle `+-0`... + if ( x == 0.0 ) { + switch ( continuity ) { + case STDLIB_MATH_HALF_MAXIMUM: + return 0.5; + case STDLIB_MATH_LEFT_CONTINUOUS: + return 0.0; + case STDLIB_MATH_RIGHT_CONTINUOUS: + return 1.0; + case STDLIB_MATH_DISCONTINUOUS: + return 0.0 / 0.0; // NaN + default: + return 0.0 / 0.0; // NaN + } + } + return 0.0; +} From adfae95de9dea106910e088b868c3b4f1eb5857c Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 13:16:55 -0700 Subject: [PATCH 02/15] feat: add support for enums --- .../math/base/special/heaviside/lib/enum.js | 49 +++++++++++++++ .../base/special/heaviside/lib/enum2str.js | 59 +++++++++++++++++++ .../math/base/special/heaviside/lib/native.js | 3 +- 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js new file mode 100644 index 000000000000..e24e3028a787 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MAIN // + +/** +* Returns an object mapping supported function continuity type strings to enumeration constants. +* +* @private +* @returns {Object} object mapping supported function continuity types to enumeration constants +* +* @example +* var table = enumeration(); +* // returns +*/ +function enumeration() { + return { + // Half-maximum: + 'half-maximum': 0, + // Left-continuous: + 'left-continuous': 1, + // Right-continuous: + 'right-continuous': 2, + // Discontinuous: + 'discontinuous': 3 + }; +} + + +// EXPORTS // + +module.exports = enumeration; diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js new file mode 100644 index 000000000000..6415f107a73a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js @@ -0,0 +1,59 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var objectInverse = require( '@stdlib/utils/object-inverse' ); +var enumeration = require( './enum.js' ); + + +// VARIABLES // + +var hash = objectInverse( enumeration(), { + 'duplicates': false +}); + + +// MAIN // + +/** +* Returns the data type string associated with a strided array data type enumeration constant. +* +* @param {integer} dtype - data type enumeration constant +* @returns {(string|null)} data type string or null +* +* @example +* var str2enum = require( '@stdlib/strided/base/dtype-str2enum' ); +* +* var v = str2enum( 'float64' ); +* // returns +* +* var dt = enum2str( v ); +* // returns 'float64' +*/ +function enum2str( dtype ) { + var v = hash[ dtype ]; + return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain +} + + +// EXPORTS // + +module.exports = enum2str; diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js index a9e76d0372e9..d92bd7c2b44a 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js @@ -21,6 +21,7 @@ // MODULES // var addon = require( './../src/addon.node' ); +var str2enum = require( './str2enum.js' ); // MAIN // @@ -54,7 +55,7 @@ var addon = require( './../src/addon.node' ); * // returns NaN */ function heaviside( x, continuity ) { - return addon( x, continuity ); + return addon( x, str2enum( continuity ) ); } From d01e42cf9b592458be044c27a9b3304c5fabc584 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 13:18:58 -0700 Subject: [PATCH 03/15] docs: fix paramater name --- .../base/special/heaviside/lib/str2enum.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js new file mode 100644 index 000000000000..b28cd4423833 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js @@ -0,0 +1,52 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var enumeration = require( './enum.js' ); + + +// VARIABLES // + +var ENUM = enumeration(); + + +// MAIN // + +/** +* Returns the enumeration constant associated with a function continuity type string. +* +* @private +* @param {string} ctype - function continuity type string +* @returns {(integer|null)} integer value or null +* +* @example +* var v = str2enum( 'left-continuous' ); +* // returns +*/ +function str2enum( ctype ) { + var v = ENUM[ ctype ]; + return ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain +} + + +// EXPORTS // + +module.exports = str2enum; From c931698d8449fc7d7c8b789fd9e07327d1bad94c Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 13:20:43 -0700 Subject: [PATCH 04/15] feat: remove enum2str --- .../base/special/heaviside/lib/enum2str.js | 59 ------------------- 1 file changed, 59 deletions(-) delete mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js deleted file mode 100644 index 6415f107a73a..000000000000 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/enum2str.js +++ /dev/null @@ -1,59 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2021 The Stdlib Authors. -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ - -'use strict'; - -// MODULES // - -var objectInverse = require( '@stdlib/utils/object-inverse' ); -var enumeration = require( './enum.js' ); - - -// VARIABLES // - -var hash = objectInverse( enumeration(), { - 'duplicates': false -}); - - -// MAIN // - -/** -* Returns the data type string associated with a strided array data type enumeration constant. -* -* @param {integer} dtype - data type enumeration constant -* @returns {(string|null)} data type string or null -* -* @example -* var str2enum = require( '@stdlib/strided/base/dtype-str2enum' ); -* -* var v = str2enum( 'float64' ); -* // returns -* -* var dt = enum2str( v ); -* // returns 'float64' -*/ -function enum2str( dtype ) { - var v = hash[ dtype ]; - return ( typeof v === 'string' ) ? v : null; // note: we include this guard to prevent walking the prototype chain -} - - -// EXPORTS // - -module.exports = enum2str; From 5e764f77ee413a8e2c87fdfc274a87f3ffb23052 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 13:23:21 -0700 Subject: [PATCH 05/15] docs: fix comments --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/heaviside/lib/native.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js index d92bd7c2b44a..fe36608c0ecb 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/native.js @@ -35,23 +35,23 @@ var str2enum = require( './str2enum.js' ); * @returns {number} function value * * @example -* var v = heaviside( 0.0, 0 ); +* var v = heaviside( 0.0, 'half-maximum' ); * // returns 0.5 * * @example -* var v = heaviside( 0.0, 1 ); +* var v = heaviside( 0.0, 'left-continuous' ); * // returns 0.0 * * @example -* var v = heaviside( 0.0, 2 ); +* var v = heaviside( 0.0, 'right-continuous' ); * // returns 1.0 * * @example -* var v = heaviside( 0.0, 3 ); +* var v = heaviside( 0.0, 'discontinuous' ); * // returns NaN * * @example -* var v = heaviside( NaN, 2 ); +* var v = heaviside( NaN, 'right-continuous' ); * // returns NaN */ function heaviside( x, continuity ) { From 9500391bba911f3cccd29c31f8fcf812c548eff0 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 13:26:14 -0700 Subject: [PATCH 06/15] test: add tests --- .../special/heaviside/test/test.native.js | 140 ++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js new file mode 100644 index 000000000000..7ddbaf474911 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js @@ -0,0 +1,140 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2024 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var EPS = require( '@stdlib/constants/float64/eps' ); +var randu = require( '@stdlib/random/base/randu' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var heaviside = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( heaviside instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof heaviside, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `0` if `x` is negative', opts, function test( t ) { + var x; + var v; + var i; + + for ( i = 0; i < 1e3; i++ ) { + x = -( randu()*100.0 ) - EPS; + v = heaviside( x, 'left-continuous' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value when provided '+x ); + } + t.end(); +}); + +tape( 'the function returns `1` if `x` is positive', opts, function test( t ) { + var x; + var v; + var i; + + for ( i = 0; i < 1e3; i++ ) { + x = ( randu()*100.0 ) + EPS; + v = heaviside( x, 'left-continuous' ); + t.strictEqual( v, 1.0, 'returns expected value when provided '+x ); + } + t.end(); +}); + +tape( 'if the `continuity` option is `discontinuous`, the function returns `NaN` if provided `+-0`', opts, function test( t ) { + var v; + + v = heaviside( -0.0, 'discontinuous' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = heaviside( +0.0, 'discontinuous' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if the `continuity` option is `half-maximum`, the function returns `0.5` if provided `+-0`', opts, function test( t ) { + var v; + + v = heaviside( -0.0, 'half-maximum' ); + t.strictEqual( v, 0.5, 'returns expected value' ); + + v = heaviside( +0.0, 'half-maximum' ); + t.strictEqual( v, 0.5, 'returns expected value' ); + + t.end(); +}); + +tape( 'if the `continuity` option is `left-continuous`, the function returns `0.0` if provided `+-0`', opts, function test( t ) { + var v; + + v = heaviside( -0.0, 'left-continuous' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = heaviside( +0.0, 'left-continuous' ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'if the `continuity` option is `right-continuous`, the function returns `1` if provided `+-0`', opts, function test( t ) { + var v; + + v = heaviside( -0.0, 'right-continuous' ); + t.strictEqual( v, 1, 'returns expected value' ); + + v = heaviside( +0.0, 'right-continuous' ); + t.strictEqual( v, 1, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var v = heaviside( NaN, 'left-continuous' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `0` if provided `-infinity`', opts, function test( t ) { + var v = heaviside( NINF, 'left-continuous' ); + t.strictEqual( v, 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `+1` if provided `+infinity`', opts, function test( t ) { + var v = heaviside( PINF, 'left-continuous' ); + t.strictEqual( v, 1.0, 'returns expected value' ); + t.end(); +}); From 337a10abd0e177ef2a4f0770dca3641b4cb7d4f7 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Sat, 10 May 2025 13:55:23 -0700 Subject: [PATCH 07/15] feat: add C implementation for `math/base/special/heaviside` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: passed - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/heaviside/README.md | 96 ++++++++++ .../heaviside/benchmark/benchmark.native.js | 61 +++++++ .../heaviside/benchmark/c/native/Makefile | 146 +++++++++++++++ .../heaviside/benchmark/c/native/benchmark.c | 136 ++++++++++++++ .../math/base/special/heaviside/binding.gyp | 170 ++++++++++++++++++ .../special/heaviside/examples/c/Makefile | 146 +++++++++++++++ .../special/heaviside/examples/c/example.c | 31 ++++ .../math/base/special/heaviside/include.gypi | 53 ++++++ .../math/base/special/heaviside/manifest.json | 76 ++++++++ .../math/base/special/heaviside/package.json | 3 + .../math/base/special/heaviside/src/Makefile | 70 ++++++++ 11 files changed, 988 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/heaviside/src/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md index 394facdae803..ffae8a5fa58b 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md @@ -164,6 +164,102 @@ logEachMap( 'H(%0.4f) = %0.4f', x, heaviside ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/heaviside.h" +``` + +#### stdlib_base_heaviside( x, continuity ) + +Evaluates the [Heaviside function][heaviside-function]. + +```c +double y = stdlib_base_heaviside( 0.0, STDLIB_MATH_HALF_MAXIMUM ); +// returns 0.5 + +y = stdlib_base_heaviside( 0.0, STDLIB_MATH_LEFT_CONTINUOUS ); +// returns 0.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **continuity**: `[in] STDLIB_MATH_CONTINUITY` continuity option + +The `continuity` parameter may be one of the following values: + +- `STDLIB_MATH_HALF_MAXIMUM`: if `x == 0`, the function returns `0.5`. +- `STDLIB_MATH_LEFT_CONTINUOUS`: if `x == 0`, the function returns `0.0`. +- `STDLIB_MATH_RIGHT_CONTINUOUS`: if `x == 0`, the function returns `1.0`. +- `STDLIB_MATH_DISCONTINUOUS`: if `x == 0`, the function returns `NaN`. + +```c +double stdlib_base_heaviside( const double x, const STDLIB_MATH_CONTINUITY continuity ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/heaviside.h" +#include + +int main( void ) { + const double x[] = { -4.0, -3.0, -2.0, -1.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0 }; + + double y; + int i; + for ( i = 0; i < 10; i++ ) { + y = stdlib_base_heaviside( x[ i ], STDLIB_MATH_HALF_MAXIMUM ); + printf( "H(%lf) = %lf\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + @@ -246,7 +246,7 @@ int main( void ) { double y; int i; for ( i = 0; i < 10; i++ ) { - y = stdlib_base_heaviside( x[ i ], STDLIB_MATH_HALF_MAXIMUM ); + y = stdlib_base_heaviside( x[ i ], STDLIB_BASE_HEAVISIDE_CONTINUITY_HALF_MAXIMUM ); printf( "H(%lf) = %lf\n", x[ i ], y ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/native/benchmark.c index f9d8f08af3e7..7f094cd89e92 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/benchmark/c/native/benchmark.c @@ -102,7 +102,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - y = stdlib_base_heaviside( x[ i%100 ], STDLIB_MATH_HALF_MAXIMUM ); + y = stdlib_base_heaviside( x[ i%100 ], STDLIB_BASE_HEAVISIDE_CONTINUITY_HALF_MAXIMUM ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/heaviside/examples/c/example.c index 457b1459c0e6..e6615320df21 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/examples/c/example.c @@ -25,7 +25,7 @@ int main( void ) { double y; int i; for ( i = 0; i < 10; i++ ) { - y = stdlib_base_heaviside( x[ i ], STDLIB_MATH_HALF_MAXIMUM ); + y = stdlib_base_heaviside( x[ i ], STDLIB_BASE_HEAVISIDE_CONTINUITY_HALF_MAXIMUM ); printf( "H(%lf) = %lf\n", x[ i ], y ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h b/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h index 4e25d2addbb7..c63b265f4bfc 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/include/stdlib/math/base/special/heaviside.h @@ -27,24 +27,24 @@ extern "C" { #endif // Enumeration of function continuity: -typedef enum STDLIB_MATH_CONTINUITY { +typedef enum STDLIB_BASE_HEAVISIDE_CONTINUITY { // Half-maximum: - STDLIB_MATH_HALF_MAXIMUM = 0, + STDLIB_BASE_HEAVISIDE_CONTINUITY_HALF_MAXIMUM = 0, // Left-continuous: - STDLIB_MATH_LEFT_CONTINUOUS = 1, + STDLIB_BASE_HEAVISIDE_CONTINUITY_LEFT_CONTINUOUS = 1, // Right-continuous: - STDLIB_MATH_RIGHT_CONTINUOUS = 2, + STDLIB_BASE_HEAVISIDE_CONTINUITY_RIGHT_CONTINUOUS = 2, // Discontinuous: - STDLIB_MATH_DISCONTINUOUS = 3 -} STDLIB_MATH_CONTINUITY; + STDLIB_BASE_HEAVISIDE_CONTINUITY_DISCONTINUOUS = 3 +} STDLIB_BASE_HEAVISIDE_CONTINUITY; /** * Evaluates the Heaviside function. */ -double stdlib_base_heaviside( const double x, const STDLIB_MATH_CONTINUITY continuity ); +double stdlib_base_heaviside( const double x, const STDLIB_BASE_HEAVISIDE_CONTINUITY continuity ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c b/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c index f5d7ae37a3dd..edbe50898238 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/src/addon.c @@ -35,7 +35,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) { STDLIB_NAPI_ARGV( env, info, argv, argc, 2 ); STDLIB_NAPI_ARGV_DOUBLE( env, x, argv, 0 ); STDLIB_NAPI_ARGV_INT32( env, continuity, argv, 1 ); - STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_heaviside( x, (STDLIB_MATH_CONTINUITY)continuity ), out ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_base_heaviside( x, continuity ), out ); return out; } diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c b/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c index 41e0ad742174..5c7cfc0af176 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/src/main.c @@ -27,10 +27,10 @@ * @return function value * * @example -* double y = stdlib_base_heaviside( 0.0, STDLIB_MATH_HALF_MAXIMUM ); +* double y = stdlib_base_heaviside( 0.0, STDLIB_BASE_HEAVISIDE_CONTINUITY_HALF_MAXIMUM ); * // returns 0.5 */ -double stdlib_base_heaviside( const double x, const STDLIB_MATH_CONTINUITY continuity ) { +double stdlib_base_heaviside( const double x, const STDLIB_BASE_HEAVISIDE_CONTINUITY continuity ) { if ( stdlib_base_is_nan( x ) ) { return 0.0 / 0.0; // NaN } @@ -40,13 +40,13 @@ double stdlib_base_heaviside( const double x, const STDLIB_MATH_CONTINUITY conti // Handle `+-0`... if ( x == 0.0 ) { switch ( continuity ) { - case STDLIB_MATH_HALF_MAXIMUM: + case STDLIB_BASE_HEAVISIDE_CONTINUITY_HALF_MAXIMUM: return 0.5; - case STDLIB_MATH_LEFT_CONTINUOUS: + case STDLIB_BASE_HEAVISIDE_CONTINUITY_LEFT_CONTINUOUS: return 0.0; - case STDLIB_MATH_RIGHT_CONTINUOUS: + case STDLIB_BASE_HEAVISIDE_CONTINUITY_RIGHT_CONTINUOUS: return 1.0; - case STDLIB_MATH_DISCONTINUOUS: + case STDLIB_BASE_HEAVISIDE_CONTINUITY_DISCONTINUOUS: return 0.0 / 0.0; // NaN default: return 0.0 / 0.0; // NaN From c8a3c52c4aa366208f6e385d364fa023e4a88976 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Thu, 15 May 2025 22:47:58 -0700 Subject: [PATCH 11/15] refactor: change fallback return value from null to -1 in str2enum --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/heaviside/README.md | 2 ++ .../math/base/special/heaviside/lib/str2enum.js | 2 +- .../math/base/special/heaviside/test/test.native.js | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md index 5d9a7859a964..d91f4dcc7f56 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md @@ -214,6 +214,8 @@ The `continuity` parameter may be one of the following values: - `STDLIB_BASE_HEAVISIDE_CONTINUITY_RIGHT_CONTINUOUS`: if `x == 0`, the function returns `1.0`. - `STDLIB_BASE_HEAVISIDE_CONTINUITY_DISCONTINUOUS`: if `x == 0`, the function returns `NaN`. +If not provided a valid `continuity` parameter, the function returns `NaN` for `x == 0`, behaving like the discontinuous case. + ```c double stdlib_base_heaviside( const double x, const STDLIB_BASE_HEAVISIDE_CONTINUITY continuity ); ``` diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js index b28cd4423833..c431f4401c92 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/lib/str2enum.js @@ -43,7 +43,7 @@ var ENUM = enumeration(); */ function str2enum( ctype ) { var v = ENUM[ ctype ]; - return ( typeof v === 'number' ) ? v : null; // note: we include this guard to prevent walking the prototype chain + return ( typeof v === 'number' ) ? v : -1; // note: we include this guard to prevent walking the prototype chain } diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js index efd7db949aa1..0ef72ec006ee 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js @@ -121,6 +121,18 @@ tape( 'if the `continuity` option is `right-continuous`, the function returns `1 t.end(); }); +tape( 'if the `continuity` option is not valid, the function returns `NaN` if provided `+-0`', opts, function test( t ) { + var v; + + v = heaviside( -0.0, 'foo' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = heaviside( +0.0, 'bar' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v = heaviside( NaN, 'left-continuous' ); t.strictEqual( isnan( v ), true, 'returns expected value' ); From 18f54b6cc06db75078b26902c0cd16b171a4e212 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Fri, 16 May 2025 08:06:47 -0700 Subject: [PATCH 12/15] Update lib/node_modules/@stdlib/math/base/special/heaviside/README.md Co-authored-by: Athan Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/heaviside/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md index d91f4dcc7f56..483543f3f143 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md @@ -205,7 +205,7 @@ y = stdlib_base_heaviside( 0.0, STDLIB_BASE_HEAVISIDE_CONTINUITY_LEFT_CONTINUOUS The function accepts the following arguments: - **x**: `[in] double` input value. -- **continuity**: `[in] STDLIB_BASE_HEAVISIDE_CONTINUITY` continuity option +- **continuity**: `[in] STDLIB_BASE_HEAVISIDE_CONTINUITY` continuity option. The `continuity` parameter may be one of the following values: From 8b773c4359c201af24a87cec74a68ad3df41fb91 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Fri, 16 May 2025 08:07:34 -0700 Subject: [PATCH 13/15] docs: update the README Co-authored-by: Athan Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- lib/node_modules/@stdlib/math/base/special/heaviside/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md index 483543f3f143..756190f5589a 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/README.md +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/README.md @@ -214,7 +214,7 @@ The `continuity` parameter may be one of the following values: - `STDLIB_BASE_HEAVISIDE_CONTINUITY_RIGHT_CONTINUOUS`: if `x == 0`, the function returns `1.0`. - `STDLIB_BASE_HEAVISIDE_CONTINUITY_DISCONTINUOUS`: if `x == 0`, the function returns `NaN`. -If not provided a valid `continuity` parameter, the function returns `NaN` for `x == 0`, behaving like the discontinuous case. +If provided a `continuity` argument which is not one of the enumeration constants listed above, the function returns `NaN` for `x == 0`, behaving like the discontinuous case. ```c double stdlib_base_heaviside( const double x, const STDLIB_BASE_HEAVISIDE_CONTINUITY continuity ); From f771e63dd8e41f5652b8487f6748954b7bfa71e0 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 16 May 2025 23:24:39 -0700 Subject: [PATCH 14/15] test: add test for the default case --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/heaviside/test/test.native.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js index 0ef72ec006ee..2c947529ddae 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js @@ -73,6 +73,18 @@ tape( 'the function returns `1` if `x` is positive', opts, function test( t ) { t.end(); }); +tape( 'by default, the function returns `NaN` if provided `+-0`', opts, function test( t ) { + var v; + + v = heaviside( -0.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = heaviside( +0.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); + tape( 'if the `continuity` option is `discontinuous`, the function returns `NaN` if provided `+-0`', opts, function test( t ) { var v; From 5b47b9f1447c89b339c32fbf94823756d3e41628 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Fri, 16 May 2025 23:28:50 -0700 Subject: [PATCH 15/15] test: update tests to match JS tests --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/heaviside/test/test.js | 4 ++-- .../math/base/special/heaviside/test/test.native.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js index df57269326d0..64716cc7dea8 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.js @@ -46,7 +46,7 @@ tape( 'the function returns `0` if `x` is negative', function test( t ) { for ( i = 0; i < 1e3; i++ ) { x = -( randu()*100.0 ) - EPS; v = heaviside( x ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value when provided '+x ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); } t.end(); }); @@ -59,7 +59,7 @@ tape( 'the function returns `1` if `x` is positive', function test( t ) { for ( i = 0; i < 1e3; i++ ) { x = ( randu()*100.0 ) + EPS; v = heaviside( x ); - t.strictEqual( v, 1.0, 'returns expected value when provided '+x ); + t.strictEqual( v, 1.0, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js index 2c947529ddae..41a80dad6d64 100644 --- a/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/heaviside/test/test.native.js @@ -54,8 +54,8 @@ tape( 'the function returns `0` if `x` is negative', opts, function test( t ) { for ( i = 0; i < 1e3; i++ ) { x = -( randu()*100.0 ) - EPS; - v = heaviside( x, 'left-continuous' ); - t.strictEqual( isPositiveZero( v ), true, 'returns expected value when provided '+x ); + v = heaviside( x ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); } t.end(); }); @@ -67,8 +67,8 @@ tape( 'the function returns `1` if `x` is positive', opts, function test( t ) { for ( i = 0; i < 1e3; i++ ) { x = ( randu()*100.0 ) + EPS; - v = heaviside( x, 'left-continuous' ); - t.strictEqual( v, 1.0, 'returns expected value when provided '+x ); + v = heaviside( x ); + t.strictEqual( v, 1.0, 'returns expected value' ); } t.end(); });