From 17eec0807b13852876fe6e951986054975b67b6a Mon Sep 17 00:00:00 2001 From: Aadish Jain Date: Fri, 10 Jan 2025 15:48:25 +0000 Subject: [PATCH 1/6] feat(special-wrapf): adding implementation --- .../base/special/wrapf/benchmark/benchmark.js | 51 ++++ .../wrapf/benchmark/benchmark.native.js | 60 +++++ .../base/special/wrapf/benchmark/c/Makefile | 127 ++++++++++ .../special/wrapf/benchmark/c/benchmark.c | 153 ++++++++++++ .../special/wrapf/benchmark/c/native/Makefile | 146 +++++++++++ .../wrapf/benchmark/c/native/benchmark.c | 133 ++++++++++ .../math/base/special/wrapf/binding.gyp | 170 +++++++++++++ .../math/base/special/wrapf/docs/repl.txt | 43 ++++ .../base/special/wrapf/docs/types/index.d.ts | 62 +++++ .../base/special/wrapf/docs/types/test.ts | 57 +++++ .../base/special/wrapf/examples/c/Makefile | 146 +++++++++++ .../base/special/wrapf/examples/c/example.c | 33 +++ .../math/base/special/wrapf/examples/index.js | 34 +++ .../math/base/special/wrapf/include.gypi | 53 ++++ .../include/stdlib/math/base/special/wrapf.h | 38 +++ .../math/base/special/wrapf/lib/index.js | 64 +++++ .../math/base/special/wrapf/lib/main.js | 101 ++++++++ .../math/base/special/wrapf/lib/native.js | 72 ++++++ .../math/base/special/wrapf/manifest.json | 82 +++++++ .../math/base/special/wrapf/package.json | 65 +++++ .../math/base/special/wrapf/src/Makefile | 70 ++++++ .../math/base/special/wrapf/src/addon.c | 23 ++ .../math/base/special/wrapf/src/main.c | 70 ++++++ .../math/base/special/wrapf/test/test.js | 221 +++++++++++++++++ .../base/special/wrapf/test/test.native.js | 230 ++++++++++++++++++ 25 files changed, 2304 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js new file mode 100644 index 000000000000..362886d461df --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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-nanf' ); +var pkg = require( './../package.json' ).name; +var wrapf = 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()*20.0 ) - 10.0; + y = wrapf( x, -5.0, 5.0 ); + 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/wrapf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..f541fafd953b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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-nanf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var wrapf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( wrapf 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()*20.0 ) - 10.0; + y = wrapf( x, -5.0, 5.0 ); + 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/wrapf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile new file mode 100644 index 000000000000..e64c0050f3da --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile @@ -0,0 +1,127 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2018 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 C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles C source files. +# +# @param {string} [C_COMPILER] - C compiler +# @param {string} [CFLAGS] - C compiler flags +# @param {(string|void)} [fPIC] - compiler flag indicating whether to generate position independent code +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler +# @param {string} CFLAGS - C compiler flags +# @param {(string|void)} fPIC - compiler flag indicating whether to generate position independent code +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) -o $@ $< -lm + +#/ +# 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/wrapf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c new file mode 100644 index 000000000000..192e253a7b58 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c @@ -0,0 +1,153 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 +#include +#include +#include +#include + +#define NAME "wrapf" +#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( float elapsed ) { + float rate = (float)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 float tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (float)now.tv_sec + (float)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.0 ); +} + +/** +* Wraps a value within a specified range. +* +* @param v value to wrap +* @param min minimum value +* @param max maximum value +* @return wrapped value +*/ +float wrapf( float v, float min, float max ) { + float delta; + if ( min <= v && v < max ) { + return v; + } + // Perform range reduction... + delta = max - min; + if ( v < min ) { + v += delta * ( trunc( (min-v)/delta ) + 1.0 ); + } + return min + fmod( (v-min), delta ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static float benchmark( void ) { + float elapsed; + float x; + float y; + float t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( 20.0*rand_float() ) - 10.0; + y = wrapf( x, -5.0, 5.0 ); + 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 ) { + float 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/wrapf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..d6b58c7f5d3e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/wrapf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..361143f7e8aa --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c @@ -0,0 +1,133 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/wrapf.h" +#include +#include +#include +#include +#include + +#define NAME "wrapf" +#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( float elapsed ) { + float rate = (float)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 float tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (float)now.tv_sec + (float)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.0 ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static float benchmark( void ) { + float elapsed; + float x; + float y; + float t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( 20.0*rand_float() ) - 10.0; + y = stdlib_base_wrapf( x, -5.0, 5.0 ); + 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 ) { + float 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/wrapf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp new file mode 100644 index 000000000000..1058b57bab16 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/wrapf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/repl.txt new file mode 100644 index 000000000000..4400433a093b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/repl.txt @@ -0,0 +1,43 @@ + +{{alias}}( v, min, max ) + Wraps a value on the half-open interval `[min,max)`. + + The function does not distinguish between positive and negative zero. Where + appropriate, the function returns positive zero. + + If provided `NaN` for any argument, the function returns `NaN`. + + Parameters + ---------- + v: number + Value to wrap. + + min: number + Minimum value. + + max: number + Maximum value. + + Returns + ------- + y: number + Wrapped value. + + Examples + -------- + > var y = {{alias}}( 3.14, 0.0, 5.0 ) + ~3.14 + > y = {{alias}}( -3.14, 0.0, 5.0 ) + ~1.86 + > y = {{alias}}( 3.14, 0.0, 3.0 ) + ~0.14 + > y = {{alias}}( -0.0, 0.0, 5.0 ) + 0.0 + > y = {{alias}}( 0.0, -3.14, -0.0 ) + ~-3.14 + > y = {{alias}}( NaN, 0.0, 5.0 ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts new file mode 100644 index 000000000000..e28fdd7ccccb --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts @@ -0,0 +1,62 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Wraps a value on the half-open interval `[min,max)`. +* +* @param v - input value +* @param min - minimum value +* @param max - maximum value +* @returns wrapped value +* +* @example +* var v = wrapf( 3.14, 0.0, 5.0 ); +* // returns 3.14 +* +* v = wrapf( -3.14, 0.0, 5.0 ); +* // returns ~1.86 +* +* v = wrapf( 10.0, 0.0, 5.0 ); +* // returns 0.0 +* +* v = wrapf( -0.0, 0.0, 5.0 ); +* // returns 0.0 +* +* v = wrapf( 0.0, -0.0, 5.0 ); +* // returns 0.0 +* +* v = wrapf( NaN, 0.0, 5.0 ); +* // returns NaN +* +* v = wrapf( 0.0, NaN, 5.0 ); +* // returns NaN +* +* v = wrapf( 3.14, 0.0, NaN ); +* // returns NaN +* +* v = wrapf( 3.14, 5.0, 0.0 ); +* // returns NaN +*/ +declare function wrapf( v: number, min: number, max: number ): number; + + +// EXPORTS // + +export = wrapf; diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts new file mode 100644 index 000000000000..ce2a0c2f0d06 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts @@ -0,0 +1,57 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import wrapf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + wrapf( -3, 0, 10 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided values other than three numbers... +{ + wrapf( true, 3, 2 ); // $ExpectError + wrapf( false, 2, 2 ); // $ExpectError + wrapf( '5', 1, 2 ); // $ExpectError + wrapf( [], 1, 2 ); // $ExpectError + wrapf( {}, 2, 2 ); // $ExpectError + wrapf( ( x: number ): number => x, 2, 2 ); // $ExpectError + + wrapf( 9, true, 2 ); // $ExpectError + wrapf( 9, false, 2 ); // $ExpectError + wrapf( 5, '5', 2 ); // $ExpectError + wrapf( 8, [], 2 ); // $ExpectError + wrapf( 9, {}, 2 ); // $ExpectError + wrapf( 8, ( x: number ): number => x, 2 ); // $ExpectError + + wrapf( 3.12, 2, true ); // $ExpectError + wrapf( 4.9, 2, false ); // $ExpectError + wrapf( 2.1, 2, '5' ); // $ExpectError + wrapf( 2.9323213, 2, [] ); // $ExpectError + wrapf( 9.343, 2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided insufficient arguments... +{ + wrapf(); // $ExpectError + wrapf( 3 ); // $ExpectError + wrapf( 2.131, 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile new file mode 100644 index 000000000000..91d364d19fc3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/wrapf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c new file mode 100644 index 000000000000..c1537009d439 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/wrapf.h" +#include + +int main( void ) { + const float min[] = { 0.0, 0.0, 0.0, 0.0, -3.14 }; + const float max[] = { 5.0, 5.0, 5.0, 5.0, -0.0 }; + const float v[] = { 3.14, -3.14, 10.0, -0.0, 0.0 }; + + float out; + int i; + for ( i = 0; i < 5; i++ ) { + out = stdlib_base_wrapf( v[i], min[i], max[i] ); + printf( "wrap(%f,%f,%f) => %f\n", v[i], min[i], max[i], out ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js new file mode 100644 index 000000000000..884ca1f1399f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 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 discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var wrapf = require( './../lib' ); + +var min; +var max; +var v; +var i; + +for ( i = 0; i < 100; i++ ) { + min = discreteUniform( 0.0, 10.0 ); + max = discreteUniform( 5.0, 15.0 ); + v = discreteUniform( -20.0, 20.0 ); + console.log( 'wrap(%d,%d,%d) => %d', v, min, max, wrapf( v, min, max ) ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi b/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi new file mode 100644 index 000000000000..3b437d524797 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2022 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': [ + '=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "wrapf", + "modulo", + "mod", + "range", + "interval" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile new file mode 100644 index 000000000000..f79b87238713 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2022 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/wrapf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c new file mode 100644 index 000000000000..6916c673a3a2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c @@ -0,0 +1,23 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/wrapf.h" +#include "stdlib/math/base/napi/ternary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_FFF_F( stdlib_base_wrapf ) diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c b/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c new file mode 100644 index 000000000000..c19fb6f2a74e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c @@ -0,0 +1,70 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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/wrapf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/special/truncf.h" +#include "stdlib/math/base/special/fmodf.h" +#include "stdlib/math/base/assert/is_negative_zerof.h" + +/** +* Wraps a value on the half-open interval [min,max). +* +* @param v input value +* @param min minimum value +* @param max maximum value +* @return wrapped value +* +* @example +* float v = stdlib_base_wrap( 3.14, 0.0, 5.0 ); +* // returns 3.14 +*/ +float stdlib_base_wrapf( const float v, const float min, const float max ) { + float delta; + float maxc; + float minc; + float vc; + + if ( stdlib_base_is_nanf( v ) || stdlib_base_is_nanf( min ) || stdlib_base_is_nanf( max ) || max <= min ) { + return 0.0 / 0.0; // NaN + } + maxc = max; + minc = min; + vc = v; + + // Normalize +-0 to +0... + if ( stdlib_base_is_negative_zerof( vc ) ) { + vc = 0.0; + } + if ( stdlib_base_is_negative_zerof( minc ) ) { + minc = 0.0; + } + if ( stdlib_base_is_negative_zerof( maxc ) ) { + maxc = 0.0; + } + // Simple case where value is already within range... + if ( minc <= vc && vc < maxc ) { + return vc; + } + // Perform range reduction... + delta = maxc - minc; + if ( vc < minc ) { + vc += delta * ( stdlib_base_truncf( ( minc - vc ) / delta ) + 1.0 ); + } + return minc + ( stdlib_base_fmodf( vc - minc, delta ) ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js new file mode 100644 index 000000000000..b4a710a7f145 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js @@ -0,0 +1,221 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nanf' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var abs = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var wrapf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof wrapf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any argument, the function returns `NaN`', function test( t ) { + var v; + + v = wrapf( NaN, 0.0, 5.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( 0.0, NaN, 5.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( 3.14, 0.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( NaN, NaN, 5.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( NaN, 0.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( 3.14, NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( NaN, NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided a value which is between a minimum value (inclusive) and a maximum value (exclusive), the function returns the input value', function test( t ) { + var expected; + var delta; + var tol; + var v; + + expected = 3.14; + v = wrapf( 3.14, 0.0, 5.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: '+v+'. expected: '+expected+'. Δ: '+delta+'. tol: '+tol+'.' ); + } + expected = -3.14; + v = wrapf( -3.14, -10.0, 15.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + expected = 3.14; + v = wrapf( 3.14, 3.14, 5.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + expected = 3.13; + v = wrapf( 3.13, 0.0, 3.14 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + t.end(); +}); + +tape( 'if provided a value which less than a minimum value or greater than or equal to a maximum value, the function wraps the value using modulo arithmetic', function test( t ) { + var expected; + var delta; + var tol; + var v; + + v = wrapf( 13.00, 0.0, 5.0 ); + t.strictEqual( v, 3.00, 'returns expected value' ); + + expected = 1.85; + v = wrapf( -3.15, 0.0, 5.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.ok( delta <= tol, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + expected = 11.86; + v = wrapf( -13.14, -10.0, 15.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.ok( delta <= tol, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + v = wrapf( 10.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( -10.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( -30.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( -30.0, -5.0, 0.0 ); + t.strictEqual( v, -5.0, 'returns expected value' ); + + v = wrapf( 30.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( 31.0, 0.0, 5.0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + v = wrapf( -31.0, -5.0, 0.0 ); + t.strictEqual( v, -1.0, 'returns expected value' ); + + expected = -3.14; + v = wrapf( 0.0, -3.14, 0.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.ok( delta <= tol, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + v = wrapf( 0.0, -10.0, -0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + v = wrapf( -0.0, -10.0, 0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + v = wrapf( 0.0, -10.0, 0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + v = wrapf( -0.0, -10.0, -0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function does not distinguish between positive and negative zero', function test( t ) { + var v; + + v = wrapf( -0.0, 0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = wrapf( 0.0, -0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = wrapf( -0.0, -0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = wrapf( 0.0, 0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if provided a maximum value which is less than or equal to a minimum value', function test( t ) { + var v; + + v = wrapf( 3.14, 10.0, 0.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = wrapf( 3.14, 10.0, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = wrapf( 3.14, 3.0, 1.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = wrapf( 3.14, 1.0, 1.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js new file mode 100644 index 000000000000..2b94249037b2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js @@ -0,0 +1,230 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 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 abs = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var isnan = require( '@stdlib/math/base/assert/is-nanf' ); +var isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var wrapf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( wrapf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof wrapf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'if provided `NaN` for any argument, the function returns `NaN`', opts, function test( t ) { + var v; + + v = wrapf( NaN, 0.0, 5.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( 0.0, NaN, 5.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( 3.14, 0.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( NaN, NaN, 5.0 ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( NaN, 0.0, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( 3.14, NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + v = wrapf( NaN, NaN, NaN ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'if provided a value which is between a minimum value (inclusive) and a maximum value (exclusive), the function returns the input value', opts, function test( t ) { + var expected; + var delta; + var tol; + var v; + + expected = 3.14; + v = wrapf( 3.14, 0.0, 5.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + expected = -3.14; + v = wrapf( -3.14, -10.0, 15.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + expected = 3.14; + v = wrapf( 3.14, 3.14, 5.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + expected = 3.13; + v = wrapf( 3.13, 0.0, 3.14 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.equal( delta <= tol, true, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + t.end(); +}); + +tape( 'if provided a value which less than a minimum value or greater than or equal to a maximum value, the function wraps the value using modulo arithmetic', opts, function test( t ) { + var expected; + var delta; + var tol; + var v; + + v = wrapf( 13.00, 0.0, 5.0 ); + t.strictEqual( v, 3.00, 'returns expected value' ); + + expected = 1.85; + v = wrapf( -3.15, 0.0, 5.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.ok( delta <= tol, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + expected = 11.86; + v = wrapf( -13.14, -10.0, 15.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.ok( delta <= tol, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + v = wrapf( 10.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( -10.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( -30.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( -30.0, -5.0, 0.0 ); + t.strictEqual( v, -5.0, 'returns expected value' ); + + v = wrapf( 30.0, 0.0, 5.0 ); + t.strictEqual( v, 0.0, 'returns expected value' ); + + v = wrapf( 31.0, 0.0, 5.0 ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + v = wrapf( -31.0, -5.0, 0.0 ); + t.strictEqual( v, -1.0, 'returns expected value' ); + + expected = -3.14; + v = wrapf( 0.0, -3.14, 0.0 ); + if ( v === expected ) { + t.equal( v, expected, 'returns expected value' ); + } else { + delta = abs( v - expected ); + tol = EPS * abs( expected ); + t.ok( delta <= tol, 'within tolerance. v: ' + v + '. expected: ' + expected + '. Δ: ' + delta + '. tol: ' + tol + '.' ); + } + + v = wrapf( 0.0, -10.0, -0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + v = wrapf( -0.0, -10.0, 0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + v = wrapf( 0.0, -10.0, 0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + v = wrapf( -0.0, -10.0, -0.0 ); + t.strictEqual( v, -10.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function does not distinguish between positive and negative zero', opts, function test( t ) { + var v; + + v = wrapf( -0.0, 0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = wrapf( 0.0, -0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = wrapf( -0.0, -0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + v = wrapf( 0.0, 0.0, 5.0 ); + t.strictEqual( isPositiveZero( v ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `NaN` if provided a maximum value which is less than or equal to a minimum value', opts, function test( t ) { + var v; + + v = wrapf( 3.14, 10.0, 0.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = wrapf( 3.14, 10.0, 10.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = wrapf( 3.14, 3.0, 1.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + v = wrapf( 3.14, 1.0, 1.0 ); + t.strictEqual( isnan( v ), true, 'returns expected value' ); + + t.end(); +}); From e51113436f7a88ca0a3124df27f2c1e64f30e482 Mon Sep 17 00:00:00 2001 From: Aadish Jain Date: Fri, 10 Jan 2025 15:54:23 +0000 Subject: [PATCH 2/6] feat(special-wrapf): adding readme --- .../@stdlib/math/base/special/wrapf/README.md | 255 ++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/wrapf/README.md diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/README.md b/lib/node_modules/@stdlib/math/base/special/wrapf/README.md new file mode 100644 index 000000000000..a17e578f07b8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/README.md @@ -0,0 +1,255 @@ + + +# wrapf + +> Wrap a value on the half-open interval `[min,max)`. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var wrapf = require( '@stdlib/math/base/special/wrapf' ); +``` + +#### wrapf( v, min, max ) + +Wraps a value on the half-open interval `[min,max)`. + +```javascript +var v = wrapf( 3.14, 0.0, 5.0 ); +// returns ~3.14 + +v = wrapf( -3.14, 0.0, 5.0 ); +// returns ~1.86 + +v = wrapf( 10.0, 0.0, 5.0 ); +// returns 0.0 + +v = wrapf( -0.0, 0.0, 5.0 ); +// returns 0.0 + +v = wrapf( 0.0, -3.14, -0.0 ); +// returns ~-3.14 +``` + +If provided `NaN` for any argument, the function returns `NaN`. + +```javascript +var v = wrapf( NaN, 0.0, 5.0 ); +// returns NaN + +v = wrapf( 0.0, NaN, 5.0 ); +// returns NaN + +v = wrapf( 3.14, 0.0, NaN ); +// returns NaN +``` + +If provided `min == max`, the function returns `NaN`. + +```javascript +var v = wrapf( 3.14, 3.0, 3.0 ); +// returns NaN +``` + +
+ + + + + +
+ +## Notes + +- The function does **not** distinguish between positive and negative zero. Where appropriate, the function returns positive zero. + +
+ + + + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var wrapf = require( '@stdlib/math/base/special/wrapf' ); + +var min; +var max; +var v; +var i; + +for ( i = 0; i < 100; i++ ) { + min = discreteUniform( 0.0, 10.0 ); + max = discreteUniform( 5.0, 15.0 ); + v = discreteUniform( -20.0, 20.0 ); + console.log( 'wrapf(%d,%d,%d) => %d', v, min, max, wrapf( v, min, max ) ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/wrapf.h" +``` + +#### stdlib_base_wrapf( v, min, max ) + +Wraps a value on the half-open interval `[min,max)`. + +```c +float v = stdlib_base_wrapf( 3.14, 0.0, 5.0 ); +// returns ~3.14 + +v = stdlib_base_wrapf( -3.14, 0.0, 5.0 ); +// returns ~1.86 +``` + +The function accepts the following arguments: + +- **v**: `[in] float` input value to wrap. +- **min**: `[in] float` minimum value. +- **max**: `[in] float` maximum value. + +```c +float stdlib_base_wrapf( const float v, const float min, const float max ) +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/wrapf.h" +#include + +int main( void ) { + const float min[] = { 0.0, 0.0, 0.0, 0.0, -3.14 }; + const float max[] = { 5.0, 5.0, 5.0, 5.0, -0.0 }; + const float v[] = { 3.14, -3.14, 10.0, -0.0, 0.0 }; + + float out; + int i; + for ( i = 0; i < 5; i++ ) { + out = stdlib_base_wrap( v[i], min[i], max[i] ); + printf( "wrap(%f,%f,%f) => %f\n", v[i], min[i], max[i], out ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + From 8de727b613ff66d779dce79b5aa468f84922189c Mon Sep 17 00:00:00 2001 From: Aadish Jain Date: Fri, 10 Jan 2025 21:30:03 +0530 Subject: [PATCH 3/6] Update README.md Signed-off-by: Aadish Jain --- lib/node_modules/@stdlib/math/base/special/wrapf/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/README.md b/lib/node_modules/@stdlib/math/base/special/wrapf/README.md index a17e578f07b8..9ce4b571d8f9 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/README.md @@ -205,7 +205,7 @@ int main( void ) { int i; for ( i = 0; i < 5; i++ ) { out = stdlib_base_wrap( v[i], min[i], max[i] ); - printf( "wrap(%f,%f,%f) => %f\n", v[i], min[i], max[i], out ); + printf( "wrapf(%f,%f,%f) => %f\n", v[i], min[i], max[i], out ); } } ``` From 0057e6060ab1bbb94db668c6923a7827a9823560 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Fri, 10 Jan 2025 16:02:50 +0000 Subject: [PATCH 4/6] chore: update copyright years --- lib/node_modules/@stdlib/math/base/special/wrapf/README.md | 2 +- .../@stdlib/math/base/special/wrapf/benchmark/benchmark.js | 2 +- .../math/base/special/wrapf/benchmark/benchmark.native.js | 2 +- .../@stdlib/math/base/special/wrapf/benchmark/c/Makefile | 2 +- .../@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c | 2 +- .../@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile | 2 +- .../math/base/special/wrapf/benchmark/c/native/benchmark.c | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp | 2 +- .../@stdlib/math/base/special/wrapf/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/wrapf/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/wrapf/examples/c/Makefile | 2 +- .../@stdlib/math/base/special/wrapf/examples/c/example.c | 2 +- .../@stdlib/math/base/special/wrapf/examples/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi | 2 +- .../base/special/wrapf/include/stdlib/math/base/special/wrapf.h | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/lib/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/lib/main.js | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/lib/native.js | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c | 2 +- lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js | 2 +- .../@stdlib/math/base/special/wrapf/test/test.native.js | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/README.md b/lib/node_modules/@stdlib/math/base/special/wrapf/README.md index 9ce4b571d8f9..ce486b85d947 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2022 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js index 362886d461df..cd11bcf5cc59 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js index f541fafd953b..8c7aee9bb296 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/benchmark.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile index e64c0050f3da..d564e8b2d6f9 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c index 192e253a7b58..0dd9fa5df0c6 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile index d6b58c7f5d3e..a4bd7b38fd74 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c index 361143f7e8aa..4a8c8fc7b389 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/benchmark/c/native/benchmark.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp index 1058b57bab16..68a1ca11d160 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/binding.gyp @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts index e28fdd7ccccb..29c6c530b719 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts index ce2a0c2f0d06..482ad7fefb9e 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/docs/types/test.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile index 91d364d19fc3..25ced822f96a 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c index c1537009d439..6b89713ea3e1 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/c/example.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js index 884ca1f1399f..1105d577ab45 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi b/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi index 3b437d524797..ecfaf82a3279 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/include.gypi @@ -1,6 +1,6 @@ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h b/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h index c451626c6734..3cfc1cc75e6c 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/wrapf/lib/index.js index de7b0da93785..f2c01283aa40 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/wrapf/lib/main.js index 6601cafa50b2..ba1a1a454240 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/wrapf/lib/native.js index 327c47838b22..f23adee5644c 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/lib/native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile index f79b87238713..7733b6180cb4 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/Makefile @@ -1,7 +1,7 @@ #/ # @license Apache-2.0 # -# Copyright (c) 2022 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c index 6916c673a3a2..f0c22f25dbbf 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/addon.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c b/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c index c19fb6f2a74e..1dcbc65b6128 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js index b4a710a7f145..aa59e89a1347 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js index 2b94249037b2..7a7ef6eb6728 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/test/test.native.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 9ef2f0901a156eab8116e39d1fa9d2a1442dc0fd Mon Sep 17 00:00:00 2001 From: Aadish Jain Date: Fri, 10 Jan 2025 21:33:55 +0530 Subject: [PATCH 5/6] Update wrapf.h Signed-off-by: Aadish Jain --- .../base/special/wrapf/include/stdlib/math/base/special/wrapf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h b/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h index 3cfc1cc75e6c..ed840f70f75a 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/include/stdlib/math/base/special/wrapf.h @@ -29,7 +29,7 @@ extern "C" { /** * Wraps a value on the half-open interval [min,max). */ -float stdlib_base_wrap( const float v, const float min, const float max ); +float stdlib_base_wrapf( const float v, const float min, const float max ); #ifdef __cplusplus } From 7126246f671ec4f9fe315dab170a1b351f7b8a31 Mon Sep 17 00:00:00 2001 From: Aadish Jain Date: Fri, 10 Jan 2025 23:58:02 +0530 Subject: [PATCH 6/6] Update main.c Signed-off-by: Aadish Jain --- .../@stdlib/math/base/special/wrapf/src/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c b/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c index 1dcbc65b6128..6903e3bdab1e 100644 --- a/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c +++ b/lib/node_modules/@stdlib/math/base/special/wrapf/src/main.c @@ -41,7 +41,7 @@ float stdlib_base_wrapf( const float v, const float min, const float max ) { float vc; if ( stdlib_base_is_nanf( v ) || stdlib_base_is_nanf( min ) || stdlib_base_is_nanf( max ) || max <= min ) { - return 0.0 / 0.0; // NaN + return 0.0f / 0.0f; // NaN } maxc = max; minc = min; @@ -49,13 +49,13 @@ float stdlib_base_wrapf( const float v, const float min, const float max ) { // Normalize +-0 to +0... if ( stdlib_base_is_negative_zerof( vc ) ) { - vc = 0.0; + vc = 0.0f; } if ( stdlib_base_is_negative_zerof( minc ) ) { - minc = 0.0; + minc = 0.0f; } if ( stdlib_base_is_negative_zerof( maxc ) ) { - maxc = 0.0; + maxc = 0.0f; } // Simple case where value is already within range... if ( minc <= vc && vc < maxc ) { @@ -64,7 +64,7 @@ float stdlib_base_wrapf( const float v, const float min, const float max ) { // Perform range reduction... delta = maxc - minc; if ( vc < minc ) { - vc += delta * ( stdlib_base_truncf( ( minc - vc ) / delta ) + 1.0 ); + vc += delta * ( stdlib_base_truncf( ( minc - vc ) / delta ) + 1.0f ); } return minc + ( stdlib_base_fmodf( vc - minc, delta ) ); }