diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/README.md b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/README.md new file mode 100644 index 000000000000..6ccb346823f3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/README.md @@ -0,0 +1,250 @@ + + +# minmaxabsf + +> Return the minimum and maximum absolute single-precision floating-point numbers. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var minmaxabsf = require( '@stdlib/math/base/special/minmaxabsf' ); +``` + +#### minmaxabsf( x,y ) + +Returns the minimum and maximum absolute single-precision floating-point values in a single pass. + +```javascript +var v = minmaxabsf( 4.0, 3.0 ); +// returns [ 3.0, 4.0 ] + +v = minmaxabsf( +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 = minmaxabsf( 4.2, NaN ); +// returns [ NaN, NaN ] + +v = minmaxabsf( NaN, 3.14 ); +// returns [ NaN, NaN ] +``` + +#### minmaxabsf.assign( x, y, out, stride, offset ) + +Returns the minimum and maximum absolute single-precision values in a single pass and assigns the results to a provided output array. + +```javascript +var Float32Array = require( '@stdlib/array/float32' ); + +var out = new Float32Array( 2 ); + +var v = minmaxabsf.assign( 5.0, -1.0, out, 1, 0 ); +// returns [ 1.0, 5.0 ] + +var bool = ( v === out ); +// returns true +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var minmaxabsf = require( '@stdlib/math/base/special/minmaxabsf' ); + +var x = uniform( 100, -50, 50); +var y = uniform( 100, -50, 50); + +logEachMap( 'minmaxabsf(%f,%f) = [%s]', x, y, minmaxabsf ); +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/minmaxabsf.h" +``` + +#### stdlib_base_minmaxabsf( x, y, min, max ) + +Returns the minimum and maximum absolute single-precision floating-point values in a single pass. + +```c +float min; +float max; +stdlib_base_minmaxabsf( -4.2f, 3.14f, &min, &max ); + +stdlib_base_minmaxabsf( 0.0f, -0.0f, &min, &max ); +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. +- **y**: `[in] float` input value. +- **min**: `[out] *float` output min. +- **max**: `[out] *float` output max. + +```c +void stdlib_base_minmaxabsf( const float x, const float y, float* min, float* max ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/minmaxabsf.h" +#include +#include + +int main(void) { + srand(time(NULL)); // Seed random number generator + + float x1[10], x2[10]; + float min, max; + int i; + + // Generate random floating-point values between -1.0 and 1.0 + for (i = 0; i < 10; i++) { + x1[i] = ((float)rand() / RAND_MAX) * 2.0f - 1.0f; // Random float in [-1,1] + x2[i] = ((float)rand() / RAND_MAX) * 2.0f - 1.0f; // Random float in [-1,1] + + // Introduce NaN values randomly + if (rand() % 10 == 0) x1[i] = NAN; + if (rand() % 10 == 0) x2[i] = NAN; + } + + // Compute min and max values + for (i = 0; i < 10; i++) { + stdlib_base_minmaxabsf(x1[i], x2[i], &min, &max); + printf("x1[%d]: %f, x2[%d]: %f, minmaxf(x1[%d], x2[%d]): (%f, %f)\n", + i, x1[i], i, x2[i], i, i, min, max); + } + + return 0; +} +``` + +
+ + + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/benchmark.js new file mode 100644 index 000000000000..fe9d43fed295 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/benchmark.js @@ -0,0 +1,78 @@ +/** +* @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 randu = require( '@stdlib/random/base/randn' ); +var isFloat32Array = require( '@stdlib/assert/is-float32array' ); +var float32Array = require( '@stdlib/array/float32' ); +var pkg = require( './../package.json' ).name; +var minmaxabsf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var z; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu()*1000.0 ) - 500.0; + y = ( randu()*1000.0 ) - 500.0; + z = minmaxabsf( x, y ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isFloat32Array( z ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( pkg+':assign', function benchmark( b ) { + var x; + var y; + var z; + var i; + + z = new float32Array( 2 ); + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu()*1000.0 ) - 500.0; + y = ( randu()*1000.0 ) - 500.0; + z = minmaxabsf.assign( x, y, z, 1, 0 ); + if ( z.length !== 2 ) { + b.fail( 'should have expected length' ); + } + } + b.toc(); + if ( !isFloat32Array( z ) ) { + b.fail( 'should return an array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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/minmaxabsf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..52435d492c9b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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/minmaxabsf.h" +#include +#include +#include +#include +#include + +#define NAME "minmaxabsf" +#define ITERATIONS 1000000 +#define REPEATS 3 + +/** +* Prints the TAP version. +*/ +static void print_version( void ) { + printf( "TAP version 13\n" ); +} + +/** +* Prints the TAP summary. +* +* @param total total number of tests +* @param passing total number of passing tests +*/ +static void print_summary( int total, int passing ) { + printf( "#\n" ); + printf( "1..%d\n", total ); // TAP plan + printf( "# total %d\n", total ); + printf( "# pass %d\n", passing ); + printf( "#\n" ); + printf( "# ok\n" ); +} + +/** +* Prints benchmarks results. +* +* @param elapsed elapsed time in seconds +*/ +static void print_results( double elapsed ) { + double rate = (double)ITERATIONS / elapsed; + printf( " ---\n" ); + printf( " iterations: %d\n", ITERATIONS ); + printf( " elapsed: %0.9f\n", elapsed ); + printf( " rate: %0.9f\n", rate ); + printf( " ...\n" ); +} + +/** +* Returns a clock time. +* +* @return clock time +*/ +static double tic( void ) { + struct timeval now; + gettimeofday( &now, NULL ); + return (double)now.tv_sec + (double)now.tv_usec/1.0e6; +} + +/** +* Generates a random number on the interval [0,1). +* +* @return random number +*/ +static float rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + double t; + float x[ 100 ]; + float y[ 100 ]; + float min; + float max; + 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_minmaxabsf( x[ i % 100 ], y[ i % 100 ], &min, &max ); + if ( min != min || max != max ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( min != min || max != max ) { + 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/minmaxabsf/benchmark/julia/REQUIRE b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/julia/REQUIRE new file mode 100644 index 000000000000..98645e192e41 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/julia/REQUIRE @@ -0,0 +1,2 @@ +julia 1.5 +BenchmarkTools 0.5.0 diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/julia/benchmark.jl new file mode 100755 index 000000000000..eba092d8880e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/benchmark/julia/benchmark.jl @@ -0,0 +1,166 @@ +#!/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 = "minmaxabsf"; +repeats = 3; + +""" + minmaxabsf( x, y ) +Returns array of minimum and maximum absolute values + +# Arguments + +* `x`: First Number +* `y`: Second Number + +# Examples + +``` julia +julia> minmaxabsf( 3, 3 ) +``` +""" +function minmaxabsf( x, y ) + ax = abs(x) + ay = abs(y) + return ax < ay ? [ax, ay] : [ay, ax] +end + + +""" + 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 minmaxabsf( (1000.0*rand())-500.0, (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/minmaxabsf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/binding.gyp new file mode 100644 index 000000000000..68a1ca11d160 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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/minmaxabsf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/docs/repl.txt new file mode 100644 index 000000000000..db190f31e798 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/docs/repl.txt @@ -0,0 +1,68 @@ + +{{alias}}( x, y ) + Returns the absolute single precision minimum and maximum values. + + 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.0, 4.0 ) + [ 3.0, 4.0 ] + > 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 absolute single precision minimum and maximum values + + 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/minmaxabsf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/docs/types/index.d.ts new file mode 100644 index 000000000000..055e750d6df7 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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 values. +*/ +interface MinMaxAbsf { + /** + * Returns the single-precision minimum and maximum values. + * + * @param x - first number + * @param y - second number + * @returns minimum and maximum values + * + * @example + * var v = minmaxabsf( 3.14, 4.2 ); + * // returns [ 3.14, 4.2 ] + * + * var v = minmaxabsf( 3.14, NaN ); + * // returns [ NaN, NaN ] + * + * @example + * var v = minmaxabsf( +0.0, -0.0 ); + * // returns [ 0.0, 0.0 ] + */ + ( x: number, y: number ): Array; + + /** + * Returns the single-precision minimum and maximum absolute values 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 = minmaxabsf( 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 single-precision absolute values. +* +* @param x - first number +* @param y - second number +* @returns minimum and maximum values +* +* @example +* var v = minmaxabsf( 3.14, 4.2 ); +* // returns [ 3.14, 4.2 ] +* +* var v = minmaxabsf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmaxabsf( +0.0, -0.0 ); +* // returns [ 0.0, 0.0 ] +*/ +declare const minmaxabsf: MinMaxAbsf; + + +// EXPORTS // + +export default minmaxabsf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/docs/types/test.ts new file mode 100644 index 000000000000..1a2994ed0a9b --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/docs/types/test.ts @@ -0,0 +1,129 @@ +/* +* @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 float32Array = require( '@stdlib/array/float32' ); +import minmaxabsf from './index'; + + +// TESTS // + +// The function returns an array of numbers... +{ + minmaxabsf( 3.0, -0.2 ); +} + +// The compiler throws an error if the function is provided an argument which is not a number... +{ + minmaxabsf( true, 1.0 ); // $ExpectError + minmaxabsf( false, 1.0 ); // $ExpectError + minmaxabsf( [], 1.0 ); // $ExpectError + minmaxabsf( {}, 1.0 ); // $ExpectError + minmaxabsf( 'abc', 1.0 ); // $ExpectError + minmaxabsf( ( x: number ): number => x, 1.0 ); // $ExpectError + + minmaxabsf( 1.2, true ); // $ExpectError + minmaxabsf( 1.2, false ); // $ExpectError + minmaxabsf( 1.2, [] ); // $ExpectError + minmaxabsf( 1.2, {} ); // $ExpectError + minmaxabsf( 1.2, 'abc' ); // $ExpectError + minmaxabsf( 1.2, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + minmaxabsf(); // $ExpectError + minmaxabsf( -0.2 ); // $ExpectError + minmaxabsf( 3.0, -0.2, -1.2 ); // $ExpectError + minmaxabsf( 3.0, -0.2, -1.2, -4.0 ); // $ExpectError + minmaxabsf( 3.0, -0.2, -1.2, -4.0, 5.0 ); // $ExpectError +} + +// Attached to the main export is an `assign` method which returns an array-like object containing numbers... +{ + const out = new float32Array( 2 ); + + minmaxabsf.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 = new float32Array( 2 ); + + minmaxabsf.assign( true, 1.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( false, 1.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( '5', -0.2, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( null, 1.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( [], -4.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( {}, 5.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( ( x: number ): number => x, 6.0, 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 = new float32Array( 2 ); + + minmaxabsf.assign( 1.0, false, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, '5', out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, null, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, [], out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, {}, out, 1, 0 ); // $ExpectError + minmaxabsf.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... +{ + minmaxabsf.assign( 1.0, 3.0, false, 1, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, null, 1, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, {}, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid fourth argument... +{ + const out = new float32Array( 2 ); + + minmaxabsf.assign( 1.0, 3.0, out, false, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, '5', 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, null, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, [], 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, {}, 0 ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an invalid fifth argument... +{ + const out = new float32Array( 2 ); + + minmaxabsf.assign( 1.0, 3.0, out, 0, false ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, 0, '5' ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, 0, null ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, 0, [] ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, 0, {} ); // $ExpectError + minmaxabsf.assign( 1.0, 3.0, out, 0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const out = new float32Array( 2 ); + + minmaxabsf.assign( out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 3.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 3.0, -0.2, 1.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 3.0, -0.2, -1.2, -4.0, out, 1, 0 ); // $ExpectError + minmaxabsf.assign( 3.0, -0.2, -1.2, -4.0, 5.0, out, 1, 0 ); // $ExpectError + minmaxabsf.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/minmaxabsf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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/minmaxabsf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/examples/c/example.c new file mode 100644 index 000000000000..381fbd3e628f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/examples/c/example.c @@ -0,0 +1,36 @@ +/** +* @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 +#include +#include "stdlib/math/base/special/minmaxabsf.h" + +int main( void ) { + float x; + float y; + float min; + float max; + int i; + + for ( i = 0; i < 100; i++ ) { + x = ( ( (float)rand() / (float)RAND_MAX ) * 1000.0f ) - 500.0f; + y = ( ( (float)rand() / (float)RAND_MAX ) * 1000.0f ) - 500.0f; + stdlib_base_minmaxabsf( x, y, &min, &max ); + printf( "x: %f, y: %f, minmaxabsf(x, y): %f %f\n", x, y, min, max ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/examples/index.js new file mode 100644 index 000000000000..877eb582f96e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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 uniform = require( '@stdlib/random/array/uniform' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var minmaxabsf = require( './../lib' ); + +var x = uniform( 100, -50, 50 ); +var y = uniform( 100, -50, 50 ); + +logEachMap( 'minmaxabsf(%f,%f) = [%s]', x, y, minmaxabsf ); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/include.gypi b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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': [ + '[ 3.14, 4.2 ] +* +* var bool = ( v === out ); +* // returns true +* +* @example +* var out = [ 0.0, 0.0 ]; +* var v = minmaxabsf( -5.9, 3.14, out, 1, 0 ); +* // returns [ 3.14, 5.9 ] +* +* @example +* var out = [ 0.0, 0.0 ]; +* var v = minmaxabsf( 3.14, NaN, out, 1, 0 ); +* // returns [ NaN, NaN ] +* +* @example +* var out = [ 0.0, 0.0 ]; +* var v = minmaxabsf( +0.0, -0.0, out, 1, 0 ); +* // returns [ 0.0, 0.0 ] +*/ +function minmaxabsf( x, y, out, stride, offset ) { + var ax; + var ay; + + if ( isnanf( x ) || isnanf( y ) ) { + out[ offset ] = NaN; + out[ offset + stride ] = NaN; + return out; + } + ax = absf( x ); + ay = absf( y ); + if ( ax < ay ) { + out[ offset ] = ax; + out[ offset + stride ] = ay; + return out; + } + out[ offset ] = ay; + out[ offset + stride ] = ax; + return out; +} + + +// EXPORTS // + +module.exports = minmaxabsf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/index.js new file mode 100644 index 000000000000..1b90f62b46da --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/index.js @@ -0,0 +1,59 @@ +/** +* @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'; + +/** +* Return the minimum and maximum absolute single-precision floating-point values. +* +* @module @stdlib/math/base/special/minmaxabsf +* +* @example +* var minmaxabsf = require( '@stdlib/math/base/special/minmaxabsf' ); +* +* var v = minmaxabsf( 3.14, 4.2 ); +* // returns [ 3.14, 4.2 ] +* +* v = minmaxabsf( -5.9, 3.14 ); +* // returns [ 3.14, 5.9 ] +* +* v = minmaxabsf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* v = minmaxabsf( +0.0, -0.0 ); +* // returns [ 0.0, 0.0 ] +* +* v = minmaxabsf( 3.14 ); +* // returns [ 3.14, 3.14 ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var assign = require( './assign.js' ); +var minmaxabsf = require( './main.js' ); + + +// MAIN // + +setReadOnly( minmaxabsf, 'assign', assign ); + + +// EXPORTS // + +module.exports = minmaxabsf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/main.js new file mode 100644 index 000000000000..2b651aabd4d1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/main.js @@ -0,0 +1,59 @@ +/** +* @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 float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var float32Array = require( '@stdlib/array/float32' ); +var assign = require( './assign.js' ); + + +// MAIN // + +/** +* Returns the minimum and maximum absolute single-precision floating-point values. +* +* @param {number} x - first number +* @param {number} y - second number +* @returns {Array} minimum and maximum absolute single-precision floating-point values +* +* @example +* var v = minmaxabsf( 3.0, 4.0 ); +* // returns [ 3.0, 4.0 ] +* +* @example +* var v = minmaxabsf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmaxabsf( +0.0, -0.0 ); +* // returns [ 0.0, 0.0 ] +*/ +function minmaxabsf( x, y ) { + var out = new float32Array( 2 ); + x = float64ToFloat32( x ); + y = float64ToFloat32( y ); + return assign( x, y, out, 1, 0 ); +} + + +// EXPORTS // + +module.exports = minmaxabsf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/native.js new file mode 100644 index 000000000000..700355e834c1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/lib/native.js @@ -0,0 +1,60 @@ +/** +* @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 float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Returns the minimum and maximum absolute single-precision floating-point values. +* @param {number} x - first number +* @param {number} y - second number +* @returns {Array} minimum and maximum absolute single-precision floating-point values +* +* @example +* var v = minmaxabsf( 3.0, 4.0 ); +* // returns [ 3.0, 4.0 ] +* +* @example +* var v = minmaxabsf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* @example +* var v = minmaxabsf( +0.0, -0.0 ); +* // returns [ 0.0, 0.0 ] +*/ +function minmaxabsf( x, y ) { + var out; + x = float64ToFloat32( x ); + y = float64ToFloat32( y ); + out = new float32Array( 2 ); + addon( x, y, out ); + return out; +} + + +// EXPORTS // + +module.exports = minmaxabsf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/manifest.json b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/manifest.json new file mode 100644 index 000000000000..7dd2b0ea08be --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/manifest.json @@ -0,0 +1,79 @@ +{ + "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/export", + "@stdlib/napi/argv-float", + "@stdlib/napi/argv-float32array", + "@stdlib/math/base/napi/quaternary", + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf" + ] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/math/base/special/absf", + "@stdlib/math/base/assert/is-nanf" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/package.json b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/package.json new file mode 100644 index 000000000000..f719fe3fcba1 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/math/base/special/minmaxabsf", + "version": "0.0.0", + "description": "Return the minimum and maximum absolute 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", + "absolute", + "value", + "abs", + "magnitude", + "math.abs" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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/minmaxabsf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/src/addon.c new file mode 100644 index 000000000000..c0ba7dcadccf --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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 +#include "stdlib/napi/argv.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv_float.h" +#include "stdlib/napi/argv_float32array.h" +#include "stdlib/math/base/special/minmaxabsf.h" + +/** +* 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, len, argv, 2 ); + stdlib_base_minmaxabsf( x, y, &out[0], &out[1] ); + return NULL; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/src/main.c b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/src/main.c new file mode 100644 index 000000000000..43a6c0f436b0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/src/main.c @@ -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. +*/ + +#include "stdlib/math/base/special/absf.h" +#include "stdlib/math/base/assert/is_nanf.h" +#include "stdlib/math/base/special/minmaxabsf.h" + +/** +* Evaluates the single-precision min and max value. +* +* @param x first input +* @param y second input +* @param min output min +* @param max output max +* @return void +* +* @example +* float min; +* float max; +* float v = stdlib_base_minmaxabsf( 3.2, 4.1, &min, &max ); +* +* @example +* float min; +* float max; +* float v = stdlib_base_minmaxabsf( 4.0, 0.0/0.0, &min, &max ); +*/ +void stdlib_base_minmaxabsf( 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; + *max = 0.0f/0.0f; + return; + } + float ax = stdlib_base_absf( x ); + float ay = stdlib_base_absf( y ); + if ( ax < ay ) { + *min = ax; + *max = ay; + return; + } + *min = ay; + *max = ax; + return; +} diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.assign.js new file mode 100644 index 000000000000..8ff8e1a2b819 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.assign.js @@ -0,0 +1,203 @@ +/** +* @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 isPositiveZero = require( '@stdlib/math/base/assert/is-positive-zero' ); +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 minmaxabsf = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxabsf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxabsf( NaN, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( 3.14, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( NaN, NaN, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + 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 = minmaxabsf( NINF, 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 -infinity' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( 3.14, NINF, 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 -infinity' ); + + 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 = minmaxabsf( PINF, 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 +infinity' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( 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 +infinity' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxabsf( +0.0, -0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( -0.0, +0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( -0.0, -0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( +0.0, +0.0, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( isPositiveZero( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZero( v[ 1 ] ), true, 'returns +0' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum single-precision floating-point absolute values', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxabsf( 4.2, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( -4.2, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + t.end(); +}); + +tape( 'the function supports providing an output object (array)', function test( t ) { + var out; + var v; + + out = new Float32Array( 2 ); + v = minmaxabsf( 4.2, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + out = new Float32Array( 2 ); + v = minmaxabsf( -4.2, 3.14, out, 1, 0 ); + t.strictEqual( v, out, 'returns output array' ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + t.end(); +}); + +tape( 'the function supports specifying a stride', function test( t ) { + var out; + var val; + + out = new Float32Array( 4 ); + val = minmaxabsf( -4.2, 3.14, out, 2, 0 ); + + t.strictEqual( val, out, 'returns output array' ); + t.strictEqual( val[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( val[ 1 ], float64ToFloat32( 0 ), 'returns expected value' ); + t.strictEqual( val[ 2 ], float64ToFloat32( 4.2 ), 'returns expected value' ); + t.strictEqual( val[ 3 ], float64ToFloat32( 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 = minmaxabsf( -4.2, 3.14, out, 2, 1 ); + + t.strictEqual( val, out, 'returns output array' ); + t.strictEqual( val[ 0 ], float64ToFloat32( 0 ), 'returns expected value' ); + t.strictEqual( val[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( val[ 2 ], float64ToFloat32( 0 ), 'returns expected value' ); + t.strictEqual( val[ 3 ], float64ToFloat32( 4.2 ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.js new file mode 100644 index 000000000000..8c959616b8dd --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.js @@ -0,0 +1,106 @@ +/** +* @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 hasOwnProp = require( '@stdlib/assert/has-own-property' ); +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 minmaxabsf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxabsf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( hasOwnProp( minmaxabsf, 'assign' ), true, 'has property' ); + t.strictEqual( typeof minmaxabsf.assign, 'function', 'has method' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided a `NaN`', function test( t ) { + var v; + + v = minmaxabsf( NaN, float64ToFloat32( 3.14 ) ); + t.strictEqual( isnanf( v[0] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[1] ), true, 'returns expected value' ); + + v = minmaxabsf( float64ToFloat32( 3.14 ), NaN ); + t.strictEqual( isnanf( v[0] ), true, 'returns expected value' ); + t.strictEqual( isnanf( v[1] ), true, 'returns expected value' ); + + v = minmaxabsf( 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 a correctly signed zero', function test( t ) { + var v; + + v = minmaxabsf( +0.0, -0.0 ); + t.strictEqual( isPositiveZerof( v[0] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[1] ), true, 'returns expected value' ); + + v = minmaxabsf( -0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[0] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[1] ), true, 'returns expected value' ); + + v = minmaxabsf( -0.0, -0.0 ); + t.strictEqual( isPositiveZerof( v[0] ), true, 'returns expected value' ); + t.strictEqual( isPositiveZerof( v[1] ), true, 'returns expected value' ); + + v = minmaxabsf( +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 absolute single-precision floating-point values', function test( t ) { + var v; + + v = minmaxabsf( 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 = minmaxabsf( 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 = minmaxabsf( PINF, float64ToFloat32( 3.14 ) ); + t.strictEqual( v[0], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[1], PINF, 'returns expected value' ); + + v = minmaxabsf( float64ToFloat32( 3.14 ), PINF ); + t.strictEqual( v[0], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[1], PINF, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.main.js new file mode 100644 index 000000000000..c2f8a3ba59ef --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/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 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 minmaxabsf = require( './../lib/main.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxabsf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` for both the minimum and maximum absolute single-precision floating-point values if provided a `NaN`', function test( t ) { + var v; + + v = minmaxabsf( NaN, 3.14 ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + v = minmaxabsf( 3.14, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + v = minmaxabsf( NaN, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns `Infinity` as the maximum value if provided `-Infinity`', function test( t ) { + var v; + + v = minmaxabsf( NINF, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + v = minmaxabsf( 3.14, NINF ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `Infinity` as the maximum value if provided `+Infinity`', function test( t ) { + var v; + + v = minmaxabsf( PINF, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns +infinity' ); + + v = minmaxabsf( 3.14, PINF ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns +infinity' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', function test( t ) { + var v; + + v = minmaxabsf( +0.0, -0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + v = minmaxabsf( -0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + v = minmaxabsf( -0.0, -0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + v = minmaxabsf( +0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum single-precision floating-point absolute values', function test( t ) { + var v; + + v = minmaxabsf( 4.2, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + v = minmaxabsf( -4.2, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.native.js b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.native.js new file mode 100644 index 000000000000..dd832f1d7869 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxabsf/test/test.native.js @@ -0,0 +1,129 @@ +/** +* @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 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 minmaxabsf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': (minmaxabsf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof minmaxabsf, '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 = minmaxabsf( NaN, 3.14 ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + v = minmaxabsf( 3.14, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + v = minmaxabsf( NaN, NaN ); + t.strictEqual( isnanf( v[ 0 ] ), true, 'returns NaN' ); + t.strictEqual( isnanf( v[ 1 ] ), true, 'returns NaN' ); + + t.end(); +}); + +tape( 'the function returns correctly signed zeros', function test( t ) { + var v; + + v = minmaxabsf( +0.0, -0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + v = minmaxabsf( -0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + v = minmaxabsf( -0.0, -0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + v = minmaxabsf( +0.0, +0.0 ); + t.strictEqual( isPositiveZerof( v[ 0 ] ), true, 'returns +0' ); + t.strictEqual( isPositiveZerof( v[ 1 ] ), true, 'returns +0' ); + + t.end(); +}); + +tape( 'the function returns `Infinity` as the maximum value if provided `-Infinity`', function test( t ) { + var v; + + v = minmaxabsf( NINF, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + v = minmaxabsf( 3.14, NINF ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns `Infinity` as the maximum value if provided `+Infinity`', function test( t ) { + var v; + + v = minmaxabsf( PINF, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns +infinity' ); + + v = minmaxabsf( 3.14, PINF ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], PINF, 'returns +infinity' ); + + t.end(); +}); + +tape( 'the function returns the minimum and maximum single-precision floating-point absolute values', function test( t ) { + var v; + + v = minmaxabsf( 4.2, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + v = minmaxabsf( -4.2, 3.14 ); + t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns min value' ); + t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns max value' ); + + t.end(); +});