From 582661f364ddfd4ae98d62fd204d08a879524a00 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Fri, 20 Dec 2024 23:55:01 +0530 Subject: [PATCH 1/9] feat:- add-ceilnf --- .../math/base/special/celinf/README.md | 233 ++++++++++++++ .../special/celinf/benchmark/benchmark.js | 51 ++++ .../celinf/benchmark/benhcmark.native.js | 60 ++++ .../base/special/celinf/benchmark/c/Makefile | 146 +++++++++ .../special/celinf/benchmark/c/benchmark.c | 133 ++++++++ .../math/base/special/celinf/binding.gyp | 170 +++++++++++ .../math/base/special/celinf/docs/repl.txt | 39 +++ .../base/special/celinf/docs/types/index.d.ts | 52 ++++ .../base/special/celinf/docs/types/test.ts | 56 ++++ .../base/special/celinf/examples/c/Makefile | 146 +++++++++ .../base/special/celinf/examples/c/example.c | 31 ++ .../base/special/celinf/examples/index.js | 34 +++ .../math/base/special/celinf/include.gypi | 53 ++++ .../include/stdlib/math/base/special/ceilnf.h | 40 +++ .../math/base/special/celinf/lib/index.js | 49 +++ .../math/base/special/celinf/lib/main.js | 116 +++++++ .../math/base/special/celinf/lib/native.js | 58 ++++ .../math/base/special/celinf/manifest.json | 102 +++++++ .../math/base/special/celinf/package.json | 69 +++++ .../math/base/special/celinf/src/Makefile | 70 +++++ .../math/base/special/celinf/src/addon.c | 22 ++ .../math/base/special/celinf/src/ceilnf.c | 106 +++++++ .../math/base/special/celinf/tests/test.js | 277 +++++++++++++++++ .../base/special/celinf/tests/test.native.js | 286 ++++++++++++++++++ 24 files changed, 2399 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benhcmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/include/stdlib/math/base/special/ceilnf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/src/ceilnf.c create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/tests/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/celinf/tests/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/README.md b/lib/node_modules/@stdlib/math/base/special/celinf/README.md new file mode 100644 index 000000000000..262178b093ba --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/README.md @@ -0,0 +1,233 @@ + + +# ceilnf + +> Round a numeric value to the nearest multiple of 10^n toward positive infinity. + +
+ +## Usage + +```javascript +var ceilnf = require( '@stdlib/math/base/special/ceilnf' ); +``` + +#### ceilnf( x, n ) + +Rounds a `numeric` value to the nearest multiple of `10^n` toward positive infinity. + +```javascript +// Round a value to 2 decimal places: +var v = ceilnf( 3.141592653589793, -2 ); +// returns 3.15 + +// If n = 0, `ceiln` behaves like `ceil`: +v = ceilnf( 3.141592653589793, 0 ); +// returns 4.0 + +// Round a value to the nearest thousand: +v = ceilnf( 12368.0, 3 ); +// returns 13000.0 +``` + +
+ + + +
+ +## Notes + +- When operating on [floating-point numbers][ieee754] in bases other than `2`, rounding to specified digits can be **inexact**. For example, + + ```javascript + var x = 0.2 + 0.1; + // returns 0.30000000000000004 + + // Should round to 0.3: + var v = ceilnf( x, -16 ); + // returns 0.3000000000000001 + ``` + +
+ + + +
+ +## Examples + + + +```javascript +var randu = require( '@stdlib/random/base/randu' ); +var ceilnf = require( './../lib' ); + +var x; +var n; +var v; +var i; + +for ( i = 0; i < 100; i++ ) { + x = (randu()*100.0) - 50.0; + n = ceilnf( randu()*5.0, 0 ); + v = ceilnf( x, -n ); + console.log( 'x: %d. Number of decimals: %d. Rounded: %d.', x, n, v ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/ceilnf.h" +``` + +#### stdlib_base_ceilnf( x, n ) + +Rounds a single-precision floating-point number to the nearest multiple of `10^n` toward positive infinity. + +```c +// Round a value to 2 decimal places: +float y = stdlib_base_ceilnf( 3.141592653589793f, -2f ); +// returns 3.15f + +// If n = 0, `ceilnf` behaves like `ceil`: +float y = stdlib_base_ceilnf( 3.141592653589793f, 0f ); +// returns 4.0f + +// Round a value to the nearest thousand: +float y = stdlib_base_ceilnf( 12368.0f, 3f ); +// returns 13000.0f +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. +- **n**: `[in] int32_t` integer power of 10. + +```c +float stdlib_base_ceilnf( const float x, const int32_t n ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/ceilnf.h" +#include + +int main( void ) { + const float x[] = { 3.14f, -3.14f, 0.0f, 0.0/0.0 }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_ceilnf( x[ i ], -2f ); + printf( "ceilnf(%f, -2f) = %f\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benchmark.js new file mode 100644 index 000000000000..2bd2c394fa89 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benchmark.js @@ -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. +*/ + +'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 pkg = require( './../package.json' ).name; +var ceilnf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu()*1.0e7 ) - 5.0e6; + y = ceilnf( x, -2 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + 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/celinf/benchmark/benhcmark.native.js b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benhcmark.native.js new file mode 100644 index 000000000000..18d477c3eda6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benhcmark.native.js @@ -0,0 +1,60 @@ +/** +* @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 tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var ceilnf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( ceilnf instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu()*1.0e7 ) - 5.0e6; + y = ceilnf( x, -2 ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + 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/celinf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/Makefile new file mode 100644 index 000000000000..f69e9da2b4d3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# 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/celinf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..42284f2f68a6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/benchmark.c @@ -0,0 +1,133 @@ +/** +* @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/ceilnf.h" +#include +#include +#include +#include +#include + +#define NAME "celinf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float x; + float y; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( 1000.0*rand_float() ) - 500.0f; + y = stdlib_base_ceilnf( x, -2f ); + if ( y != y ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( y != y ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/celinf/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/binding.gyp @@ -0,0 +1,170 @@ +# @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. + +# 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/celinf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/celinf/docs/repl.txt new file mode 100644 index 000000000000..ab55b781de10 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/docs/repl.txt @@ -0,0 +1,39 @@ + +{{alias}}( x, n ) + Rounds a numeric value to the nearest multiple of `10^n` toward positive + infinity. + + When operating on single-precision floating-point numbers in bases other than `2`, rounding + to specified digits can be inexact. + + Parameters + ---------- + x: number + Input value. + + n: integer + Integer power of 10. + + Returns + ------- + y: number + Rounded value. + + Examples + -------- + // Round to 2 decimal places: + > var y = {{alias}}( 3.14159f, -2f ) + 3.15f + + // If `n = 0`, standard round toward positive infinity behavior: + > y = {{alias}}( 3.14159f, 0f ) + 4.0f + + // Round to nearest thousand: + > y = {{alias}}( 12368.0f, 3f ) + 13000.0f + + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/index.d.ts new file mode 100644 index 000000000000..6ebdc28bc583 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/index.d.ts @@ -0,0 +1,52 @@ +/* +* @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 multiple of `10^n` toward positive infinity. +* +* ## Notes +* +* - When operating on single-precison floating-point numbers in bases other than `2`, rounding to specified digits can be inexact. +* +* @param x - input value +* @param n - integer power of 10 +* @returns rounded value +* +* @example +* // Round a value to 2 decimal places: +* var v = ceilnf( 3.141592653589793f, -2f ); +* // returns 3.15f +* +* @example +* // If n = 0, `ceilnf` behaves like `ceil`: +* var v = ceilnf( 3.141592653589793f, 0f ); +* // returns 4.0f +* +* @example +* // Round a value to the nearest thousand: +* var v = ceilnf( 12368.0f, 3f ); +* // returns 13000.0f +*/ +declare function ceilnf( x: number, n: number ): number; + + +// EXPORTS // + +export = ceilnf; diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/test.ts new file mode 100644 index 000000000000..d5be4e738fc4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/test.ts @@ -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. +*/ + +import ceilnf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + ceilnf( 3.141592653589793, -4 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than two numbers... +{ + ceilnf( true, 3 ); // $ExpectError + ceilnf( false, 2 ); // $ExpectError + ceilnf( '5', 1 ); // $ExpectError + ceilnf( [], 1 ); // $ExpectError + ceilnf( {}, 2 ); // $ExpectError + ceilnf( ( x: number ): number => x, 2 ); // $ExpectError + + ceilnf( 9, true ); // $ExpectError + ceilnf( 9, false ); // $ExpectError + ceilnf( 5, '5' ); // $ExpectError + ceilnf( 8, [] ); // $ExpectError + ceilnf( 9, {} ); // $ExpectError + ceilnf( 8, ( x: number ): number => x ); // $ExpectError + + ceilnf( [], true ); // $ExpectError + ceilnf( {}, false ); // $ExpectError + ceilnf( false, '5' ); // $ExpectError + ceilnf( {}, [] ); // $ExpectError + ceilnf( '5', ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + ceilnf(); // $ExpectError + ceilnf( 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/Makefile new file mode 100644 index 000000000000..6aed70daf167 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @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. +#/ + +# 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/celinf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/example.c new file mode 100644 index 000000000000..de95809cd407 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @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/ceilnf.h" +#include + +int main( void ) { + const float x[] = { 3.14f, -3.14f, 0.0f, 0.0/0.0 }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_ceilnf( x[ i ], -2f ); + printf( "ceilnf(%f, -2f) = %f\n", x[ i ], y ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/celinf/examples/index.js new file mode 100644 index 000000000000..fcc78b66d486 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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 randu = require( '@stdlib/random/base/randu' ); +var ceilnf = require( './../lib' ); + +var x; +var n; +var v; +var i; + +for ( i = 0; i < 100; i++ ) { + x = (randu()*100.0) - 50.0; + n = ceilnf( randu()*5.0, 0 ); + v = ceilnf( x, -n ); + console.log( 'x: %d. Number of decimals: %d. Rounded: %d.', x, n, v ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/include.gypi b/lib/node_modules/@stdlib/math/base/special/celinf/include.gypi new file mode 100644 index 000000000000..575cb043c0bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/include.gypi @@ -0,0 +1,53 @@ +# @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. + +# 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': [ + ' + +#ifndef STDLIB_MATH_BASE_SPECIAL_CEILNF_H +#define STDLIB_MATH_BASE_SPECIAL_CEILNF_H + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +*/ +float stdlib_base_ceilnf( const float x, const int32_t n ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_CEILNF_H diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js new file mode 100644 index 000000000000..0aa4f3dd3828 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js @@ -0,0 +1,49 @@ +/** +* @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 multiple of `10^n` toward positive infinity. +* +* @module @stdlib/math/base/special/ceilnf +* +* @example +* var ceiln = require( '@stdlib/math/base/special/ceilnf' ); +* +* // Round a value to 2 decimal places: +* var v = ceilnf( 3.141592653589793, -2 ); +* // returns 3.15 +* +* // If n = 0, `ceilnf` behaves like `ceil`: +* v = ceilnf( 3.141592653589793, 0 ); +* // returns 4.0 +* +* // Round a value to the nearest thousand: +* v = ceilnf( 12368.0, 3 ); +* // returns 13000.0 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js new file mode 100644 index 000000000000..41ed515b789d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js @@ -0,0 +1,116 @@ +/** +* @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 isInfinitef = require( '@stdlib/math/base/assert/is-infinitef' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var ceilf = require( '@stdlib/math/base/special/ceilf' ); +var MAX_SAFE_INTEGER = require( '@stdlib/constants/float32/max-safe-integer' ); +var MAX_EXP = require( '@stdlib/constants/float32/max-base10-exponent' ); +var MIN_EXP = require( '@stdlib/constants/float32/min-base10-exponent' ); +var MIN_EXP_SUBNORMAL = require( '@stdlib/constants/float32/min-base10-exponent-subnormal' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); + + +// VARIABLES // + +var MAX_INT = MAX_SAFE_INTEGER + 1; +var HUGE = 1.0e+308; + + +// MAIN // + +/** +* Rounds a numeric value to the nearest multiple of \\(10^n\\) toward positive infinity. +* +* @param {number} x - input value +* @param {integer} n - integer power of 10 +* @returns {number} rounded value +* +* @example +* // Round a value to 2 decimal places: +* var v = ceilnf( 3.141592653589793, -2 ); +* // returns 3.15 +* +* @example +* // If n = 0, `ceilnf` behaves like `ceil`: +* var v = ceilnf( 3.141592653589793, 0 ); +* // returns 4.0 +* +* @example +* // Round a value to the nearest thousand: +* var v = ceilnf( 12368.0, 3 ); +* // returns 13000.0 +*/ +function ceilnf( x, n ) { + var s; + var y; + if ( + isnan( x ) || + isnan( n ) || + isInfinitef( n ) + ) { + return NaN; + } + if ( + // Handle infinities... + isInfinitef( x ) || + + // Handle +-0... + x === 0.0 || + + // If `n` exceeds the maximum number of feasible decimal places (such as with subnormal numbers), nothing to round... + n < MIN_EXP_SUBNORMAL || + + // If `|x|` is large enough, no decimals to round... + ( absf( x ) > MAX_INT && n <= 0 ) + ) { + return x; + } + // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. + if ( n > MAX_EXP ) { + if ( x <= 0.0 ) { + return -0.0; // preserve the sign (same behavior as ceil) + } + return PINF; + } + // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... + if ( n < MIN_EXP ) { + s = pow( 10.0, -(n + MAX_EXP) ); + y = (x*HUGE) * s; // order of operation matters! + if ( isInfinitef( y ) ) { + return x; + } + return ( ceilf(y)/HUGE ) / s; + } + s = pow( 10.0, -n ); + y = x * s; + if ( isInfinitef( y ) ) { + return x; + } + return ceilf( y ) / s; +} + + +// EXPORTS // + +module.exports = ceilnf; diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js new file mode 100644 index 000000000000..62f3f3e2e8c4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js @@ -0,0 +1,58 @@ +/** +* @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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +* +* @private +* @param {number} x - input value +* @param {integer} n - integer power of 10 +* @returns {number} rounded value +* +* @example +* // Round a value to 2 decimal places: +* var v = ceilnf( 3.141592653589793, -2 ); +* // returns 3.15 +* +* @example +* // If n = 0, `ceilnf` behaves like `ceil`: +* var v = ceilnf( 3.141592653589793, 0 ); +* // returns 4.0 +* +* @example +* // Round a value to the nearest thousand: +* var v = ceilnf( 12368.0, 3 ); +* // returns 13000.0 +*/ +function ceilnf( x, n ) { + return addon( x, n ); +} + + +// EXPORTS // + +module.exports = ceilnf; diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/manifest.json b/lib/node_modules/@stdlib/math/base/special/celinf/manifest.json new file mode 100644 index 000000000000..664cd84f8c7e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/manifest.json @@ -0,0 +1,102 @@ +{ + "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/ceiln.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/napi/binary", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-infinitef", + "@stdlib/constants/float32/max-base10-exponent", + "@stdlib/constants/float32/min-base10-exponent", + "@stdlib/constants/float32/min-base10-exponent-subnormal", + "@stdlib/constants/float32/max-safe-integer", + "@stdlib/constants/float32/pinf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/ceiln.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-infinitef", + "@stdlib/constants/float32/max-base10-exponent", + "@stdlib/constants/float32/min-base10-exponent", + "@stdlib/constants/float32/min-base10-exponent-subnormal", + "@stdlib/constants/float32/max-safe-integer", + "@stdlib/constants/float32/pinf" + ] + }, + { + "task": "examples", + "src": [ + "./src/ceiln.c" + ], + "include": [ + "./include" + ], + "libraries": [ + "-lm" + ], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-infinitef", + "@stdlib/constants/float32/max-base10-exponent", + "@stdlib/constants/float32/min-base10-exponent", + "@stdlib/constants/float32/min-base10-exponent-subnormal", + "@stdlib/constants/float32/max-safe-integer", + "@stdlib/constants/float32/pinf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/package.json b/lib/node_modules/@stdlib/math/base/special/celinf/package.json new file mode 100644 index 000000000000..3b9303110408 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/package.json @@ -0,0 +1,69 @@ +{ + "name": "@stdlib/math/base/special/ceilnf", + "version": "0.0.0", + "description": "Round a numeric value to the nearest multiple of 10^n toward positive infinity.", + "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": {}, + "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.ceil", + "ceilf", + "ceilnf", + "round", + "fix", + "tofixed", + "integer", + "nearest", + "number" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/celinf/src/Makefile new file mode 100644 index 000000000000..bcf18aa46655 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @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. +#/ + +# 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/celinf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/celinf/src/addon.c new file mode 100644 index 000000000000..348cfc8c5927 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/src/addon.c @@ -0,0 +1,22 @@ +/** +* @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/ceilnf.h" +#include "stdlib/math/base/napi/binary.h" + +STDLIB_MATH_BASE_NAPI_MODULE_FI_F( stdlib_base_ceilnf ) diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/src/ceilnf.c b/lib/node_modules/@stdlib/math/base/special/celinf/src/ceilnf.c new file mode 100644 index 000000000000..0a3e56fb27e5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/src/ceilnf.c @@ -0,0 +1,106 @@ +/** +* @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/ceilnf.h" +#include "stdlib/math/base/special/ceilf.h" +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/assert/is_infinitef.h" +#include "stdlib/constants/float32/max_base10_exponent.h" +#include "stdlib/constants/float32/min_base10_exponent.h" +#include "stdlib/constants/float32/min_base10_exponent_subnormal.h" +#include "stdlib/constants/float32/max_safe_integer.h" +#include "stdlib/constants/float32/pinf.h" +#include +#include + + +// VARIABLES // + +static const float MAX_INT = STDLIB_CONSTANT_FLOAT32_MAX_SAFE_INTEGER + 1.0; +static const float HUGE_VALUE = 1.0e+308; + + +// MAIN // + +/** +* Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +* +* @param x input value +* @param n integer power of 10 +* @return rounded value +* +* @example +* // Round a value to 2 decimal places: +* float y = stdlib_base_ceilnf( 3.141592653589793f, -2f ); +* // returns 3.15f +* +* @example +* // If n = 0, `ceilnf` behaves like `ceil`: +* float y = stdlib_base_ceilnf( 3.141592653589793f, 0f ); +* // returns 4.0f +* +* @example +* // Round a value to the nearest thousand: +* float y = stdlib_base_ceilnf( 12368.0f, 3f ); +* // returns 13000.0f +*/ +float stdlib_base_ceilnf( const float x, const int32_t n ) { + float s; + float y; + if ( stdlib_base_is_nan( x ) ) { + return x; + } + if ( + // Handle infinities... + stdlib_base_is_infinitef( x ) || + + // Handle +-0... + x == 0.0 || + + // If `n` exceeds the maximum number of feasible decimal places (such as with subnormal numbers), nothing to round... + n < STDLIB_CONSTANT_FLOAT32_MIN_BASE10_EXPONENT_SUBNORMAL || + + // If `|x|` is large enough, no decimals to round... + ( stdlib_base_absf( x ) > MAX_INT && n <= 0 ) + ) { + return x; + } + // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. + if ( n > STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) { + if ( x <= 0.0 ) { + return -0.0; // preserve the sign (same behavior as ceil) + } + return STDLIB_CONSTANT_FLOAT32_PINF; + } + // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... + if ( n < STDLIB_CONSTANT_FLOAT32_MIN_BASE10_EXPONENT ) { + s = pow( 10.0, -( n + STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent + y = ( x * HUGE_VALUE ) * s; // order of operation matters! + if ( stdlib_base_is_infinitef( y ) ) { + return x; + } + return ( stdlib_base_ceilf( y ) / HUGE_VALUE ) / s; + } + s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent + y = x * s; + if ( stdlib_base_is_infinitef( y ) ) { + return x; + } + return stdlib_base_ceilf( y ) / s; +} diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.js b/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.js new file mode 100644 index 000000000000..efb7cf3ac4bf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.js @@ -0,0 +1,277 @@ +/** +* @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 PI = require( '@stdlib/constants/float32/pi' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var ceilnf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ceilnf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { + var v; + + v = ceilnf( NaN, -2 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = ceilnf( 12368.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = ceilnf( NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if provided `n = +-infinity`', function test( t ) { + var v; + + v = ceilnf( PI, PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = ceilnf( PI, NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `+infinity` if provided `+infinity`', function test( t ) { + var v = ceilnf( PINF, 5 ); + t.strictEqual( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'the function returns `-infinity` if provided `-infinity`', function test( t ) { + var v = ceilnf( NINF, -3 ); + t.strictEqual( v, NINF, 'returns -infinity' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', function test( t ) { + var v; + + v = ceilnf( -0.0, 0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + + v = ceilnf( -0.0, -2 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + + v = ceilnf( -0.0, 2 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', function test( t ) { + var v; + + v = ceilnf( 0.0, 0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + + v = ceilnf( +0.0, -2 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + + v = ceilnf( +0.0, 2 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + + t.end(); +}); + +tape( 'the function supports rounding a numeric value to a desired number of decimals', function test( t ) { + t.strictEqual( ceilnf( PI, -2 ), 3.15, 'equals 3.15' ); + t.strictEqual( ceilnf( -PI, -2 ), -3.14, 'equals -3.14' ); + t.strictEqual( ceilnf( 9.99999, -2 ), 10.0, 'equals 10' ); + t.strictEqual( ceilnf( -9.99999, -2 ), -9.99, 'equals -9.99' ); + t.strictEqual( ceilnf( 0.0, 2 ), 0.0, 'equals 0' ); + t.strictEqual( ceilnf( 12368.0, -3 ), 12368.0, 'equals 12368' ); + t.strictEqual( ceilnf( -12368.0, -3 ), -12368.0, 'equals -12368' ); + t.end(); +}); + +tape( 'rounding a numeric value to a desired number of decimals can result in unexpected behavior', function test( t ) { + var x = 0.2 + 0.1; // => 0.30000000000000004 + t.strictEqual( ceilnf( x, -16 ), 0.3000000000000001, 'equals 0.3000000000000001 and not 0.3' ); + t.end(); +}); + +tape( 'the function supports rounding a numeric value to a desired number of digits', function test( t ) { + t.strictEqual( ceilnf( PI, 4 ), 10000.0, 'equals 10000' ); + t.strictEqual( ceilnf( 12368.0, 3 ), 13000.0, 'equals 13000' ); + t.strictEqual( ceilnf( 12363.0, 1 ), 12370.0, 'equals 12370' ); + t.strictEqual( isNegativeZero( ceilnf( -PI, 3 ) ), true, 'equals -0' ); + t.strictEqual( ceilnf( -12368.0, 3 ), -12000.0, 'equals -12000' ); + t.strictEqual( ceilnf( -12368.0, 1 ), -12360.0, 'equals -12360' ); + t.end(); +}); + +tape( 'the function returns the input value if provided an `n` which is less than the minimum decimal exponential (-324)', function test( t ) { + var exp; + var n; + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + exp = round( randu()*616.0 ) - 308; + x = (1.0+randu()) * pow( 10.0, exp ); + n = -(round( randu()*1000.0 ) + 325); + v = ceilnf( x, n ); + t.strictEqual( v, x, 'returns input value when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'if `x` is too large a double to have decimals and `n < 0`, the input value is returned', function test( t ) { + var sign; + var exp; + var x; + var n; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + sign = ( randu()<0.5 ) ? -1.0 : 1.0; + exp = 54 + round( randu()*254.0 ); + x = sign * (1.0+randu()) * pow( 10.0, exp ); + n = -( round( randu()*324.0) ); + v = ceilnf( x, n ); + t.strictEqual( x, v, ' returns input value when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'if `n > 308` and `x > 0`, the function returns `+infinity`', function test( t ) { + var exp; + var x; + var n; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + exp = round( randu()*307.0 ); + x = (1.0+randu()) * pow( 10.0, exp ); + n = round( randu()*100.0 ) + 309; + v = ceilnf( x, n ); + t.strictEqual( v, PINF, ' returns +infinity when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'if `n > 308` and `x < 0`, the function returns `-0` (sign preserving)', function test( t ) { + var exp; + var x; + var n; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + exp = round( randu()*307.0 ); + x = -(1.0+randu()) * pow( 10.0, exp ); + n = round( randu()*100.0 ) + 309; + v = ceilnf( x, n ); + t.strictEqual( isNegativeZero( v ), true, ' returns -0 when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'the function supports rounding very small numbers (including subnormals)', function test( t ) { + var expected; + var delta; + var tol; + var x; + var n; + var v; + var i; + + x = 3.1468234343023397 * pow( 10.0, -308 ); + + n = []; + for ( i = -308; i > -325; i-- ) { + n.push( i ); + } + expected = [ + 4e-308, + 3.2e-308, + 3.15e-308, + 3.147e-308, + 3.1469e-308, + 3.14683e-308, + 3.146824e-308, + 3.1468235e-308, + 3.14682344e-308, + 3.146823435e-308, + 3.1468234344e-308, + 3.14682343431e-308, + 3.146823434303e-308, + 3.1468234343024e-308, + 3.14682343430234e-308, + 3.146823434302340e-308, + 3.1468234343023397e-308 + ]; + + for ( i = 0; i < n.length; i++ ) { + v = ceilnf( x, n[i] ); + if ( v === expected[i] ) { + t.strictEqual( v, expected[ i ], 'returns '+expected[i]+' when provided x='+x+' and n='+n[i]+'.' ); + } else { + delta = absf( v - expected[i] ); + tol = EPS * absf( expected[i] ); + t.strictEqual( delta <= tol, true, 'x: '+x+'. n: '+n[i]+'. v: '+v+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); + } + } + t.end(); +}); + +tape( 'if the function encounters overflow, the function returns the input value', function test( t ) { + var x; + var v; + + x = 3.1468234343023397; + v = ceilnf( x, -314 ); + t.strictEqual( v, x, 'returns the input value' ); + + x = -3.1468234343023397; + v = ceilnf( x, -314 ); + t.strictEqual( v, x, 'returns the input value' ); + + x = 9007199254740000; + v = ceilnf( x, -300 ); + t.strictEqual( v, x, 'returns the input value' ); + + x = -9007199254740000; + v = ceilnf( x, -300 ); + t.strictEqual( v, x, 'returns the input value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.native.js b/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.native.js new file mode 100644 index 000000000000..abc39b492cac --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.native.js @@ -0,0 +1,286 @@ +/** +* @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 PI = require( '@stdlib/constants/float32/pi' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var randu = require( '@stdlib/random/base/randu' ); +var round = require( '@stdlib/math/base/special/round' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var ceilnf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( ceilnf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ceilnf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var v; + + v = ceilnf( NaN, -2 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = ceilnf( 12368.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = ceilnf( NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if provided `n = +-infinity`', opts, function test( t ) { + var v; + + v = ceilnf( PI, PINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = ceilnf( PI, NINF ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `+infinity` if provided `+infinity`', opts, function test( t ) { + var v = ceilnf( PINF, 5 ); + t.strictEqual( v, PINF, 'returns +infinity' ); + t.end(); +}); + +tape( 'the function returns `-infinity` if provided `-infinity`', opts, function test( t ) { + var v = ceilnf( NINF, -3 ); + t.strictEqual( v, NINF, 'returns -infinity' ); + t.end(); +}); + +tape( 'the function returns `-0` if provided `-0`', opts, function test( t ) { + var v; + + v = ceilnf( -0.0, 0 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + + v = ceilnf( -0.0, -2 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + + v = ceilnf( -0.0, 2 ); + t.strictEqual( isNegativeZero( v ), true, 'returns -0' ); + + t.end(); +}); + +tape( 'the function returns `+0` if provided `+0`', opts, function test( t ) { + var v; + + v = ceilnf( 0.0, 0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + + v = ceilnf( +0.0, -2 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + + v = ceilnf( +0.0, 2 ); + t.strictEqual( isPositiveZero( v ), true, 'returns +0' ); + + t.end(); +}); + +tape( 'the function supports rounding a numeric value to a desired number of decimals', opts, function test( t ) { + t.strictEqual( ceilnf( PI, -2 ), 3.15, 'equals 3.15' ); + t.strictEqual( ceilnf( -PI, -2 ), -3.14, 'equals -3.14' ); + t.strictEqual( ceilnf( 9.99999, -2 ), 10.0, 'equals 10' ); + t.strictEqual( ceilnf( -9.99999, -2 ), -9.99, 'equals -9.99' ); + t.strictEqual( ceilnf( 0.0, 2 ), 0.0, 'equals 0' ); + t.strictEqual( ceilnf( 12368.0, -3 ), 12368.0, 'equals 12368' ); + t.strictEqual( ceilnf( -12368.0, -3 ), -12368.0, 'equals -12368' ); + t.end(); +}); + +tape( 'rounding a numeric value to a desired number of decimals can result in unexpected behavior', opts, function test( t ) { + var x = 0.2 + 0.1; // => 0.30000000000000004 + t.strictEqual( ceilnf( x, -16 ), 0.3000000000000001, 'equals 0.3000000000000001 and not 0.3' ); + t.end(); +}); + +tape( 'the function supports rounding a numeric value to a desired number of digits', opts, function test( t ) { + t.strictEqual( ceilnf( PI, 4 ), 10000.0, 'equals 10000' ); + t.strictEqual( ceilnf( 12368.0, 3 ), 13000.0, 'equals 13000' ); + t.strictEqual( ceilnf( 12363.0, 1 ), 12370.0, 'equals 12370' ); + t.strictEqual( isNegativeZero( ceilnf( -PI, 3 ) ), true, 'equals -0' ); + t.strictEqual( ceilnf( -12368.0, 3 ), -12000.0, 'equals -12000' ); + t.strictEqual( ceilnf( -12368.0, 1 ), -12360.0, 'equals -12360' ); + t.end(); +}); + +tape( 'the function returns the input value if provided an `n` which is less than the minimum decimal exponential (-324)', opts, function test( t ) { + var exp; + var n; + var x; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + exp = round( randu()*616.0 ) - 308; + x = (1.0+randu()) * pow( 10.0, exp ); + n = -(round( randu()*1000.0 ) + 325); + v = ceilnf( x, n ); + t.strictEqual( v, x, 'returns input value when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'if `x` is too large a double to have decimals and `n < 0`, the input value is returned', opts, function test( t ) { + var sign; + var exp; + var x; + var n; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + sign = ( randu()<0.5 ) ? -1.0 : 1.0; + exp = 54 + round( randu()*254.0 ); + x = sign * (1.0+randu()) * pow( 10.0, exp ); + n = -( round( randu()*324.0) ); + v = ceilnf( x, n ); + t.strictEqual( x, v, ' returns input value when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'if `n > 308` and `x > 0`, the function returns `+infinity`', opts, function test( t ) { + var exp; + var x; + var n; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + exp = round( randu()*307.0 ); + x = (1.0+randu()) * pow( 10.0, exp ); + n = round( randu()*100.0 ) + 309; + v = ceilnf( x, n ); + t.strictEqual( v, PINF, ' returns +infinity when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'if `n > 308` and `x < 0`, the function returns `-0` (sign preserving)', opts, function test( t ) { + var exp; + var x; + var n; + var v; + var i; + for ( i = 0; i < 100; i++ ) { + exp = round( randu()*307.0 ); + x = -(1.0+randu()) * pow( 10.0, exp ); + n = round( randu()*100.0 ) + 309; + v = ceilnf( x, n ); + t.strictEqual( isNegativeZero( v ), true, ' returns -0 when provided x='+x+', n='+n+'.' ); + } + t.end(); +}); + +tape( 'the function supports rounding very small numbers (including subnormals)', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var n; + var v; + var i; + + x = 3.1468234343023397 * pow( 10.0, -308 ); + + n = []; + for ( i = -308; i > -325; i-- ) { + n.push( i ); + } + expected = [ + 4e-308, + 3.2e-308, + 3.15e-308, + 3.147e-308, + 3.1469e-308, + 3.14683e-308, + 3.146824e-308, + 3.1468235e-308, + 3.14682344e-308, + 3.146823435e-308, + 3.1468234344e-308, + 3.14682343431e-308, + 3.146823434303e-308, + 3.1468234343024e-308, + 3.14682343430234e-308, + 3.146823434302340e-308, + 3.1468234343023397e-308 + ]; + + for ( i = 0; i < n.length; i++ ) { + v = ceilnf( x, n[i] ); + if ( v === expected[i] ) { + t.strictEqual( v, expected[ i ], 'returns '+expected[i]+' when provided x='+x+' and n='+n[i]+'.' ); + } else { + delta = absf( v - expected[i] ); + tol = EPS * absf( expected[i] ); + t.strictEqual( delta <= tol, true, 'x: '+x+'. n: '+n[i]+'. v: '+v+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); + } + } + t.end(); +}); + +tape( 'if the function encounters overflow, the function returns the input value', opts, function test( t ) { + var x; + var v; + + x = 3.1468234343023397; + v = ceilnf( x, -314 ); + t.strictEqual( v, x, 'returns the input value' ); + + x = -3.1468234343023397; + v = ceilnf( x, -314 ); + t.strictEqual( v, x, 'returns the input value' ); + + x = 9007199254740000; + v = ceilnf( x, -300 ); + t.strictEqual( v, x, 'returns the input value' ); + + x = -9007199254740000; + v = ceilnf( x, -300 ); + t.strictEqual( v, x, 'returns the input value' ); + + t.end(); +}); From c2f50c350d6db0604d7a7a5160b0ec6399320013 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sat, 21 Dec 2024 00:06:43 +0530 Subject: [PATCH 2/9] feat:- add-ceilnf --- .../@stdlib/math/base/special/{celinf => ceilnf}/README.md | 2 +- .../base/special/{celinf => ceilnf}/benchmark/benchmark.js | 0 .../special/{celinf => ceilnf}/benchmark/benhcmark.native.js | 0 .../math/base/special/{celinf => ceilnf}/benchmark/c/Makefile | 0 .../base/special/{celinf => ceilnf}/benchmark/c/benchmark.c | 2 +- .../@stdlib/math/base/special/{celinf => ceilnf}/binding.gyp | 0 .../math/base/special/{celinf => ceilnf}/docs/repl.txt | 0 .../base/special/{celinf => ceilnf}/docs/types/index.d.ts | 0 .../math/base/special/{celinf => ceilnf}/docs/types/test.ts | 0 .../math/base/special/{celinf => ceilnf}/examples/c/Makefile | 0 .../math/base/special/{celinf => ceilnf}/examples/c/example.c | 4 ++-- .../math/base/special/{celinf => ceilnf}/examples/index.js | 0 .../@stdlib/math/base/special/{celinf => ceilnf}/include.gypi | 0 .../include/stdlib/math/base/special/ceilnf.h | 0 .../@stdlib/math/base/special/{celinf => ceilnf}/lib/index.js | 2 +- .../@stdlib/math/base/special/{celinf => ceilnf}/lib/main.js | 2 +- .../math/base/special/{celinf => ceilnf}/lib/native.js | 2 +- .../math/base/special/{celinf => ceilnf}/manifest.json | 0 .../@stdlib/math/base/special/{celinf => ceilnf}/package.json | 0 .../@stdlib/math/base/special/{celinf => ceilnf}/src/Makefile | 0 .../@stdlib/math/base/special/{celinf => ceilnf}/src/addon.c | 0 .../@stdlib/math/base/special/{celinf => ceilnf}/src/ceilnf.c | 0 .../math/base/special/{celinf => ceilnf}/tests/test.js | 0 .../math/base/special/{celinf => ceilnf}/tests/test.native.js | 0 24 files changed, 7 insertions(+), 7 deletions(-) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/README.md (99%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/benchmark/benchmark.js (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/benchmark/benhcmark.native.js (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/benchmark/c/Makefile (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/benchmark/c/benchmark.c (98%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/binding.gyp (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/docs/repl.txt (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/docs/types/index.d.ts (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/docs/types/test.ts (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/examples/c/Makefile (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/examples/c/example.c (89%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/examples/index.js (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/include.gypi (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/include/stdlib/math/base/special/ceilnf.h (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/lib/index.js (96%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/lib/main.js (98%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/lib/native.js (96%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/manifest.json (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/package.json (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/src/Makefile (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/src/addon.c (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/src/ceilnf.c (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/tests/test.js (100%) rename lib/node_modules/@stdlib/math/base/special/{celinf => ceilnf}/tests/test.native.js (100%) diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/README.md b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md similarity index 99% rename from lib/node_modules/@stdlib/math/base/special/celinf/README.md rename to lib/node_modules/@stdlib/math/base/special/ceilnf/README.md index 262178b093ba..7a524d5af700 100644 --- a/lib/node_modules/@stdlib/math/base/special/celinf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +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. diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benchmark.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.js diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benhcmark.native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benhcmark.native.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/benchmark/benhcmark.native.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benhcmark.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/Makefile rename to lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c similarity index 98% rename from lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/benchmark.c rename to lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c index 42284f2f68a6..4bc282e7f7ed 100644 --- a/lib/node_modules/@stdlib/math/base/special/celinf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c @@ -99,7 +99,7 @@ static double benchmark( void ) { t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { x = ( 1000.0*rand_float() ) - 500.0f; - y = stdlib_base_ceilnf( x, -2f ); + y = stdlib_base_ceilnf( x, -2 ); if ( y != y ) { printf( "should not return NaN\n" ); break; diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/ceilnf/binding.gyp similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/binding.gyp rename to lib/node_modules/@stdlib/math/base/special/ceilnf/binding.gyp diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/docs/repl.txt rename to lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/index.d.ts similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/docs/types/index.d.ts rename to lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/index.d.ts diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/test.ts similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/docs/types/test.ts rename to lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/test.ts diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/ceilnf/examples/c/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/examples/c/Makefile rename to lib/node_modules/@stdlib/math/base/special/ceilnf/examples/c/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/examples/c/example.c similarity index 89% rename from lib/node_modules/@stdlib/math/base/special/celinf/examples/c/example.c rename to lib/node_modules/@stdlib/math/base/special/ceilnf/examples/c/example.c index de95809cd407..b4d0a2e3ec8a 100644 --- a/lib/node_modules/@stdlib/math/base/special/celinf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/examples/c/example.c @@ -25,7 +25,7 @@ int main( void ) { float y; int i; for ( i = 0; i < 4; i++ ) { - y = stdlib_base_ceilnf( x[ i ], -2f ); - printf( "ceilnf(%f, -2f) = %f\n", x[ i ], y ); + y = stdlib_base_ceilnf( x[ i ], -2 ); + printf( "ceilnf(%f, -2) = %f\n", x[ i ], y ); } } diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/examples/index.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/examples/index.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/examples/index.js diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/include.gypi b/lib/node_modules/@stdlib/math/base/special/ceilnf/include.gypi similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/include.gypi rename to lib/node_modules/@stdlib/math/base/special/ceilnf/include.gypi diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/include/stdlib/math/base/special/ceilnf.h b/lib/node_modules/@stdlib/math/base/special/ceilnf/include/stdlib/math/base/special/ceilnf.h similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/include/stdlib/math/base/special/ceilnf.h rename to lib/node_modules/@stdlib/math/base/special/ceilnf/include/stdlib/math/base/special/ceilnf.h diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js similarity index 96% rename from lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js index 0aa4f3dd3828..abf965ded80c 100644 --- a/lib/node_modules/@stdlib/math/base/special/celinf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js @@ -30,7 +30,7 @@ * var v = ceilnf( 3.141592653589793, -2 ); * // returns 3.15 * -* // If n = 0, `ceilnf` behaves like `ceil`: +* // If n = 0, `ceilnf` behaves like `ceilf`: * v = ceilnf( 3.141592653589793, 0 ); * // returns 4.0 * diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js similarity index 98% rename from lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js index 41ed515b789d..3fe4e0c417f2 100644 --- a/lib/node_modules/@stdlib/math/base/special/celinf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js @@ -52,7 +52,7 @@ var HUGE = 1.0e+308; * // returns 3.15 * * @example -* // If n = 0, `ceilnf` behaves like `ceil`: +* // If n = 0, `ceilnf` behaves like `ceilf`: * var v = ceilnf( 3.141592653589793, 0 ); * // returns 4.0 * diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js similarity index 96% rename from lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js index 62f3f3e2e8c4..e8b83c422377 100644 --- a/lib/node_modules/@stdlib/math/base/special/celinf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js @@ -39,7 +39,7 @@ var addon = require( './../src/addon.node' ); * // returns 3.15 * * @example -* // If n = 0, `ceilnf` behaves like `ceil`: +* // If n = 0, `ceilnf` behaves like `ceilf`: * var v = ceilnf( 3.141592653589793, 0 ); * // returns 4.0 * diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/manifest.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/manifest.json rename to lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/package.json rename to lib/node_modules/@stdlib/math/base/special/ceilnf/package.json diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/Makefile similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/src/Makefile rename to lib/node_modules/@stdlib/math/base/special/ceilnf/src/Makefile diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/addon.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/src/addon.c rename to lib/node_modules/@stdlib/math/base/special/ceilnf/src/addon.c diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/src/ceilnf.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/src/ceilnf.c rename to lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/tests/test.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js diff --git a/lib/node_modules/@stdlib/math/base/special/celinf/tests/test.native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.native.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/celinf/tests/test.native.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.native.js From c98e24935e1179ba05714d477f1b0de7348eb740 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sat, 21 Dec 2024 00:25:49 +0530 Subject: [PATCH 3/9] fix: CI errors --- .../math/base/special/ceilnf/README.md | 26 +++++++++---------- ...enhcmark.native.js => benchmark.native.js} | 0 .../special/ceilnf/benchmark/c/benchmark.c | 2 +- .../math/base/special/ceilnf/docs/repl.txt | 12 ++++----- .../math/base/special/ceilnf/package.json | 4 +-- 5 files changed, 22 insertions(+), 22 deletions(-) rename lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/{benhcmark.native.js => benchmark.native.js} (100%) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md index 7a524d5af700..50f18578198d 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md @@ -79,7 +79,7 @@ v = ceilnf( 12368.0, 3 ); ```javascript var randu = require( '@stdlib/random/base/randu' ); -var ceilnf = require( './../lib' ); +var ceilnf = require( '@stdlib/math/base/special/ceilnf' ); var x; var n; @@ -87,10 +87,10 @@ var v; var i; for ( i = 0; i < 100; i++ ) { - x = (randu()*100.0) - 50.0; - n = ceilnf( randu()*5.0, 0 ); - v = ceilnf( x, -n ); - console.log( 'x: %d. Number of decimals: %d. Rounded: %d.', x, n, v ); + x = (randu()*100.0) - 50.0; + n = ceilnf( randu()*5.0, 0 ); + v = ceilnf( x, -n ); + console.log( 'x: %d. Number of decimals: %d. Rounded: %d.', x, n, v ); } ``` @@ -174,14 +174,14 @@ float stdlib_base_ceilnf( const float x, const int32_t n ); #include int main( void ) { - const float x[] = { 3.14f, -3.14f, 0.0f, 0.0/0.0 }; - - float y; - int i; - for ( i = 0; i < 4; i++ ) { - y = stdlib_base_ceilnf( x[ i ], -2f ); - printf( "ceilnf(%f, -2f) = %f\n", x[ i ], y ); - } + const float x[] = { 3.14f, -3.14f, 0.0f, 0.0/0.0 }; + + float y; + int i; + for ( i = 0; i < 4; i++ ) { + y = stdlib_base_ceilnf( x[ i ], -2f ); + printf( "ceilnf(%f, -2f) = %f\n", x[ i ], y ); + } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benhcmark.native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.native.js similarity index 100% rename from lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benhcmark.native.js rename to lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c index 4bc282e7f7ed..f2e5a24127fc 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c @@ -23,7 +23,7 @@ #include #include -#define NAME "celinf" +#define NAME "ceilnf" #define ITERATIONS 1000000 #define REPEATS 3 diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt index ab55b781de10..2b8d893b07c5 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt @@ -22,16 +22,16 @@ Examples -------- // Round to 2 decimal places: - > var y = {{alias}}( 3.14159f, -2f ) - 3.15f + > var y = {{alias}}( 3.14159, -2 ) + 3.15 // If `n = 0`, standard round toward positive infinity behavior: - > y = {{alias}}( 3.14159f, 0f ) - 4.0f + > y = {{alias}}( 3.14159, 0 ) + 4.0 // Round to nearest thousand: - > y = {{alias}}( 12368.0f, 3f ) - 13000.0f + > y = {{alias}}( 12368.0, 3 ) + 13000.0 See Also diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json index 3b9303110408..b7a02618220d 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json @@ -21,8 +21,8 @@ "example": "./examples", "include": "./include", "lib": "./lib", - "src": "./src", - "test": "./test" + "test": "./test", + "src": "./src" }, "types": "./docs/types", "scripts": {}, From 75e6e3b55098617b1c7d51c0ed1bf73030781733 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sat, 21 Dec 2024 00:30:42 +0530 Subject: [PATCH 4/9] fix: CI errors --- lib/node_modules/@stdlib/math/base/special/ceilnf/README.md | 4 ++-- .../@stdlib/math/base/special/ceilnf/manifest.json | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md index 50f18578198d..27820fb122f1 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md @@ -179,8 +179,8 @@ int main( void ) { float y; int i; for ( i = 0; i < 4; i++ ) { - y = stdlib_base_ceilnf( x[ i ], -2f ); - printf( "ceilnf(%f, -2f) = %f\n", x[ i ], y ); + y = stdlib_base_ceilnf( x[ i ], -2 ); + printf( "ceilnf(%f, -2) = %f\n", x[ i ], y ); } } ``` diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json index 664cd84f8c7e..22b2b45833ae 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json @@ -28,7 +28,7 @@ { "task": "build", "src": [ - "./src/ceiln.c" + "./src/ceilnf.c" ], "include": [ "./include" @@ -53,7 +53,7 @@ { "task": "benchmark", "src": [ - "./src/ceiln.c" + "./src/ceilnf.c" ], "include": [ "./include" @@ -77,7 +77,7 @@ { "task": "examples", "src": [ - "./src/ceiln.c" + "./src/ceilnf.c" ], "include": [ "./include" From 3f6ea1f1664235931b8e3a5368facc6d63988064 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sat, 21 Dec 2024 01:08:48 +0530 Subject: [PATCH 5/9] fix: test errors --- .../@stdlib/math/base/special/ceilnf/docs/repl.txt | 4 ++-- lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js | 1 + .../@stdlib/math/base/special/ceilnf/package.json | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt index 2b8d893b07c5..52433a415774 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt @@ -3,8 +3,8 @@ Rounds a numeric value to the nearest multiple of `10^n` toward positive infinity. - When operating on single-precision floating-point numbers in bases other than `2`, rounding - to specified digits can be inexact. + When operating on single-precision floating-point numbers in bases other + than `2`, rounding to specified digits can be inexact. Parameters ---------- diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js index 3fe4e0c417f2..b80595cbddee 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js @@ -19,6 +19,7 @@ 'use strict'; // MODULES // + var isnan = require( '@stdlib/math/base/assert/is-nan' ); var isInfinitef = require( '@stdlib/math/base/assert/is-infinitef' ); var pow = require( '@stdlib/math/base/special/pow' ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json index b7a02618220d..3b9303110408 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json @@ -21,8 +21,8 @@ "example": "./examples", "include": "./include", "lib": "./lib", - "test": "./test", - "src": "./src" + "src": "./src", + "test": "./test" }, "types": "./docs/types", "scripts": {}, From c6a602fef21d9fa96c797140069374f66fa009b5 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sat, 21 Dec 2024 01:19:16 +0530 Subject: [PATCH 6/9] fix: lint errors --- .../@stdlib/math/base/special/ceilnf/lib/native.js | 4 ++-- .../@stdlib/math/base/special/ceilnf/src/ceilnf.c | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js index e8b83c422377..b10b9ffc2e19 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js @@ -36,7 +36,7 @@ var addon = require( './../src/addon.node' ); * @example * // Round a value to 2 decimal places: * var v = ceilnf( 3.141592653589793, -2 ); -* // returns 3.15 +* // returns 3.1500000953674316 * * @example * // If n = 0, `ceilnf` behaves like `ceilf`: @@ -46,7 +46,7 @@ var addon = require( './../src/addon.node' ); * @example * // Round a value to the nearest thousand: * var v = ceilnf( 12368.0, 3 ); -* // returns 13000.0 +* // returns 12999.9990234375 */ function ceilnf( x, n ) { return addon( x, n ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c index 0a3e56fb27e5..cba7da9d0fb9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c @@ -32,8 +32,8 @@ // VARIABLES // -static const float MAX_INT = STDLIB_CONSTANT_FLOAT32_MAX_SAFE_INTEGER + 1.0; -static const float HUGE_VALUE = 1.0e+308; +static const float MAX_INT = STDLIB_CONSTANT_FLOAT32_MAX_SAFE_INTEGER + 1.0f; +static const float HUGE_VALUE = 1.0e+308f; // MAIN // @@ -71,7 +71,7 @@ float stdlib_base_ceilnf( const float x, const int32_t n ) { stdlib_base_is_infinitef( x ) || // Handle +-0... - x == 0.0 || + x == 0.0f || // If `n` exceeds the maximum number of feasible decimal places (such as with subnormal numbers), nothing to round... n < STDLIB_CONSTANT_FLOAT32_MIN_BASE10_EXPONENT_SUBNORMAL || @@ -83,21 +83,21 @@ float stdlib_base_ceilnf( const float x, const int32_t n ) { } // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. if ( n > STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) { - if ( x <= 0.0 ) { - return -0.0; // preserve the sign (same behavior as ceil) + if ( x <= 0.0f ) { + return -0.0f; // preserve the sign (same behavior as ceil) } return STDLIB_CONSTANT_FLOAT32_PINF; } // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... if ( n < STDLIB_CONSTANT_FLOAT32_MIN_BASE10_EXPONENT ) { - s = pow( 10.0, -( n + STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent + s = pow( 10.0f, -( n + STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent y = ( x * HUGE_VALUE ) * s; // order of operation matters! if ( stdlib_base_is_infinitef( y ) ) { return x; } return ( stdlib_base_ceilf( y ) / HUGE_VALUE ) / s; } - s = pow( 10.0, -n ); // TODO: replace use of `pow` once have stdlib equivalent + s = pow( 10.0f, -n ); // TODO: replace use of `pow` once have stdlib equivalent y = x * s; if ( stdlib_base_is_infinitef( y ) ) { return x; From a7c94b6f690f0f160c7538eb327e56d14fe6802c Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Sat, 21 Dec 2024 11:04:19 +0530 Subject: [PATCH 7/9] fix: package errors --- lib/node_modules/@stdlib/math/base/special/ceilnf/package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json index 3b9303110408..c2fda643e8c9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json @@ -21,8 +21,7 @@ "example": "./examples", "include": "./include", "lib": "./lib", - "src": "./src", - "test": "./test" + "src": "./src" }, "types": "./docs/types", "scripts": {}, From 53723fe35724afdfc2588f83cd30e3527c1c51a7 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Mon, 23 Dec 2024 13:28:31 +0530 Subject: [PATCH 8/9] fix: changing isnan to isnanf --- .../math/base/special/ceilnf/benchmark/benchmark.js | 6 +++--- .../special/ceilnf/benchmark/benchmark.native.js | 6 +++--- .../@stdlib/math/base/special/ceilnf/lib/index.js | 2 +- .../@stdlib/math/base/special/ceilnf/lib/main.js | 8 ++++---- .../@stdlib/math/base/special/ceilnf/manifest.json | 6 +++--- .../@stdlib/math/base/special/ceilnf/src/ceilnf.c | 4 ++-- .../@stdlib/math/base/special/ceilnf/tests/test.js | 12 ++++++------ .../math/base/special/ceilnf/tests/test.native.js | 12 ++++++------ 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.js index 2bd2c394fa89..f7b8f5d047fe 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.js @@ -22,7 +22,7 @@ var bench = require( '@stdlib/bench' ); var randu = require( '@stdlib/random/base/randu' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var pkg = require( './../package.json' ).name; var ceilnf = require( './../lib' ); @@ -38,12 +38,12 @@ bench( pkg, function benchmark( b ) { for ( i = 0; i < b.iterations; i++ ) { x = ( randu()*1.0e7 ) - 5.0e6; y = ceilnf( x, -2 ); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.native.js index 18d477c3eda6..a889644c0772 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/benchmark.native.js @@ -23,7 +23,7 @@ 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 isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -47,12 +47,12 @@ bench( pkg+'::native', opts, function benchmark( b ) { for ( i = 0; i < b.iterations; i++ ) { x = ( randu()*1.0e7 ) - 5.0e6; y = ceilnf( x, -2 ); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } } b.toc(); - if ( isnan( y ) ) { + if ( isnanf( y ) ) { b.fail( 'should not return NaN' ); } b.pass( 'benchmark finished' ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js index abf965ded80c..1e0ec5a7f812 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js @@ -24,7 +24,7 @@ * @module @stdlib/math/base/special/ceilnf * * @example -* var ceiln = require( '@stdlib/math/base/special/ceilnf' ); +* var ceilnf = require( '@stdlib/math/base/special/ceilnf' ); * * // Round a value to 2 decimal places: * var v = ceilnf( 3.141592653589793, -2 ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js index b80595cbddee..15da15754ceb 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js @@ -20,7 +20,7 @@ // MODULES // -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isInfinitef = require( '@stdlib/math/base/assert/is-infinitef' ); var pow = require( '@stdlib/math/base/special/pow' ); var absf = require( '@stdlib/math/base/special/absf' ); @@ -66,8 +66,8 @@ function ceilnf( x, n ) { var s; var y; if ( - isnan( x ) || - isnan( n ) || + isnanf( x ) || + isnanf( n ) || isInfinitef( n ) ) { return NaN; @@ -90,7 +90,7 @@ function ceilnf( x, n ) { // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. if ( n > MAX_EXP ) { if ( x <= 0.0 ) { - return -0.0; // preserve the sign (same behavior as ceil) + return -0.0; // preserve the sign (same behavior as ceilf) } return PINF; } diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json index 22b2b45833ae..6dada02bbcb3 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json @@ -41,7 +41,7 @@ "@stdlib/math/base/napi/binary", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", - "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/constants/float32/max-base10-exponent", "@stdlib/constants/float32/min-base10-exponent", @@ -65,7 +65,7 @@ "dependencies": [ "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", - "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/constants/float32/max-base10-exponent", "@stdlib/constants/float32/min-base10-exponent", @@ -89,7 +89,7 @@ "dependencies": [ "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", - "@stdlib/math/base/assert/is-nan", + "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/constants/float32/max-base10-exponent", "@stdlib/constants/float32/min-base10-exponent", diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c index cba7da9d0fb9..68e7ec007254 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c @@ -19,7 +19,7 @@ #include "stdlib/math/base/special/ceilnf.h" #include "stdlib/math/base/special/ceilf.h" #include "stdlib/math/base/special/absf.h" -#include "stdlib/math/base/assert/is_nan.h" +#include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/assert/is_infinitef.h" #include "stdlib/constants/float32/max_base10_exponent.h" #include "stdlib/constants/float32/min_base10_exponent.h" @@ -63,7 +63,7 @@ static const float HUGE_VALUE = 1.0e+308f; float stdlib_base_ceilnf( const float x, const int32_t n ) { float s; float y; - if ( stdlib_base_is_nan( x ) ) { + if ( stdlib_base_is_nanf( x ) ) { return x; } if ( diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js index efb7cf3ac4bf..73e71610d454 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js @@ -29,7 +29,7 @@ var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); var absf = require( '@stdlib/math/base/special/absf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var ceilnf = require( './../lib' ); @@ -47,13 +47,13 @@ tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { var v; v = ceilnf( NaN, -2 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = ceilnf( 12368.0, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = ceilnf( NaN, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -62,10 +62,10 @@ tape( 'the function returns `NaN` if provided `n = +-infinity`', function test( var v; v = ceilnf( PI, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = ceilnf( PI, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.native.js index abc39b492cac..be8e8600b828 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.native.js @@ -30,7 +30,7 @@ var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var pow = require( '@stdlib/math/base/special/pow' ); var absf = require( '@stdlib/math/base/special/absf' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); var isNegativeZero = require( '@stdlib/math/base/assert/is-negative-zero' ); var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -56,13 +56,13 @@ tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { var v; v = ceilnf( NaN, -2 ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = ceilnf( 12368.0, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = ceilnf( NaN, NaN ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); @@ -71,10 +71,10 @@ tape( 'the function returns `NaN` if provided `n = +-infinity`', opts, function var v; v = ceilnf( PI, PINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); v = ceilnf( PI, NINF ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.strictEqual( isnanf( v ), true, 'returns NaN' ); t.end(); }); From ff55505e26d6c79cdba3d782cd1ef2ec7a6a30f5 Mon Sep 17 00:00:00 2001 From: Neerajpathak07 Date: Tue, 28 Jan 2025 13:43:26 +0530 Subject: [PATCH 9/9] chore: minor clean up --- .../math/base/special/ceilnf/README.md | 30 +++++-------------- .../special/ceilnf/benchmark/c/benchmark.c | 4 +-- .../math/base/special/ceilnf/docs/repl.txt | 4 +-- .../base/special/ceilnf/docs/types/index.d.ts | 2 +- .../include/stdlib/math/base/special/ceilnf.h | 2 +- .../math/base/special/ceilnf/lib/index.js | 2 +- .../math/base/special/ceilnf/lib/main.js | 6 ++-- .../math/base/special/ceilnf/lib/native.js | 2 +- .../math/base/special/ceilnf/manifest.json | 3 ++ .../math/base/special/ceilnf/package.json | 4 +-- .../math/base/special/ceilnf/src/addon.c | 1 + .../math/base/special/ceilnf/src/ceilnf.c | 15 +++++----- .../math/base/special/ceilnf/tests/test.js | 2 +- 13 files changed, 34 insertions(+), 43 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md index 27820fb122f1..e740c1eaf253 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/README.md @@ -20,7 +20,7 @@ limitations under the License. # ceilnf -> Round a numeric value to the nearest multiple of 10^n toward positive infinity. +> Round a single-precision floating-point numeric value to the nearest multiple of 10^n toward positive infinity.
@@ -32,7 +32,7 @@ var ceilnf = require( '@stdlib/math/base/special/ceilnf' ); #### ceilnf( x, n ) -Rounds a `numeric` value to the nearest multiple of `10^n` toward positive infinity. +Rounds a single-precision floating-point `numeric` value to the nearest multiple of `10^n` toward positive infinity. ```javascript // Round a value to 2 decimal places: @@ -126,20 +126,12 @@ for ( i = 0; i < 100; i++ ) { #### stdlib_base_ceilnf( x, n ) -Rounds a single-precision floating-point number to the nearest multiple of `10^n` toward positive infinity. +Rounds a single-precision floating-point numeric value to the nearest multiple of 10^n toward positive infinity. ```c // Round a value to 2 decimal places: float y = stdlib_base_ceilnf( 3.141592653589793f, -2f ); // returns 3.15f - -// If n = 0, `ceilnf` behaves like `ceil`: -float y = stdlib_base_ceilnf( 3.141592653589793f, 0f ); -// returns 4.0f - -// Round a value to the nearest thousand: -float y = stdlib_base_ceilnf( 12368.0f, 3f ); -// returns 13000.0f ``` The function accepts the following arguments: @@ -174,7 +166,7 @@ float stdlib_base_ceilnf( const float x, const int32_t n ); #include int main( void ) { - const float x[] = { 3.14f, -3.14f, 0.0f, 0.0/0.0 }; + const float x[] = { 3.14f, -3.14f, 0.0f, 0.0f/0.0f }; float y; int i; @@ -201,10 +193,8 @@ int main( void ) { ## See Also -- [`@stdlib/math/base/special/ceil`][@stdlib/math/base/special/ceil]: round a double-precision floating-point number toward positive infinity. -- [`@stdlib/math/base/special/ceilb`][@stdlib/math/base/special/ceilb]: round a numeric value to the nearest multiple of b^n toward positive infinity. -- [`@stdlib/math/base/special/floorn`][@stdlib/math/base/special/floorn]: round a double-precision floating-point number to the nearest multiple of 10^n toward negative infinity. -- [`@stdlib/math/base/special/roundn`][@stdlib/math/base/special/roundn]: round a double-precision floating-point number to the nearest multiple of 10^n. +- [`@stdlib/math/base/special/ceilf`][@stdlib/math/base/special/ceilf]: Rounds a single-precision floating-point number toward positive infinity. +- [`@stdlib/math/base/special/ceiln`][@stdlib/math/base/special/ceiln]: Rounds a numeric value to the nearest multiple of 10^n toward positive infinity.
@@ -218,13 +208,9 @@ int main( void ) { -[@stdlib/math/base/special/ceil]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ceil - -[@stdlib/math/base/special/ceilb]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ceilb - -[@stdlib/math/base/special/floorn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/floorn +[@stdlib/math/base/special/ceilf]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ceilf -[@stdlib/math/base/special/roundn]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/roundn +[@stdlib/math/base/special/ceiln]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ceiln diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c index f2e5a24127fc..36b0d4bff2dc 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/benchmark/c/benchmark.c @@ -91,14 +91,14 @@ static float rand_float( void ) { */ static double benchmark( void ) { double elapsed; - float x; + float x; float y; double t; int i; t = tic(); for ( i = 0; i < ITERATIONS; i++ ) { - x = ( 1000.0*rand_float() ) - 500.0f; + x = ( 1000.0f*rand_float() ) - 500.0f; y = stdlib_base_ceilnf( x, -2 ); if ( y != y ) { printf( "should not return NaN\n" ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt index 52433a415774..86387b4a9ee2 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/repl.txt @@ -1,7 +1,7 @@ {{alias}}( x, n ) - Rounds a numeric value to the nearest multiple of `10^n` toward positive - infinity. + Rounds a single-precision floating-point numeric value to the nearest + multiple of `10^n` toward positive infinity. When operating on single-precision floating-point numbers in bases other than `2`, rounding to specified digits can be inexact. diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/index.d.ts index 6ebdc28bc583..8139e1a5b8c9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/docs/types/index.d.ts @@ -19,7 +19,7 @@ // TypeScript Version: 4.1 /** -* Rounds a numeric value to the nearest multiple of `10^n` toward positive infinity. +* Rounds a single-precision floating-point numeric value to the nearest multiple of `10^n` toward positive infinity. * * ## Notes * diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/include/stdlib/math/base/special/ceilnf.h b/lib/node_modules/@stdlib/math/base/special/ceilnf/include/stdlib/math/base/special/ceilnf.h index b243668cb84e..f5c4a3ab15e9 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/include/stdlib/math/base/special/ceilnf.h +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/include/stdlib/math/base/special/ceilnf.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +* Rounds a single-precision floating-point numeric value to the nearest multiple of 10^n toward positive infinity. */ float stdlib_base_ceilnf( const float x, const int32_t n ); diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js index 1e0ec5a7f812..6839a04ed5d3 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/index.js @@ -19,7 +19,7 @@ 'use strict'; /** -* Round a numeric value to the nearest multiple of `10^n` toward positive infinity. +* Round a single-precision floating-point numeric value to the nearest multiple of `10^n` toward positive infinity. * * @module @stdlib/math/base/special/ceilnf * diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js index 15da15754ceb..3088856ebed2 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/main.js @@ -35,13 +35,13 @@ var PINF = require( '@stdlib/constants/float32/pinf' ); // VARIABLES // var MAX_INT = MAX_SAFE_INTEGER + 1; -var HUGE = 1.0e+308; +var HUGE = 1.0e+38; // MAIN // /** -* Rounds a numeric value to the nearest multiple of \\(10^n\\) toward positive infinity. +* Rounds a single-precision floating-point numeric value to the nearest multiple of \\(10^n\\) toward positive infinity. * * @param {number} x - input value * @param {integer} n - integer power of 10 @@ -87,7 +87,7 @@ function ceilnf( x, n ) { ) { return x; } - // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. + // The maximum absolute double is ~1.8e38. Accordingly, any possible positive finite `x` rounded to the nearest >=10^39 is infinity and any negative finite `x` is zero. if ( n > MAX_EXP ) { if ( x <= 0.0 ) { return -0.0; // preserve the sign (same behavior as ceilf) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js index b10b9ffc2e19..5ed85c249612 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/lib/native.js @@ -26,7 +26,7 @@ var addon = require( './../src/addon.node' ); // MAIN // /** -* Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +* Rounds a single-precision floating-point numeric value to the nearest multiple of \\(10^n\\) toward positive infinity. * * @private * @param {number} x - input value diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json index 6dada02bbcb3..31a75e700854 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/manifest.json @@ -41,6 +41,7 @@ "@stdlib/math/base/napi/binary", "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/special/pow", "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/constants/float32/max-base10-exponent", @@ -65,6 +66,7 @@ "dependencies": [ "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/special/pow", "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/constants/float32/max-base10-exponent", @@ -89,6 +91,7 @@ "dependencies": [ "@stdlib/math/base/special/absf", "@stdlib/math/base/special/ceilf", + "@stdlib/math/base/special/pow", "@stdlib/math/base/assert/is-nanf", "@stdlib/math/base/assert/is-infinitef", "@stdlib/constants/float32/max-base10-exponent", diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json index c2fda643e8c9..03c4ec82f510 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/package.json @@ -1,7 +1,7 @@ { "name": "@stdlib/math/base/special/ceilnf", "version": "0.0.0", - "description": "Round a numeric value to the nearest multiple of 10^n toward positive infinity.", + "description": "Round a single-precision floating-point numeric value to the nearest multiple of 10^n toward positive infinity.", "license": "Apache-2.0", "author": { "name": "The Stdlib Authors", @@ -55,7 +55,7 @@ "stdmath", "mathematics", "math", - "math.ceil", + "math.ceilf", "ceilf", "ceilnf", "round", diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/addon.c index 348cfc8c5927..5033b78d2ad0 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/addon.c @@ -19,4 +19,5 @@ #include "stdlib/math/base/special/ceilnf.h" #include "stdlib/math/base/napi/binary.h" +// cppcheck-suppress shadowFunction STDLIB_MATH_BASE_NAPI_MODULE_FI_F( stdlib_base_ceilnf ) diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c index 68e7ec007254..63aa2063133a 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/src/ceilnf.c @@ -19,6 +19,7 @@ #include "stdlib/math/base/special/ceilnf.h" #include "stdlib/math/base/special/ceilf.h" #include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/special/pow.h" #include "stdlib/math/base/assert/is_nanf.h" #include "stdlib/math/base/assert/is_infinitef.h" #include "stdlib/constants/float32/max_base10_exponent.h" @@ -33,13 +34,13 @@ // VARIABLES // static const float MAX_INT = STDLIB_CONSTANT_FLOAT32_MAX_SAFE_INTEGER + 1.0f; -static const float HUGE_VALUE = 1.0e+308f; +static const float HUGE_VALUE = 1.0e+38f; // MAIN // /** -* Rounds a single-precision floating-point number to the nearest multiple of \\(10^n\\) toward positive infinity. +* Rounds a single-precision floating-point numeric value to the nearest multiple of 10^n toward positive infinity. * * @param x input value * @param n integer power of 10 @@ -51,7 +52,7 @@ static const float HUGE_VALUE = 1.0e+308f; * // returns 3.15f * * @example -* // If n = 0, `ceilnf` behaves like `ceil`: +* // If n = 0, `ceilnf` behaves like `ceilf`: * float y = stdlib_base_ceilnf( 3.141592653589793f, 0f ); * // returns 4.0f * @@ -81,23 +82,23 @@ float stdlib_base_ceilnf( const float x, const int32_t n ) { ) { return x; } - // The maximum absolute double is ~1.8e308. Accordingly, any possible positive finite `x` rounded to the nearest >=10^309 is infinity and any negative finite `x` is zero. + // The maximum absolute float is ~1.8e38. Accordingly, any possible positive finite `x` rounded to the nearest >=10^39 is infinity and any negative finite `x` is zero. if ( n > STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) { if ( x <= 0.0f ) { - return -0.0f; // preserve the sign (same behavior as ceil) + return -0.0f; // preserve the sign (same behavior as ceilf) } return STDLIB_CONSTANT_FLOAT32_PINF; } // If we overflow, return `x`, as the number of digits to the right of the decimal is too small (i.e., `x` is too large / lacks sufficient fractional precision) for there to be any effect when rounding... if ( n < STDLIB_CONSTANT_FLOAT32_MIN_BASE10_EXPONENT ) { - s = pow( 10.0f, -( n + STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent + s = stdlib_base_pow( 10.0f, -( n + STDLIB_CONSTANT_FLOAT32_MAX_BASE10_EXPONENT ) ); // TODO: replace use of `pow` once have stdlib equivalent y = ( x * HUGE_VALUE ) * s; // order of operation matters! if ( stdlib_base_is_infinitef( y ) ) { return x; } return ( stdlib_base_ceilf( y ) / HUGE_VALUE ) / s; } - s = pow( 10.0f, -n ); // TODO: replace use of `pow` once have stdlib equivalent + s = stdlib_base_pow( 10.0f, -n ); // TODO: replace use of `pow` once have stdlib equivalent y = x * s; if ( stdlib_base_is_infinitef( y ) ) { return x; diff --git a/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js index 73e71610d454..2e47c84ccde4 100644 --- a/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js +++ b/lib/node_modules/@stdlib/math/base/special/ceilnf/tests/test.js @@ -246,7 +246,7 @@ tape( 'the function supports rounding very small numbers (including subnormals)' t.strictEqual( v, expected[ i ], 'returns '+expected[i]+' when provided x='+x+' and n='+n[i]+'.' ); } else { delta = absf( v - expected[i] ); - tol = EPS * absf( expected[i] ); + tol = 2.0 * EPS * absf( expected[i] ); t.strictEqual( delta <= tol, true, 'x: '+x+'. n: '+n[i]+'. v: '+v+'. expected: '+expected[i]+'. delta: '+delta+'. tol: '+tol ); } }