diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md b/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md new file mode 100644 index 000000000000..8d79d49abd0c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md @@ -0,0 +1,242 @@ + + +# minmaxf + +> Return the minimum and maximum of two single-precision floating-point numbers. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var minmaxf = require( '@stdlib/math/base/special/minmaxf' ); +``` + +#### minmaxf( x, y ) + +Returns the minimum and maximum of two single-precision floating-point numbers in a single pass. + +```javascript +var v = minmaxf( 4.2, 3.14 ); +// returns [ 3.14, 4.2 ] + +v = minmaxf( +0.0, -0.0 ); +// returns [ -0.0, +0.0 ] +``` + +If any argument is `NaN`, the function returns `NaN` for both the minimum value and the maximum value. + +```javascript +var v = minmaxf( 4.2, NaN ); +// returns [ NaN, NaN ] + +v = minmaxf( NaN, 3.14 ); +// returns [ NaN, NaN ] +``` + +#### minmaxf.assign( x, y, out, stride, offset ) + +Returns the minimum and maximum of two single-precision floating-point numbers in a single pass and assigns results to a provided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var out = new Float32Array( 2 ); + +var v = minmaxf.assign( 5.0, -2.0, out, 1, 0 ); +// returns [ -2.0, 5.0 ] + +var bool = ( v === out ); +// returns true +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var minstd = require( '@stdlib/random/base/minstd-shuffle' ); +var minmaxf = require( '@stdlib/math/base/special/minmaxf' ); + +var x; +var y; +var v; +var i; + +for ( i = 0; i < 100; i++ ) { + x = minstd(); + y = minstd(); + v = minmaxf( x, y ); + console.log( 'minmaxf(%d,%d) = [%d, %d]', x, y, v[0], v[1] ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/minmaxf.h" +``` + +#### stdlib_base_minmaxf( x, y, &min, &max ) + +Evaluates the minimum and maximum of two single-precision floating-point numbers in a single pass. + +```c +float x = 3.14f; +float y = 2.71f; + +float min; +float max; +stdlib_base_minmaxf( x, y, &min, &max ); +``` + +The function accepts the following arguments: + +- **x**: `[in] float` first number. +- **y**: `[in] float` second number. +- **min**: `[out] float` destination for the minimum value. +- **max**: `[out] float` destination for the maximum value. + +```c +void stdlib_base_minmaxf( const float x, const float y, float* min, float* max ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/minmaxf.h" +#include + +int main( void ) { + const float x[] = { 1.0f, 0.45f, -0.89f, 0.0f / 0.0f, -0.78f, -0.22f, 0.66f, 0.11f, -0.55f, 0.0f }; + const float y[] = { -0.22f, 0.66f, 0.0f, -0.55f, 0.33f, 1.0f, 0.0f / 0.0f, 0.11f, 0.45f, -0.78f }; + + float min; + float max; + int i; + for ( i = 0; i < 10; i++ ) { + stdlib_base_minmaxf( x[ i ], y[ i ], &min, &max ); + printf( "x: %f, y: %f => min: %f, max: %f\n", x[ i ], y[ i ], min, max ); + } +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js new file mode 100644 index 000000000000..8f04dac5a187 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isArray = require( '@stdlib/assert/is-array' ); +var minf = require( '@stdlib/math/base/special/minf' ); +var maxf = require( '@stdlib/math/base/special/maxf' ); +var pkg = require( './../package.json' ).name; +var minmaxf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var z; + var i; + + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + y = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = minmaxf( x[ i%x.length ], y[ i%y.length ] ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isArray( z ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':assign', function benchmark( b ) { + var out; + var x; + var y; + var z; + var i; + + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + y = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + out = [ 0.0, 0.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = minmaxf.assign( x[ i%x.length ], y[ i%y.length ], out, 1, 0 ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isArray( z ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::minf,maxf', function benchmark( b ) { + var x; + var y; + var z; + var i; + + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + y = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + // eslint-disable-next-line max-len + z = [ minf( x[ i%x.length ], y[ i%y.length ] ), maxf( x[ i%x.length ], y[ i%y.length ] ) ]; + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isArray( z ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+'::minf,maxf,memory_reuse', function benchmark( b ) { + var x; + var y; + var z; + var i; + + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + y = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + z = [ 0.0, 0.0 ]; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z[ 0 ] = minf( x[ i%x.length ], y[ i%y.length ] ); + z[ 1 ] = maxf( x[ i%x.length ], y[ i%y.length ] ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isArray( z ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..d337113b61c4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.native.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isFloat32Array = require( '@stdlib/assert/is-float32array' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var minmaxf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( minmaxf instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var z; + var i; + + x = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + y = uniform( 100, -500.0, 500.0, { + 'dtype': 'float32' + }); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = minmaxf( x[ i%x.length ], y[ i%y.length ] ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isFloat32Array( z ) ) { + b.fail( 'should return a Float32Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := benchmark.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled benchmarks. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..71114b855829 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/benchmark.c @@ -0,0 +1,139 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/minmaxf.h" +#include +#include +#include +#include +#include + +#define NAME "minmaxf" +#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 ) { + float x[ 100 ]; + float y[ 100 ]; + double elapsed; + float min; + float max; + double t; + int i; + + for( i = 0; i < 100; i++ ) { + x[ i ] = ( 1000.0f*rand_float() ) - 500.0f; + y[ i ] = ( 1000.0f*rand_float() ) - 500.0f; + } + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + stdlib_base_minmaxf( x[ i%100 ], y[ i%100 ], &min, &max ); + if ( max != max || min != min ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( max != max || min != min ) { + 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::native::%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/minmaxf/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..e907278cfcc2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/benchmark.jl @@ -0,0 +1,144 @@ +#!/usr/bin/env julia +# +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import BenchmarkTools +using Printf + +# Benchmark variables: +name = "minmaxf"; +repeats = 3; + +""" + print_version() + +Prints the TAP version. + +# Examples + +``` julia +julia> print_version() +``` +""" +function print_version() + @printf( "TAP version 13\n" ); +end + +""" + print_summary( total, passing ) + +Print the benchmark summary. + +# Arguments + +* `total`: total number of tests +* `passing`: number of passing tests + +# Examples + +``` julia +julia> print_summary( 3, 3 ) +``` +""" +function print_summary( total, 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" ); +end + +""" + print_results( iterations, elapsed ) + +Print benchmark results. + +# Arguments + +* `iterations`: number of iterations +* `elapsed`: elapsed time (in seconds) + +# Examples + +``` julia +julia> print_results( 1000000, 0.131009101868 ) +``` +""" +function print_results( iterations, elapsed ) + rate = iterations / elapsed + + @printf( " ---\n" ); + @printf( " iterations: %d\n", iterations ); + @printf( " elapsed: %0.9f\n", elapsed ); + @printf( " rate: %0.9f\n", rate ); + @printf( " ...\n" ); +end + +""" + benchmark() + +Run a benchmark. + +# Notes + +* Benchmark results are returned as a two-element array: [ iterations, elapsed ]. +* The number of iterations is not the true number of iterations. Instead, an 'iteration' is defined as a 'sample', which is a computed estimate for a single evaluation. +* The elapsed time is in seconds. + +# Examples + +``` julia +julia> out = benchmark(); +``` +""" +function benchmark() + t = BenchmarkTools.@benchmark minmax( Float32((1000.0 * rand()) - 500.0), Float32((1000.0 * rand()) - 500.0) ) samples=1e6 + + # Compute the total "elapsed" time and convert from nanoseconds to seconds: + s = sum( t.times ) / 1.0e9; + + # Determine the number of "iterations": + iter = length( t.times ); + + # Return the results: + [ iter, s ]; +end + +""" + main() + +Run benchmarks. + +# Examples + +``` julia +julia> main(); +``` +""" +function main() + print_version(); + for i in 1:repeats + @printf( "# julia::%s\n", name ); + results = benchmark(); + print_results( results[ 1 ], results[ 2 ] ); + @printf( "ok %d benchmark finished\n", i ); + end + print_summary( repeats, repeats ); +end + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/minmaxf/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt new file mode 100644 index 000000000000..641e2ce36c6b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt @@ -0,0 +1,70 @@ + +{{alias}}( x, y ) + Returns the minimum and maximum of two single-precision floating-point + numbers. + + If any argument is `NaN`, the function returns `NaN` for both the minimum + and maximum values. + + Parameters + ---------- + x: number + First number. + + y: number + Second number. + + Returns + ------- + out: Array + Minimum and maximum values. + + Examples + -------- + > var v = {{alias}}( 3.14, 4.2 ) + [ 3.14, 4.2 ] + > v = {{alias}}( 3.14, NaN ) + [ NaN, NaN ] + > v = {{alias}}( +0.0, -0.0 ) + [ -0.0, +0.0 ] + + +{{alias}}.assign( x, y, out, stride, offset ) + Returns the minimum and maximum of two single-precision floating-point + numbers and assigns results to a provided output array. + + If any argument is `NaN`, the function returns `NaN` for both the minimum + and maximum values. + + Parameters + ---------- + x: number + First number. + + y: number + Second number. + + out: Array|TypedArray|Object + Output object. + + stride: integer + Output array stride. + + offset: integer + Output array index offset. + + Returns + ------- + out: Array|TypedArray|Object + Minimum and maximum values. + + Examples + -------- + > var out = [ 0.0, 0.0 ]; + > var v = {{alias}}.assign( 3.14, -1.5, out, 1, 0 ) + [ -1.5, 3.14 ] + > var bool = ( v === out ) + true + + See Also + -------- diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/index.d.ts new file mode 100644 index 000000000000..b9daf1565cfa --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/index.d.ts @@ -0,0 +1,93 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection } from '@stdlib/types/array'; + +/** +* Interface describing an interface for computing minimum and maximum of two single-precision floating-point numbers. +*/ +interface MinMaxf { + /** + * Returns the minimum and maximum of two single-precision floating-point numbers. + * + * @param x - first number + * @param y - second number + * @returns minimum and maximum values + * + * @example + * var v = minmaxf( 3.14, 4.2 ); + * // returns [ 3.14, 4.2 ] + * + * var v = minmaxf( 3.14, NaN ); + * // returns [ NaN, NaN ] + * + * @example + * var v = minmaxf( +0.0, -0.0 ); + * // returns [ -0.0, 0.0 ] + */ + ( x: number, y: number ): Array; + + /** + * Returns the minimum and maximum of two single-precision floating-point numbers and assigns results to a provided output array. + * + * @param x - first number + * @param y - second number + * @param out - output object + * @param stride - output array stride + * @param offset - output array index offset + * @returns minimum and maximum values + * + * @example + * var out = [ 0.0, 0.0 ]; + * var v = minmaxf( 5.9, 3.14, out, 1, 0 ); + * // returns [ 3.14, 5.9 ] + * + * var bool = ( v === out ); + * // returns true + */ + assign( x: number, y: number, out: Collection, stride: number, offset: number ): Collection; +} + +/** +* Returns the minimum and maximum of two single-precision floating-point numbers. +* +* @param x - first number +* @param y - second number +* @returns minimum and maximum values +* +* @example +* var v = minmaxf( 3.14, 4.2 ); +* // returns [ 3.14, 4.2 ] +* +* var v = minmaxf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmaxf( +0.0, -0.0 ); +* // returns [ -0.0, 0.0 ] +*/ +declare var minmaxf: MinMaxf; + + +// EXPORTS // + +export = minmaxf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/test.ts new file mode 100644 index 000000000000..2b2d050ad0d2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/test.ts @@ -0,0 +1,126 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import minmaxf = require( './index' ); + + +// TESTS // + +// The function returns an array of numbers... +{ + minmaxf( 3.0, -0.2 ); // $ExpectType number[] +} + +// The compiler throws an error if the function is provided an argument which is not a number... +{ + minmaxf( true, 1.2 ); // $ExpectError + minmaxf( false, 1.2 ); // $ExpectError + minmaxf( [], 1.2 ); // $ExpectError + minmaxf( {}, 1.2 ); // $ExpectError + minmaxf( 'abc', 1.2 ); // $ExpectError + minmaxf( ( x: number ): number => x, 1.2 ); // $ExpectError + + minmaxf( 1.2, true ); // $ExpectError + minmaxf( 1.2, false ); // $ExpectError + minmaxf( 1.2, [] ); // $ExpectError + minmaxf( 1.2, {} ); // $ExpectError + minmaxf( 1.2, 'abc' ); // $ExpectError + minmaxf( 1.2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + minmaxf(); // $ExpectError + minmaxf( -0.2 ); // $ExpectError + minmaxf( 3.0, -0.2, 1.0 ); // $ExpectError + minmaxf( 3.0, -0.2, -1.2, -4.0 ); // $ExpectError + minmaxf( 3.0, -0.2, -1.2, -4.0, 5.0 ); // $ExpectError + minmaxf( 3.0, -0.2, -1.2, -4.0, 5.0, 6.0 ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns an array-like object containing numbers... +{ + const out = [ 0.0, 0.0 ]; + + minmaxf.assign( 3.0, -0.2, out, 1, 0 ); // $ExpectType Collection +} + +// The compiler throws an error if the `assign` method is provided a first argument which is not a number... +{ + const out = [ 0.0, 0.0 ]; + + minmaxf.assign( true, -0.2, out, 1, 0 ); // $ExpectError + minmaxf.assign( false, -0.2, out, 1, 0 ); // $ExpectError + minmaxf.assign( '5', -0.2, out, 1, 0 ); // $ExpectError + minmaxf.assign( null, -0.2, out, 1, 0 ); // $ExpectError + minmaxf.assign( [], -0.2, out, 1, 0 ); // $ExpectError + minmaxf.assign( {}, -0.2, out, 1, 0 ); // $ExpectError + minmaxf.assign( ( x: number ): number => x, -0.2, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not a number... +{ + const out = [ 0.0, 0.0 ]; + + minmaxf.assign( 1.0, false, out, 1, 0 ); // $ExpectError + minmaxf.assign( 1.0, '5', out, 1, 0 ); // $ExpectError + minmaxf.assign( 1.0, null, out, 1, 0 ); // $ExpectError + minmaxf.assign( 1.0, [], out, 1, 0 ); // $ExpectError + minmaxf.assign( 1.0, {}, out, 1, 0 ); // $ExpectError + minmaxf.assign( 1.0, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid third argument... +{ + minmaxf.assign( 1.0, 2.0, false, 1, 0 ); // $ExpectError + minmaxf.assign( 1.0, 2.0, null, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid fourth argument... +{ + const out = [ 0.0, 0.0 ]; + + minmaxf.assign( 1.0, 2.0, out, false, 0 ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, null, 0 ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, '5', 0 ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, [], 0 ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, {}, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid fifth argument... +{ + const out = [ 0.0, 0.0 ]; + + minmaxf.assign( 1.0, 2.0, out, 1, false ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, 1, null ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, 1, '5' ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, 1, [] ); // $ExpectError + minmaxf.assign( 1.0, 2.0, out, 1, {} ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const out = [ 0.0, 0.0 ]; + + minmaxf.assign( out, 1, 0 ); // $ExpectError + minmaxf.assign( 3.0, out, 1, 0 ); // $ExpectError + minmaxf.assign( 3.0, -0.2, 1.0, out, 1, 0 ); // $ExpectError + minmaxf.assign( 3.0, -0.2, -1.2, -4.0, out, 1, 0 ); // $ExpectError + minmaxf.assign( 3.0, -0.2, -1.2, -4.0, 5.0, out, 1, 0 ); // $ExpectError + minmaxf.assign( 3.0, -0.2, -1.2, -4.0, 5.0, 6.0, out, 1, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + +# Define the program used for compiling C source files: +ifdef C_COMPILER + CC := $(C_COMPILER) +else + CC := gcc +endif + +# Define the command-line options when compiling C files: +CFLAGS ?= \ + -std=c99 \ + -O3 \ + -Wall \ + -pedantic + +# Determine whether to generate position independent code ([1][1], [2][2]). +# +# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options +# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option +ifeq ($(OS), WINNT) + fPIC ?= +else + fPIC ?= -fPIC +endif + +# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`): +INCLUDE ?= + +# List of source files: +SOURCE_FILES ?= + +# List of libraries (e.g., `-lopenblas -lpthread`): +LIBRARIES ?= + +# List of library paths (e.g., `-L /foo/bar -L /beep/boop`): +LIBPATH ?= + +# List of C targets: +c_targets := example.out + + +# RULES # + +#/ +# Compiles source files. +# +# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`) +# @param {string} [CFLAGS] - C compiler options +# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`) +# @param {string} [SOURCE_FILES] - list of source files +# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`) +# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`) +# +# @example +# make +# +# @example +# make all +#/ +all: $(c_targets) + +.PHONY: all + +#/ +# Compiles C source files. +# +# @private +# @param {string} CC - C compiler (e.g., `gcc`) +# @param {string} CFLAGS - C compiler options +# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`) +# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`) +# @param {string} SOURCE_FILES - list of source files +# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`) +# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`) +#/ +$(c_targets): %.out: %.c + $(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES) + +#/ +# Runs compiled examples. +# +# @example +# make run +#/ +run: $(c_targets) + $(QUIET) ./$< + +.PHONY: run + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: + $(QUIET) -rm -f *.o *.out + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/example.c new file mode 100644 index 000000000000..dc3a2ebe6350 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/example.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/minmaxf.h" +#include + +int main( void ) { + const float x[] = { 1.0f, 0.45f, -0.89f, 0.0f / 0.0f, -0.78f, -0.22f, 0.66f, 0.11f, -0.55f, 0.0f }; + const float y[] = { -0.22f, 0.66f, 0.0f, -0.55f, 0.33f, 1.0f, 0.0f / 0.0f, 0.11f, 0.45f, -0.78f }; + + float min; + float max; + int i; + for ( i = 0; i < 10; i++ ) { + stdlib_base_minmaxf( x[ i ], y[ i ], &min, &max ); + printf( "x: %f, y: %f => min: %f, max: %f\n", x[ i ], y[ i ], min, max ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js new file mode 100644 index 000000000000..50d2a864e3c2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var minstd = require( '@stdlib/random/base/minstd-shuffle' ); +var minmaxf = require( './../lib' ); + +var x; +var y; +var v; +var i; + +for ( i = 0; i < 100; i++ ) { + x = minstd(); + y = minstd(); + v = minmaxf( x, y ); + console.log( 'minmaxf(%d,%d) = [%d, %d]', x, y, v[0], v[1] ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/include.gypi b/lib/node_modules/@stdlib/math/base/special/minmaxf/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A GYP include file for building a Node.js native add-on. +# +# Main documentation: +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Source directory: + 'src_dir': './src', + + # Include directories: + 'include_dirs': [ + '} minimum and maximum values +* +* @example +* var v = minmaxf( 3.14, 4.2 ); +* // returns [ 3.14, 4.2 ] +* +* @example +* var v = minmaxf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmaxf( +0.0, -0.0 ); +* // returns [ -0.0, 0.0 ] +*/ +function minmaxf( x, y ) { + return assign( x, y, [ 0.0, 0.0 ], 1, 0 ); +} + + +// EXPORTS // + +module.exports = minmaxf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/native.js new file mode 100644 index 000000000000..e5656e435397 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/native.js @@ -0,0 +1,58 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var Float32Array = require( '@stdlib/array/float32' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Returns the minimum and maximum of two single-precision floating-point numbers. +* +* @private +* @param {number} x - first number +* @param {number} y - second number +* @returns {Float32Array} minimum and maximum values +* +* @example +* var v = minmaxf( 3.14, 4.2 ); +* // returns [ ~3.14, ~4.2 ] +* +* @example +* var v = minmaxf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmaxf( +0.0, -0.0 ); +* // returns [ -0.0, 0.0 ] +*/ +function minmaxf( x, y ) { + var out = new Float32Array( 2 ); + addon( x, y, out ); + return out; +} + + +// EXPORTS // + +module.exports = minmaxf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/manifest.json b/lib/node_modules/@stdlib/math/base/special/minmaxf/manifest.json new file mode 100644 index 000000000000..51990ff36d8b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/manifest.json @@ -0,0 +1,78 @@ +{ + "options": { + "task": "build" + }, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "task": "build", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/napi/argv", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-float32array", + "@stdlib/napi/export", + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/assert/is-negative-zerof" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/assert/is-negative-zerof" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/assert/is-nanf", + "@stdlib/math/base/assert/is-negative-zerof" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/package.json b/lib/node_modules/@stdlib/math/base/special/minmaxf/package.json new file mode 100644 index 000000000000..c4e6905dd7b9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/math/base/special/minmaxf", + "version": "0.0.0", + "description": "Return the minimum and maximum of two single-precision floating-point numbers.", + "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.min", + "math.max", + "minimum", + "maximum", + "extremum", + "min", + "max", + "smallest", + "largest", + "extrema" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/minmaxf/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2025 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +#/ + +# VARIABLES # + +ifndef VERBOSE + QUIET := @ +else + QUIET := +endif + +# Determine the OS ([1][1], [2][2]). +# +# [1]: https://en.wikipedia.org/wiki/Uname#Examples +# [2]: http://stackoverflow.com/a/27776822/2225624 +OS ?= $(shell uname) +ifneq (, $(findstring MINGW,$(OS))) + OS := WINNT +else +ifneq (, $(findstring MSYS,$(OS))) + OS := WINNT +else +ifneq (, $(findstring CYGWIN,$(OS))) + OS := WINNT +else +ifneq (, $(findstring Windows_NT,$(OS))) + OS := WINNT +endif +endif +endif +endif + + +# RULES # + +#/ +# Removes generated files for building an add-on. +# +# @example +# make clean-addon +#/ +clean-addon: + $(QUIET) -rm -f *.o *.node + +.PHONY: clean-addon + +#/ +# Removes generated files. +# +# @example +# make clean +#/ +clean: clean-addon + +.PHONY: clean diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/minmaxf/src/addon.c new file mode 100644 index 000000000000..0df420aba87c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/src/addon.c @@ -0,0 +1,42 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/minmaxf.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_float32array.h" +#include + +/** +* Receives JavaScript callback invocation data. +* +* @param env environment under which the function is invoked +* @param info callback data +* @return Node-API value +*/ +static napi_value addon( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 3 ); + STDLIB_NAPI_ARGV_FLOAT( env, x, argv, 0 ); + STDLIB_NAPI_ARGV_FLOAT( env, y, argv, 1 ); + STDLIB_NAPI_ARGV_FLOAT32ARRAY( env, out, outlen, argv, 2 ); + stdlib_base_minmaxf( x, y, &out[ 0 ], &out[ 1 ] ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/src/main.c b/lib/node_modules/@stdlib/math/base/special/minmaxf/src/main.c new file mode 100644 index 000000000000..1dc835d01f78 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/src/main.c @@ -0,0 +1,63 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/math/base/special/minmaxf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/assert/is_negative_zerof.h" + +/** +* Evaluates the minimum and maximum of two single-precision floating-point numbers. +* +* @param x first number +* @param y second number +* @param min destination for the minimum value +* @param max destination for the maximum value +* +* @example +* float x = 3.14f; +* float y = 2.71f; +* +* float min; +* float max; +* stdlib_base_minmaxf( x, y, &min, &max ); +*/ +void stdlib_base_minmaxf( const float x, const float y, float* min, float* max ) { + if ( stdlib_base_is_nanf( x ) || stdlib_base_is_nanf( y ) ) { + *min = 0.0f / 0.0f; // NaN + *max = 0.0f / 0.0f; // NaN + return; + } + if ( x == y && x == 0.0f ) { + if ( stdlib_base_is_negative_zerof( x ) ) { + *min = x; + *max = y; + return; + } + *min = y; + *max = x; + return; + } + if ( x < y ) { + *min = x; + *max = y; + return; + } + *min = y; + *max = x; + return; +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js new file mode 100644 index 000000000000..f8533930564b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js @@ -0,0 +1,225 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +/* eslint-disable max-len */ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var Float32Array = require( '@stdlib/array/float32' ); +var minmaxf = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` for both the minimum and maximum value if provided a `NaN`', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxf( NaN, float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( float64ToFloat32( 3.14 ), NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( NaN, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-Infinity` as the minimum value if provided `-Infinity`', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxf( NINF, float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( float64ToFloat32( 3.14 ), NINF, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+Infinity` as the maximum value if provided `+Infinity`', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxf( PINF, float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( float64ToFloat32( 3.14 ), PINF, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxf( +0.0, -0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( -0.0, +0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( -0.0, -0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isNegativeZerof( v[ 1 ] ), true, 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( +0.0, +0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum values', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxf( float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], -float64ToFloat32( 4.2 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing an output object (array)', function test( t ) { + var out; + var v; + + out = [ 0.0, 0.0 ]; + v = minmaxf( 4.2, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); + + out = [ 0.0, 0.0 ]; + v = minmaxf( -4.2, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports providing an output object (typed array)', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxf( float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); + + out = new Float32Array( 2 ); + v = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], -float64ToFloat32( 4.2 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', function test( t ) { + var out; + var val; + + out = new Float32Array( 4 ); + val = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 2, 0 ); + + t.strictEqual( val, out, 'returns output array' ); + t.strictEqual( val[ 0 ], -float64ToFloat32( 4.2 ), 'returns expected value' ); + t.strictEqual( val[ 1 ], 0, 'returns expected value' ); + t.strictEqual( val[ 2 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( val[ 3 ], 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports specifying an offset', function test( t ) { + var out; + var val; + + out = new Float32Array( 4 ); + val = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 2, 1 ); + + t.strictEqual( val, out, 'returns output array' ); + t.strictEqual( val[ 0 ], 0, 'returns expected value' ); + t.strictEqual( val[ 1 ], -float64ToFloat32( 4.2 ), 'returns expected value' ); + t.strictEqual( val[ 2 ], 0, 'returns expected value' ); + t.strictEqual( val[ 3 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js new file mode 100644 index 000000000000..ff00bb92971c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var hasOwnProp = require( '@stdlib/assert/has-own-property' ); +var minmaxf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( hasOwnProp( minmaxf, 'assign' ), true, 'has property' ); + t.strictEqual( typeof minmaxf.assign, 'function', 'has method' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js new file mode 100644 index 000000000000..fd170e8a064a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js @@ -0,0 +1,120 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var minmaxf = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` for both the minimum and maximum value if provided a `NaN`', function test( t ) { + var v; + + v = minmaxf( NaN, 3.14 ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( 3.14, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( NaN, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-Infinity` as the minimum value if provided `-Infinity`', function test( t ) { + var v; + + v = minmaxf( NINF, 3.14 ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + v = minmaxf( 3.14, NINF ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+Infinity` as the maximum value if provided `+Infinity`', function test( t ) { + var v; + + v = minmaxf( PINF, 3.14 ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + v = minmaxf( 3.14, PINF ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', function test( t ) { + var v; + + v = minmaxf( +0.0, -0.0 ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( -0.0, +0.0 ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( -0.0, -0.0 ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isNegativeZerof( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( +0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum values', function test( t ) { + var v; + + v = minmaxf( 4.2, 3.14 ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 4.2, 'returns expected value' ); + + v = minmaxf( -4.2, 3.14 ); + t.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.native.js new file mode 100644 index 000000000000..223093894759 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.native.js @@ -0,0 +1,130 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var isNegativeZerof = require( '@stdlib/math/base/assert/is-negative-zerof' ); +var isPositiveZerof = require( '@stdlib/math/base/assert/is-positive-zerof' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var minmaxf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( minmaxf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` for both the minimum and maximum value if provided a `NaN`', opts, function test( t ) { + var v; + + v = minmaxf( NaN, float64ToFloat32( 3.14 ) ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( float64ToFloat32( 3.14 ), NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( NaN, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `-Infinity` as the minimum value if provided `-Infinity`', opts, function test( t ) { + var v; + + v = minmaxf( NINF, float64ToFloat32( 3.14 ) ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + v = minmaxf( float64ToFloat32( 3.14 ), NINF ); + t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `+Infinity` as the maximum value if provided `+Infinity`', opts, function test( t ) { + var v; + + v = minmaxf( PINF, float64ToFloat32( 3.14 ) ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + v = minmaxf( float64ToFloat32( 3.14 ), PINF ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', opts, function test( t ) { + var v; + + v = minmaxf( +0.0, -0.0 ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( -0.0, +0.0 ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( -0.0, -0.0 ); + t.strictEqual( isNegativeZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isNegativeZerof( v[ 1 ] ), true, 'returns expected value' ); + + v = minmaxf( +0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum values', opts, function test( t ) { + var v; + + v = minmaxf( float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ) ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); + + v = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ) ); + t.strictEqual( v[ 0 ], -float64ToFloat32( 4.2 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + + t.end(); +});