From 5983a13496a9a1c9addb52283298bbfce9822b39 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Fri, 23 Jan 2026 20:41:08 +0000 Subject: [PATCH 01/13] feat: add math/base/special/roundsdf --- 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: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../math/base/special/roundsdf/README.md | 208 ++++++++++++++++++ .../special/roundsdf/benchmark/benchmark.js | 88 ++++++++ .../roundsdf/benchmark/benchmark.native.js | 97 ++++++++ .../roundsdf/benchmark/c/native/Makefile | 146 ++++++++++++ .../roundsdf/benchmark/c/native/benchmark.c | 100 +++++++++ .../math/base/special/roundsdf/binding.gyp | 170 ++++++++++++++ .../math/base/special/roundsdf/docs/repl.txt | 41 ++++ .../special/roundsdf/docs/types/index.d.ts | 51 +++++ .../base/special/roundsdf/docs/types/test.ts | 61 +++++ .../base/special/roundsdf/examples/c/Makefile | 146 ++++++++++++ .../special/roundsdf/examples/c/example.c | 39 ++++ .../base/special/roundsdf/examples/index.js | 33 +++ .../math/base/special/roundsdf/include.gypi | 53 +++++ .../stdlib/math/base/special/roundsdf.h | 43 ++++ .../math/base/special/roundsdf/lib/index.js | 56 +++++ .../math/base/special/roundsdf/lib/main.js | 79 +++++++ .../math/base/special/roundsdf/lib/native.js | 48 ++++ .../math/base/special/roundsdf/manifest.json | 97 ++++++++ .../math/base/special/roundsdf/package.json | 82 +++++++ .../math/base/special/roundsdf/src/Makefile | 70 ++++++ .../math/base/special/roundsdf/src/addon.c | 26 +++ .../math/base/special/roundsdf/src/main.c | 56 +++++ .../math/base/special/roundsdf/test/test.js | 90 ++++++++ .../base/special/roundsdf/test/test.native.js | 84 +++++++ 24 files changed, 1964 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md b/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md new file mode 100644 index 000000000000..26d09fed5654 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md @@ -0,0 +1,208 @@ + + +# roundsdf + +> Round a single-precision floating-point number to the nearest value with `n` significant figures. + +
+ +## Usage + +```javascript +var roundsdf = require( '@stdlib/math/base/special/roundsdf' ); +``` + +#### roundsdf( x, n ) + +Rounds a single-precision floating-point number to the nearest value with `n` significant figures. + +```javascript +var v = roundsdf( 3.141592653589793, 3 ); +// returns 3.14 + +v = roundsdf( 3.141592653589793, 1 ); +// returns 3.0 + +v = roundsdf( 12368.0, 2 ); +// returns 12000.0 + +v = roundsdf( -12368.0, 2 ); +// returns -12000.0 +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var roundsdf = require( '@stdlib/math/base/special/roundsdf' ); + +var opts = { + 'dtype': 'float32' +}; + +var x = uniform( 100, -5000.0, 5000.0, opts ); + +logEachMap( 'x: %0.4f. n: 3. rounded: %0.4f.', x, 3, roundsdf ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/roundsdf.h" +``` + +#### stdlib_base_roundsdf( x, n ) + +Rounds a single-precision floating-point number to the nearest value with `n` significant figures + +```c +float v = stdlib_base_roundsdf( 3.1415927f, 3 ); +// returns 3.14f +``` + +The function accepts the following arguments: + +- **x**: `[in] double` input value. +- **n**: `[in] int32_t` number of significant figures. + +```c +float stdlib_base_roundsdf( float x, int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/roundsdf.h" +#include +#include + +int main( void ) { + const float x[] = { 3.143546f, -3.142635f, 0.0f, NAN }; + + float y; + int i; + + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_roundsdf( x[ i ], 2 ); + printf( "roundsdf(%f) = %f\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js new file mode 100644 index 000000000000..290171e86075 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js @@ -0,0 +1,88 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var roundsdf = require( './../lib' ); + + +// MAIN // + +bench( format( '%s::n=1', pkg ), function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 10000.0 ) - 5000.0; + y = roundsdf( x, 1 ); + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::n=3', pkg ), function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 10000.0 ) - 5000.0; + y = roundsdf( x, 3 ); + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::n=5', pkg ), function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 10000.0 ) - 5000.0; + y = roundsdf( x, 5 ); + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..12058d460d11 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js @@ -0,0 +1,97 @@ +/** +* @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 bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var roundsdf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( roundsdf instanceof Error ) +}; + + +// MAIN // + +bench( format( '%s::native:n=1', pkg ), opts, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 10000.0 ) - 5000.0; + y = roundsdf( x, 1 ); + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::native:n=3', pkg ), opts, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 10000.0 ) - 5000.0; + y = roundsdf( x, 3 ); + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s::native:n=5', pkg ), opts, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() * 10000.0 ) - 5000.0; + y = roundsdf( x, 5 ); + } + b.toc(); + + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# 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 +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles 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} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# 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`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..d97f16df1b35 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c @@ -0,0 +1,100 @@ +/** +* @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. +*/ + +#include "stdlib/math/base/special/roundsdf.h" +#include "stdlib/math/base/assert/is_nan.h" +#include +#include +#include + +#define NAME "roundsdf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Returns a wall-clock time in seconds. +* +* @return time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec * 1.0e-6; +} + +/** +* Generates a pseudo-random float on the interval [-5000, 5000). +* +* @return random float +*/ +static float rand_float( void ) { + return ( (float)rand() / (float)RAND_MAX ) * 10000.0f - 5000.0f; +} + +/** +* Runs the benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + float x; + float y; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = rand_float(); + y = stdlib_base_roundsdf( x, 5, 10 ); + if ( stdlib_base_is_nan( y ) ) { + printf( "unexpected NaN\n" ); + break; + } + } + return tic() - t; +} + +/** +* Main execution sequence. +* +* @return exit status +*/ +int main( void ) { + double elapsed; + int i; + + printf( "TAP version 13\n" ); + + for ( i = 0; i < REPEATS; i++ ) { + elapsed = benchmark(); + printf( "# %s\n", NAME ); + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", (double)ITERATIONS / elapsed ); + printf( " ...\n" ); + printf( "ok %d benchmark finished\n", i+1 ); + } + + printf( "1..%d\n", REPEATS ); + printf( "# total %d\n", REPEATS ); + printf( "# pass %d\n", REPEATS ); + printf( "# ok\n" ); + + return 0; +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp @@ -0,0 +1,170 @@ +# @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. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/repl.txt new file mode 100644 index 000000000000..602d99362a34 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/repl.txt @@ -0,0 +1,41 @@ + +{{alias}}( x, n[, b] ) + Rounds a numeric value to the nearest number toward positive infinity with + `n` significant figures. + + Parameters + ---------- + x: number + Input value. + + n: integer + Number of significant figures. Must be greater than 0. + + b: integer (optional) + Base. Must be greater than 0. Default: 10. + + Returns + ------- + y: number + Rounded value. + + Examples + -------- + > var y = {{alias}}( 3.141592653589793, 3 ) + 3.14 + + > y = {{alias}}( 3.141592653589793, 1 ) + 3 + + > y = {{alias}}( 12368.0, 2 ) + 12000 + + > y = {{alias}}( -12368.0, 2 ) + -12000 + + > y = {{alias}}( 0.0313, 2, 2 ) + 0.031 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts new file mode 100644 index 000000000000..84a0553a816c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts @@ -0,0 +1,51 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/** +* Rounds a numeric value to the nearest number toward positive infinity with +* `n` significant figures. +* +* @param x - input value +* @param n - number of significant figures +* @param b - base (default: 10) +* @returns rounded value +* +* @example +* var v = roundsdf( 3.141592653589793, 3 ); +* // returns 3.14 +* +* @example +* var v = roundsdf( 3.141592653589793, 1 ); +* // returns 3 +* +* @example +* var v = roundsdf( 12368.0, 2 ); +* // returns 12000 +* +* @example +* var v = roundsdf( 0.0313, 2, 2 ); +* // returns 0.031 +*/ +declare function roundsdf( x: number, n: number, b?: number ): number; + + +// EXPORTS // + +export = roundsdf; diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts new file mode 100644 index 000000000000..3412d27b0c46 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts @@ -0,0 +1,61 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 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. +*/ + +import roundsdf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + roundsdf( 3.141592653589793, 4 ); // $ExpectType number + roundsdf( 3.141592653589793, 1 ); // $ExpectType number + roundsdf( 12368.0, 2 ); // $ExpectType number + roundsdf( 0.0313, 2, 2 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than numbers... +{ + roundsdf( true, 3 ); // $ExpectError + roundsdf( false, 2 ); // $ExpectError + roundsdf( '5', 1 ); // $ExpectError + roundsdf( [], 1 ); // $ExpectError + roundsdf( {}, 2 ); // $ExpectError + roundsdf( ( x: number ): number => x, 2 ); // $ExpectError + + roundsdf( 9, true ); // $ExpectError + roundsdf( 9, false ); // $ExpectError + roundsdf( 5, '5' ); // $ExpectError + roundsdf( 8, [] ); // $ExpectError + roundsdf( 9, {} ); // $ExpectError + roundsdf( 8, ( x: number ): number => x ); // $ExpectError + + roundsdf( 3.14, 2, true ); // $ExpectError + roundsdf( 3.14, 2, false ); // $ExpectError + roundsdf( 3.14, 2, '5' ); // $ExpectError + roundsdf( 3.14, 2, [] ); // $ExpectError + roundsdf( 3.14, 2, {} ); // $ExpectError + roundsdf( 3.14, 2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an invalid number of arguments... +{ + roundsdf(); // $ExpectError + roundsdf( 3 ); // $ExpectError + roundsdf( 2.131, 3, 10, 10 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# 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 +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles 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} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# 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`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c new file mode 100644 index 000000000000..828f4610fd21 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c @@ -0,0 +1,39 @@ +/** +* @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. +*/ + +#include "stdlib/math/base/special/roundsdf.h" +#include +#include + +int main( void ) { + const float x[] = { + 3.143546f, + -3.142635f, + 0.0f, + NAN + }; + + float y; + int i; + + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_roundsdf( x[ i ], 2, 10 ); + printf( "roundsdf(%f, 2, 10) = %f\n", x[ i ], y ); + } + return 0; +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js new file mode 100644 index 000000000000..629171bb08ee --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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'; + +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var roundsdf = require( './../lib' ); + +var opts = { + 'dtype': 'float32' +}; + +// Generate random values: +var x = uniform( 100, -5000.0, 5000.0, opts ); + +// Apply rounding: +logEachMap('x: %0.4f. n: 5. rounded: %0.4f.', x, 5, roundsdf); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi b/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi @@ -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. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + ' + +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Rounds a single-precision floating-point number to the nearest value toward +* positive infinity with `n` significant figures. +* +* @param x input value +* @param n number of significant figures +* @param b base +* @return rounded value +*/ +float stdlib_base_roundsdf( const float x, const int32_t n, const int32_t b ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_ROUNDSDF_H diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js new file mode 100644 index 000000000000..1d7dc1720119 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js @@ -0,0 +1,56 @@ +/** +* @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'; + +/** +* Round a numeric value to the nearest number toward positive infinity with n significant figures. +* +* @module @stdlib/math/base/special/roundsdf +* +* @example +* var roundsdf = require( '@stdlib/math/base/special/roundsdf' ); +* +* var v = roundsdf( 3.141592653589793, 3 ); +* // returns 3.14 +* +* v = roundsdf( 3.141592653589793, 1 ); +* // returns 3 +* +* v = roundsdf( 12368.0, 2 ); +* // returns 12000 +* +* v = roundsdf( 0.0313, 2, 2 ); +* // returns 0.031 +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var native = require( './native.js' ); + + +// MAIN // + +setReadOnly( main, 'native', native ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js new file mode 100644 index 000000000000..931a4330b7f9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js @@ -0,0 +1,79 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isInfinite = require( '@stdlib/math/base/assert/is-infinite' ); +var abs = require( '@stdlib/math/base/special/abs' ); +var floor = require( '@stdlib/math/base/special/floor' ); +var log10 = require( '@stdlib/math/base/special/log10' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var round = require( '@stdlib/math/base/special/round' ); + + +// MAIN // + +/** +* Rounds a numeric value to the nearest number with `n` significant figures. +* +* @param {number} x - input value +* @param {PositiveInteger} n - number of significant figures +* @returns {number} rounded value +* +* @example +* var v = roundsdf( 3.141592653589793, 3 ); +* // returns 3.14 +* +* @example +* var v = roundsdf( 3.141592653589793, 1 ); +* // returns 3.0 +* +* @example +* var v = roundsdf( 12368.0, 2 ); +* // returns 12000.0 +*/ +function roundsdf( x, n ) { + var e; + var s; + + if ( isnan( x ) || isnan( n ) || n < 1 || isInfinite( n ) ) { + return NaN; + } + if ( isInfinite( x ) || x === 0.0 ) { + return x; + } + + // Base-10 exponent: + e = floor( log10( abs( x ) ) - n + 1.0 ); + + // Scale factor: + s = pow( 10.0, abs( e ) ); + + if ( e < 0 ) { + return round( x * s ) / s; + } + return round( x / s ) * s; +} + + +// EXPORTS // + +module.exports = roundsdf; diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js new file mode 100644 index 000000000000..1fcf93de9aed --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js @@ -0,0 +1,48 @@ +/** +* @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 tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var addon = tryRequire( './../src/addon.node' ); + + +// MAIN // + +/** +* Rounds a numeric value to the nearest number with `n` significant figures. +* +* @private +* @param {number} x - input value +* @param {PositiveInteger} n - number of significant figures +* @returns {number} rounded value +*/ +function roundsdf( x, n ) { + return addon( x, n ); +} + + +// EXPORTS // + +module.exports = roundsdf; diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json new file mode 100644 index 000000000000..bfdb8ec1664c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json @@ -0,0 +1,97 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c", + "./src/addon.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/ternary", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/logf", + "@stdlib/math/base/special/powf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/logf", + "@stdlib/math/base/special/powf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/special/floorf", + "@stdlib/math/base/special/logf", + "@stdlib/math/base/special/powf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/package.json b/lib/node_modules/@stdlib/math/base/special/roundsdf/package.json new file mode 100644 index 000000000000..9931b6af04fc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/package.json @@ -0,0 +1,82 @@ +{ + "name": "@stdlib/math/base/special/roundsdf", + "version": "0.0.0", + "description": "Round a single-precision floating-point number to the nearest number toward positive infinity with N significant figures.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "gypfile": true, + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "include": "./include", + "lib": "./lib", + "src": "./src", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": { + "@stdlib/utils/define-nonenumerable-read-only-property": "^0.0.0", + "@stdlib/math/base/assert/is-nan": "^0.0.0", + "@stdlib/math/base/assert/is-infinite": "^0.0.0", + "@stdlib/math/base/special/pow": "^0.0.0", + "@stdlib/math/base/special/abs": "^0.0.0", + "@stdlib/math/base/special/floor": "^0.0.0", + "@stdlib/math/base/special/ceil": "^0.0.0", + "@stdlib/math/base/special/log": "^0.0.0" + }, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "math.round", + "round", + "significant", + "figures", + "sigfig", + "sigfigs", + "digits", + "measurement", + "science", + "nearest", + "number", + "float32", + "ceil" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c new file mode 100644 index 000000000000..a2277d9801eb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c @@ -0,0 +1,26 @@ +/** +* @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/roundsdf.h" +#include "stdlib/math/base/napi/ternary.h" + +/* +* Create a Node-API module for a ternary function accepting +* a float and two integers and returning a float. +*/ +STDLIB_MATH_BASE_NAPI_MODULE_FII_F( stdlib_base_roundsdf ) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c new file mode 100644 index 000000000000..785e06aa2af6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c @@ -0,0 +1,56 @@ +/** +* @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. +*/ + +#include "stdlib/math/base/special/roundsdf.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/assert/is_infinite.h" +#include +#include + +/** +* Rounds a single-precision floating-point number to the nearest value with `n` +* significant figures. +* +* @param x input value +* @param n number of significant figures +* @return rounded value +*/ +float stdlib_base_roundsdf( const float x, const int32_t n ) { + float ax; + float e; + float s; + + if ( stdlib_base_is_nan( x ) || n < 1 ) { + return 0.0f / 0.0f; // NaN + } + if ( stdlib_base_is_infinite( x ) || x == 0.0f ) { + return x; + } + + // Absolute value: + ax = stdlib_base_absf( x ); + + // Base-10 exponent: + e = stdlib_base_floorf( stdlib_base_log10f( ax ) ); + + // Scale factor: + s = stdlib_base_powf( 10.0f, (float)( n - 1 ) - e ); + + // Round to nearest: + return stdlib_base_roundf( x * s ) / s; +} diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js new file mode 100644 index 000000000000..bb27504e3d1a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js @@ -0,0 +1,90 @@ +/** +* @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 tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var roundsdf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof roundsdf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns NaN if provided NaN', function test( t ) { + t.ok( isnan( roundsdf( NaN, 2 ) ), 'NaN x' ); + t.ok( isnan( roundsdf( 3.14, NaN ) ), 'NaN n' ); + t.ok( isnan( roundsdf( NaN, NaN ) ), 'NaN x and n' ); + t.end(); +}); + +tape( 'the function returns NaN if provided n < 1', function test( t ) { + t.ok( isnan( roundsdf( 3.14, 0 ) ), 'n = 0' ); + t.ok( isnan( roundsdf( 3.14, -1 ) ), 'n < 0' ); + t.end(); +}); + +tape( 'the function returns infinity unchanged', function test( t ) { + t.strictEqual( roundsdf( PINF, 3 ), PINF, '+infinity' ); + t.strictEqual( roundsdf( NINF, 3 ), NINF, '-infinity' ); + t.end(); +}); + +tape( 'the function preserves signed zeros', function test( t ) { + t.ok( isPositiveZero( roundsdf( 0.0, 2 ) ), '+0 preserved' ); + t.ok( isNegativeZero( roundsdf( -0.0, 2 ) ), '-0 preserved' ); + t.end(); +}); + +tape( 'the function rounds to nearest with n significant figures', function test( t ) { + t.strictEqual( roundsdf( 3.141592653589793, 1 ), 3.0, 'n=1' ); + t.strictEqual( roundsdf( 3.141592653589793, 2 ), 3.1, 'n=2' ); + t.strictEqual( roundsdf( 3.141592653589793, 3 ), 3.14, 'n=3' ); + t.strictEqual( roundsdf( 3.141592653589793, 4 ), 3.142, 'n=4' ); + t.end(); +}); + +tape( 'the function rounds large values correctly', function test( t ) { + t.strictEqual( roundsdf( 12368.0, 1 ), 10000.0, 'n=1' ); + t.strictEqual( roundsdf( 12368.0, 2 ), 12000.0, 'n=2' ); + t.strictEqual( roundsdf( 12368.0, 3 ), 12400.0, 'n=3' ); + t.end(); +}); + +tape( 'the function rounds negative values correctly', function test( t ) { + t.strictEqual( roundsdf( -3.141592653589793, 1 ), -3.0, 'n=1' ); + t.strictEqual( roundsdf( -3.141592653589793, 3 ), -3.14, 'n=3' ); + t.strictEqual( roundsdf( -12368.0, 2 ), -12000.0, 'n=2' ); + t.end(); +}); + +tape( 'the main export has a native method', function test( t ) { + t.strictEqual( typeof roundsdf.native, 'function', 'has native method' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js new file mode 100644 index 000000000000..5b97089f5030 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js @@ -0,0 +1,84 @@ +/** +* @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 isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var PINF = require( '@stdlib/constants/float64/pinf' ); +var NINF = require( '@stdlib/constants/float64/ninf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var roundsdf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( roundsdf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof roundsdf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'returns NaN for NaN inputs', opts, function test( t ) { + t.ok( isnan( roundsdf( NaN, 2 ) ), 'NaN input' ); + t.ok( isnan( roundsdf( 3.14, NaN ) ), 'NaN n' ); + t.end(); +}); + +tape( 'returns NaN for n < 1', opts, function test( t ) { + t.ok( isnan( roundsdf( 3.14, 0 ) ), 'n = 0' ); + t.ok( isnan( roundsdf( 3.14, -1 ) ), 'n < 0' ); + t.end(); +}); + +tape( 'returns infinities unchanged', opts, function test( t ) { + t.strictEqual( roundsdf( PINF, 3 ), PINF, '+infinity' ); + t.strictEqual( roundsdf( NINF, 3 ), NINF, '-infinity' ); + t.end(); +}); + +tape( 'preserves signed zero', opts, function test( t ) { + t.ok( isPositiveZero( roundsdf( 0.0, 2 ) ), '+0 preserved' ); + t.ok( isNegativeZero( roundsdf( -0.0, 2 ) ), '-0 preserved' ); + t.end(); +}); + +tape( 'rounds to nearest with n significant figures', opts, function test( t ) { + t.strictEqual( roundsdf( 3.141592653589793, 1 ), 3.0, 'n=1' ); + t.strictEqual( roundsdf( 3.141592653589793, 2 ), 3.1, 'n=2' ); + t.strictEqual( roundsdf( 3.141592653589793, 3 ), 3.14, 'n=3' ); + t.end(); +}); + +tape( 'rounds large and negative values correctly', opts, function test( t ) { + t.strictEqual( roundsdf( 12368.0, 1 ), 10000.0, 'large positive' ); + t.strictEqual( roundsdf( -12368.0, 2 ), -12000.0, 'large negative' ); + t.end(); +}); From 1f81a6e3c2773d0b2d6cad433c2d486c74f45361 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 23 Jan 2026 20:51:00 +0000 Subject: [PATCH 02/13] chore: update copyright years --- lib/node_modules/@stdlib/math/base/special/roundsdf/README.md | 2 +- .../@stdlib/math/base/special/roundsdf/benchmark/benchmark.js | 2 +- .../math/base/special/roundsdf/benchmark/benchmark.native.js | 2 +- .../math/base/special/roundsdf/benchmark/c/native/Makefile | 2 +- .../math/base/special/roundsdf/benchmark/c/native/benchmark.c | 2 +- lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp | 2 +- .../@stdlib/math/base/special/roundsdf/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/roundsdf/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/roundsdf/examples/c/Makefile | 2 +- .../@stdlib/math/base/special/roundsdf/examples/c/example.c | 2 +- .../@stdlib/math/base/special/roundsdf/examples/index.js | 2 +- .../@stdlib/math/base/special/roundsdf/include.gypi | 2 +- .../roundsdf/include/stdlib/math/base/special/roundsdf.h | 2 +- .../@stdlib/math/base/special/roundsdf/lib/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js | 2 +- .../@stdlib/math/base/special/roundsdf/lib/native.js | 2 +- .../@stdlib/math/base/special/roundsdf/src/Makefile | 2 +- lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c | 2 +- lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c | 2 +- .../@stdlib/math/base/special/roundsdf/test/test.js | 2 +- .../@stdlib/math/base/special/roundsdf/test/test.native.js | 2 +- 21 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md b/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md index 26d09fed5654..56fe0cc47111 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2024 The Stdlib Authors. +Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js index 290171e86075..f86ed04432ae 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js index 12058d460d11..c7635d84bac9 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile index a4bd7b38fd74..979768abbcec 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c index d97f16df1b35..3c623c581b54 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/benchmark/c/native/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp index 68a1ca11d160..0d6508a12e99 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts index 84a0553a816c..8b1d1ec67df0 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts index 3412d27b0c46..efe3bb95cf0f 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile index 25ced822f96a..c8f8e9a1517b 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c index 828f4610fd21..5484f4d090bb 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js index 629171bb08ee..3f2f7d0063a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi b/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi index ecfaf82a3279..bee8d41a2caf 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h b/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h index 056a066ed734..32a71f5e3683 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js index 1d7dc1720119..c5560491c335 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js index 931a4330b7f9..270425bb4b40 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js index 1fcf93de9aed..c3d1a2550de9 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile index 7733b6180cb4..2caf905cedbe 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2025 The Stdlib Authors. +# Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c index a2277d9801eb..032c86de03b2 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2025 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c index 785e06aa2af6..f6ce9b04b629 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js index bb27504e3d1a..42022a1d45fa 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js index 5b97089f5030..8c246213c4ac 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2024 The Stdlib Authors. +* Copyright (c) 2026 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. From c41e40ca5c5c2503bc70da8c0a5b3459f3fe2d33 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Fri, 23 Jan 2026 21:02:37 +0000 Subject: [PATCH 03/13] feat: add math/base/special/roundsdf --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../include/stdlib/math/base/special/roundsdf.h | 8 +------- .../@stdlib/math/base/special/roundsdf/src/main.c | 10 +++++++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h b/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h index 32a71f5e3683..a7a24506c9ce 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h @@ -26,13 +26,7 @@ extern "C" { #endif /** -* Rounds a single-precision floating-point number to the nearest value toward -* positive infinity with `n` significant figures. -* -* @param x input value -* @param n number of significant figures -* @param b base -* @return rounded value +* Rounds a single-precision floating-point number to the nearest value toward positive infinity with `n` significant figures. */ float stdlib_base_roundsdf( const float x, const int32_t n, const int32_t b ); diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c index f6ce9b04b629..73b375142c67 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c @@ -17,9 +17,13 @@ */ #include "stdlib/math/base/special/roundsdf.h" -#include "stdlib/math/base/assert/is_nan.h" -#include "stdlib/math/base/assert/is_infinite.h" -#include +#include "stdlib/math/base/assert/is-nan.h" +#include "stdlib/math/base/assert/is-infinite.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/special/floorf.h" +#include "stdlib/math/base/special/log10f.h" +#include "stdlib/math/base/special/powf.h" +#include "stdlib/math/base/special/roundf.h" #include /** From aed0b169868ccb09965a92545175326d750b8672 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 06:34:07 +0000 Subject: [PATCH 04/13] fix: correct C assert header names for roundsdf --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/manifest.json | 12 ++++++------ .../@stdlib/math/base/special/roundsdf/src/main.c | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json index bfdb8ec1664c..278fe1ceded3 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json @@ -40,8 +40,8 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/napi/ternary", - "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is_infinite", + "@stdlib/math/base/assert/is_nan", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", @@ -62,8 +62,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is_infinite", + "@stdlib/math/base/assert/is_nan", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", @@ -84,8 +84,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is-infinite", - "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is_infinite", + "@stdlib/math/base/assert/is_nan", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c index 73b375142c67..9dbffd1271bf 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c @@ -17,8 +17,8 @@ */ #include "stdlib/math/base/special/roundsdf.h" -#include "stdlib/math/base/assert/is-nan.h" -#include "stdlib/math/base/assert/is-infinite.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/assert/is_infinite.h" #include "stdlib/math/base/special/absf.h" #include "stdlib/math/base/special/floorf.h" #include "stdlib/math/base/special/log10f.h" From 3222e8dc32d847bd7cdadab650b66168b0c02e8c Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 06:42:21 +0000 Subject: [PATCH 05/13] fix: resolve C dependencies and example build for roundsdf --- 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: 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: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/roundsdf/examples/c/example.c | 2 +- .../@stdlib/math/base/special/roundsdf/manifest.json | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c index 5484f4d090bb..4c2780b7dd4d 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c @@ -1,4 +1,4 @@ -/** +/* * @license Apache-2.0 * * Copyright (c) 2026 The Stdlib Authors. diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json index 278fe1ceded3..bfdb8ec1664c 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json @@ -40,8 +40,8 @@ "libpath": [], "dependencies": [ "@stdlib/math/base/napi/ternary", - "@stdlib/math/base/assert/is_infinite", - "@stdlib/math/base/assert/is_nan", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", @@ -62,8 +62,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is_infinite", - "@stdlib/math/base/assert/is_nan", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", @@ -84,8 +84,8 @@ ], "libpath": [], "dependencies": [ - "@stdlib/math/base/assert/is_infinite", - "@stdlib/math/base/assert/is_nan", + "@stdlib/math/base/assert/is-infinite", + "@stdlib/math/base/assert/is-nan", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", From 2251bd56c1034dd7817c199e9256e88b819c53b3 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 06:47:26 +0000 Subject: [PATCH 06/13] fix: resolve C dependencies and example build for roundsdf --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/roundsdf/examples/c/example.c | 4 ++-- .../@stdlib/math/base/special/roundsdf/src/main.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c index 4c2780b7dd4d..3018e6169ddb 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/examples/c/example.c @@ -32,8 +32,8 @@ int main( void ) { int i; for ( i = 0; i < 4; i++ ) { - y = stdlib_base_roundsdf( x[ i ], 2, 10 ); - printf( "roundsdf(%f, 2, 10) = %f\n", x[ i ], y ); + y = stdlib_base_roundsdf( x[ i ], 2 ); + printf( "roundsdf(%f, 2) = %f\n", x[ i ], y ); } return 0; } diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c index 9dbffd1271bf..1f813184c5b8 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c @@ -21,7 +21,7 @@ #include "stdlib/math/base/assert/is_infinite.h" #include "stdlib/math/base/special/absf.h" #include "stdlib/math/base/special/floorf.h" -#include "stdlib/math/base/special/log10f.h" +#include "stdlib/math/base/special/logf.h" #include "stdlib/math/base/special/powf.h" #include "stdlib/math/base/special/roundf.h" #include @@ -39,6 +39,7 @@ float stdlib_base_roundsdf( const float x, const int32_t n ) { float e; float s; + // Validate input: if ( stdlib_base_is_nan( x ) || n < 1 ) { return 0.0f / 0.0f; // NaN } @@ -49,8 +50,10 @@ float stdlib_base_roundsdf( const float x, const int32_t n ) { // Absolute value: ax = stdlib_base_absf( x ); - // Base-10 exponent: - e = stdlib_base_floorf( stdlib_base_log10f( ax ) ); + // Base-10 exponent (NO log10f): + e = stdlib_base_floorf( + stdlib_base_logf( ax ) / stdlib_base_logf( 10.0f ) + ); // Scale factor: s = stdlib_base_powf( 10.0f, (float)( n - 1 ) - e ); From c228e8708cf16247602568055f53feb3cec88d76 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 06:52:02 +0000 Subject: [PATCH 07/13] fix: resolve C dependencies and example build for roundsdf --- 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: 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/manifest.json | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json index bfdb8ec1664c..dc52cfd10bf8 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/manifest.json @@ -46,7 +46,8 @@ "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/logf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/roundf" ] }, { @@ -68,7 +69,8 @@ "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/logf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/roundf" ] }, { @@ -90,7 +92,8 @@ "@stdlib/math/base/special/ceilf", "@stdlib/math/base/special/floorf", "@stdlib/math/base/special/logf", - "@stdlib/math/base/special/powf" + "@stdlib/math/base/special/powf", + "@stdlib/math/base/special/roundf" ] } ] From 54e1445eecd24e51ea6bf7c1bb60330471a9167c Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 06:56:16 +0000 Subject: [PATCH 08/13] fix: resolve C dependencies and example build for roundsdf --- 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: 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../roundsdf/include/stdlib/math/base/special/roundsdf.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h b/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h index a7a24506c9ce..ebca1fbc2758 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/include/stdlib/math/base/special/roundsdf.h @@ -26,9 +26,13 @@ extern "C" { #endif /** -* Rounds a single-precision floating-point number to the nearest value toward positive infinity with `n` significant figures. +* Rounds a single-precision floating-point number to the nearest value with `n` significant figures. +* +* @param x input value +* @param n number of significant figures +* @return rounded value */ -float stdlib_base_roundsdf( const float x, const int32_t n, const int32_t b ); +float stdlib_base_roundsdf( const float x, const int32_t n ); #ifdef __cplusplus } From 52fdf8965711993c5c0bbcb638f5caf67c9649bc Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 07:07:05 +0000 Subject: [PATCH 09/13] fix: correct roundsdf log base handling in C implementation --- 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: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: missing_dependencies - 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c index 1f813184c5b8..855b9d0aed0b 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/src/main.c @@ -50,9 +50,9 @@ float stdlib_base_roundsdf( const float x, const int32_t n ) { // Absolute value: ax = stdlib_base_absf( x ); - // Base-10 exponent (NO log10f): + // Base-10 exponent: e = stdlib_base_floorf( - stdlib_base_logf( ax ) / stdlib_base_logf( 10.0f ) + stdlib_base_logf( ax, 10.0f ) ); // Scale factor: From 3fee0a8989bd33dc7198a79ae234d064e397668a Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 07:13:10 +0000 Subject: [PATCH 10/13] fix: correctly invoke native roundsdf export --- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js index c3d1a2550de9..ce6d07782d3c 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js @@ -39,7 +39,7 @@ var addon = tryRequire( './../src/addon.node' ); * @returns {number} rounded value */ function roundsdf( x, n ) { - return addon( x, n ); + return addon.roundsdf( x, n ); } From 40529d38d7a662f554c42d81bf7397bd727124d0 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 07:21:22 +0000 Subject: [PATCH 11/13] fix: call correct native export and fix JS wrapper --- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/lib/native.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js index ce6d07782d3c..d23363c01140 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js @@ -20,12 +20,7 @@ // MODULES // -var tryRequire = require( '@stdlib/utils/try-require' ); - - -// VARIABLES // - -var addon = tryRequire( './../src/addon.node' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -39,7 +34,7 @@ var addon = tryRequire( './../src/addon.node' ); * @returns {number} rounded value */ function roundsdf( x, n ) { - return addon.roundsdf( x, n ); + return addon( x, n ); } From 4b13825d427ef59a89c2db6f58156b4dd23e2b19 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 07:25:29 +0000 Subject: [PATCH 12/13] fix: call correct index export and fix JS wrapper --- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/lib/index.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js index c5560491c335..e7e9ec69a6db 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/index.js @@ -41,14 +41,7 @@ // MODULES // -var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); var main = require( './main.js' ); -var native = require( './native.js' ); - - -// MAIN // - -setReadOnly( main, 'native', native ); // EXPORTS // From cfb2b99c30e1f77fce7bc1ad5f4a10a2d4656151 Mon Sep 17 00:00:00 2001 From: Aryan Kumar Date: Sat, 24 Jan 2026 07:31:36 +0000 Subject: [PATCH 13/13] fix: pass base argument to native roundsdf wrapper --- 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: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/roundsdf/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js index d23363c01140..cf949a972cd3 100644 --- a/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/roundsdf/lib/native.js @@ -34,7 +34,7 @@ var addon = require( './../src/addon.node' ); * @returns {number} rounded value */ function roundsdf( x, n ) { - return addon( x, n ); + return addon.stdlib_base_roundsdf( x, n, 10 ); }