diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.js index c28c502fde04..760fe2476bc2 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. @@ -21,7 +21,7 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var randu = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pkg = require( './../package.json' ).name; var round = require( './../lib' ); @@ -34,10 +34,11 @@ bench( pkg, function benchmark( b ) { var y; var i; + x = randu( 100, -500.0, 500.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = round( x ); + y = round( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } @@ -55,10 +56,11 @@ bench( pkg+'::built-in', function benchmark( b ) { var y; var i; + x = randu( 100, -500.0, 500.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = Math.round( x ); // eslint-disable-line stdlib/no-builtin-math + y = Math.round( x[ i % x.length ] ); // eslint-disable-line stdlib/no-builtin-math if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.native.js index 1fe5301bf44d..591560fc83e7 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -22,7 +22,7 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var randu = require( '@stdlib/random/array/uniform' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -43,10 +43,11 @@ bench( pkg+'::native', opts, function benchmark( b ) { var y; var i; + x = randu( 100, -500.0, 500.0 ); + b.tic(); for ( i = 0; i < b.iterations; i++ ) { - x = ( randu()*1000.0 ) - 500.0; - y = round( x ); + y = round( x[ i % x.length ] ); if ( isnan( y ) ) { b.fail( 'should not return NaN' ); } diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/Makefile index e64c0050f3da..635d877081d5 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# 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. @@ -16,7 +16,6 @@ # limitations under the License. #/ - # VARIABLES # ifndef VERBOSE diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/benchmark.c index 9a4a20c84398..0205f1b66dd9 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. @@ -89,16 +89,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0 * rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; - y = round( x ); + y = round( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/Makefile b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/Makefile index 60e93ff57ffd..c103e646f7a5 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# 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. @@ -16,11 +16,12 @@ # limitations under the License. #/ - # VARIABLES # ifndef VERBOSE QUIET := @ +else + QUIET := endif # Specify the path to Cephes: @@ -29,7 +30,7 @@ CEPHES ?= # Specify a list of Cephes source files: CEPHES_SRC ?= -# Determine the OS: +# Determine the OS ([1][1], [2][2]). # # [1]: https://en.wikipedia.org/wiki/Uname#Examples # [2]: http://stackoverflow.com/a/27776822/2225624 @@ -42,6 +43,10 @@ ifneq (, $(findstring MSYS,$(OS))) else ifneq (, $(findstring CYGWIN,$(OS))) OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif endif endif endif @@ -60,7 +65,7 @@ CFLAGS ?= \ -Wall \ -pedantic -# Determine whether to generate [position independent code][1]: +# Determine whether to generate position independent code ([1][1], [2][2]). # # [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options # [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option @@ -74,39 +79,55 @@ endif c_targets := benchmark.out -# TARGETS # +# RULES # -# Default target. +#/ +# Compiles C source files. # -# This target is the default target. - +# @param {string} CEPHES_SRC - list of Cephes source files +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ all: $(c_targets) .PHONY: all - -# Compile C source. +#/ +# Compiles C source files. # -# This target compiles C source files. - +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +# @param {string} CEPHES_SRC - list of Cephes source files +#/ $(c_targets): %.out: %.c $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $(CEPHES_SRC) $< -lm - -# Run a benchmark. +#/ +# Runs compiled benchmarks. # -# This target runs a benchmark. - +# @example +# make run +#/ run: $(c_targets) $(QUIET) ./$< .PHONY: run - -# Perform clean-up. +#/ +# Removes generated files. # -# This target removes generated files. - +# @example +# make clean +#/ clean: $(QUIET) -rm -f *.o *.out diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/benchmark.c b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/benchmark.c index 64d5da4e159e..10086c3ae921 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/cephes/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. @@ -94,16 +94,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0 * rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; - y = round( x ); + y = round( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/Makefile index f69e9da2b4d3..5d7e79f50788 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2024 The Stdlib Authors. +# 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. @@ -88,15 +88,15 @@ c_targets := benchmark.out # RULES # #/ -# Compiles source files. +# Compiles C source files. # -# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) -# @param {string} [CFLAGS] - C compiler options -# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) -# @param {string} [SOURCE_FILES] - list of source files +# @param {string} SOURCE_FILES - list of C source files +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lpthread -lblas`) # @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) -# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code # # @example # make @@ -112,13 +112,13 @@ all: $(c_targets) # Compiles C source files. # # @private -# @param {string} CC - C compiler (e.g., `gcc`) -# @param {string} CFLAGS - C compiler options -# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) -# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) -# @param {string} SOURCE_FILES - list of source files -# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) -# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +# @param {string} SOURCE_FILES - list of C source files +# @param {(string|void)} INCLUDE - list of includes (e.g., `-I /foo/bar -I /beep/boop`) +# @param {(string|void)} LIBRARIES - list of libraries (e.g., `-lpthread -lblas`) +# @param {(string|void)} LIBPATH - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code #/ $(c_targets): %.out: %.c $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) diff --git a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/benchmark.c index 9b9772c4207a..1fd6c986247e 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/round/benchmark/c/native/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -90,16 +90,19 @@ static double rand_double( void ) { * @return elapsed time in seconds */ static double benchmark( void ) { + double x[ 100 ]; double elapsed; - double x; double y; double t; int i; + for ( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0 * rand_double() ) - 500.0; + } + t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_double() ) - 500.0; - y = round( x ); + y = round( x[ i % 100 ] ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/round/test/test.js b/lib/node_modules/@stdlib/math/base/special/round/test/test.js index f81309e0e4ff..a904f3a3852c 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/round/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* 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. @@ -37,39 +37,39 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function rounds a numeric value to the nearest integer', function test( t ) { - t.strictEqual( round( -4.2 ), -4.0, 'equals -4' ); - t.strictEqual( round( -4.5 ), -4.0, 'equals -4' ); - t.strictEqual( round( -4.8 ), -5.0, 'equals -5' ); - t.strictEqual( round( 4.2 ), 4.0, 'equals 4' ); - t.strictEqual( round( 4.5 ), 5.0, 'equals 5' ); - t.strictEqual( round( 9.99999 ), 10.0, 'equals 10' ); - t.strictEqual( round( 9.5 ), 10.0, 'equals 10' ); - t.strictEqual( round( 9.4 ), 9.0, 'equals 10' ); - t.strictEqual( round( 0.0 ), 0.0, 'equals 0' ); + t.strictEqual( round( -4.2 ), -4.0, 'returns expected value' ); + t.strictEqual( round( -4.5 ), -4.0, 'returns expected value' ); + t.strictEqual( round( -4.8 ), -5.0, 'returns expected value' ); + t.strictEqual( round( 4.2 ), 4.0, 'returns expected value' ); + t.strictEqual( round( 4.5 ), 5.0, 'returns expected value' ); + t.strictEqual( round( 9.99999 ), 10.0, 'returns expected value' ); + t.strictEqual( round( 9.5 ), 10.0, 'returns expected value' ); + t.strictEqual( round( 9.4 ), 9.0, 'returns expected value' ); + t.strictEqual( round( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', function test( t ) { var v = round( -0.0 ); - t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) { var v = round( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided a `+infinity`', function test( t ) { var v = round( PINF ); - t.strictEqual( v, PINF, 'returns +infinity' ); + t.strictEqual( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `-infinity` if provided a `-infinity`', function test( t ) { var v = round( NINF ); - t.strictEqual( v, NINF, 'returns -infinity' ); + t.strictEqual( v, NINF, 'returns expected value' ); t.end(); }); @@ -79,7 +79,7 @@ tape( 'the function returns the correct result for large positive non-decimal va var i; for ( i = start; i < end; i++ ) { - t.strictEqual( round( i ), i, 'returns '+i ); + t.strictEqual( round( i ), i, 'returns expected value' ); } t.end(); }); @@ -90,7 +90,7 @@ tape( 'the function returns the correct result for large negative non-decimal va var i; for ( i = start; i < end; i++ ) { - t.strictEqual( round( i ), i, 'returns '+i ); + t.strictEqual( round( i ), i, 'returns expected value' ); } t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/round/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/round/test/test.native.js index 2384ecd8267f..48eac248d7f1 100644 --- a/lib/node_modules/@stdlib/math/base/special/round/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/round/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* 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. @@ -46,39 +46,39 @@ tape( 'main export is a function', opts, function test( t ) { }); tape( 'the function rounds a numeric value to the nearest integer', opts, function test( t ) { - t.strictEqual( round( -4.2 ), -4.0, 'equals -4' ); - t.strictEqual( round( -4.5 ), -4.0, 'equals -4' ); - t.strictEqual( round( -4.8 ), -5.0, 'equals -5' ); - t.strictEqual( round( 4.2 ), 4.0, 'equals 4' ); - t.strictEqual( round( 4.5 ), 5.0, 'equals 5' ); - t.strictEqual( round( 9.99999 ), 10.0, 'equals 10' ); - t.strictEqual( round( 9.5 ), 10.0, 'equals 10' ); - t.strictEqual( round( 9.4 ), 9.0, 'equals 10' ); - t.strictEqual( round( 0.0 ), 0.0, 'equals 0' ); + t.strictEqual( round( -4.2 ), -4.0, 'returns expected value' ); + t.strictEqual( round( -4.5 ), -4.0, 'returns expected value' ); + t.strictEqual( round( -4.8 ), -5.0, 'returns expected value' ); + t.strictEqual( round( 4.2 ), 4.0, 'returns expected value' ); + t.strictEqual( round( 4.5 ), 5.0, 'returns expected value' ); + t.strictEqual( round( 9.99999 ), 10.0, 'returns expected value' ); + t.strictEqual( round( 9.5 ), 10.0, 'returns expected value' ); + t.strictEqual( round( 9.4 ), 9.0, 'returns expected value' ); + t.strictEqual( round( 0.0 ), 0.0, 'returns expected value' ); t.end(); }); tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { var v = round( -0.0 ); - t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + t.strictEqual( isNegativeZero( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `NaN` if provided a `NaN`', opts, function test( t ) { var v = round( NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); t.end(); }); tape( 'the function returns `+infinity` if provided a `+infinity`', opts, function test( t ) { var v = round( PINF ); - t.strictEqual( v, PINF, 'returns +infinity' ); + t.strictEqual( v, PINF, 'returns expected value' ); t.end(); }); tape( 'the function returns `-infinity` if provided a `-infinity`', opts, function test( t ) { var v = round( NINF ); - t.strictEqual( v, NINF, 'returns -infinity' ); + t.strictEqual( v, NINF, 'returns expected value' ); t.end(); }); @@ -88,7 +88,7 @@ tape( 'the function returns the correct result for large positive non-decimal va var i; for ( i = start; i < end; i++ ) { - t.strictEqual( round( i ), i, 'returns '+i ); + t.strictEqual( round( i ), i, 'returns expected value' ); } t.end(); }); @@ -99,7 +99,7 @@ tape( 'the function returns the correct result for large negative non-decimal va var i; for ( i = start; i < end; i++ ) { - t.strictEqual( round( i ), i, 'returns '+i ); + t.strictEqual( round( i ), i, 'returns expected value' ); } t.end(); });