From 6374f1d3862a224b94a16030f87927e823a60192 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 12:56:22 -0700 Subject: [PATCH 01/12] feat: add C implementation for `math/base/special/minmaxf` --- .../math/base/special/minmaxf/README.md | 242 ++++++++++++++++++ .../special/minmaxf/benchmark/benchmark.js | 149 +++++++++++ .../minmaxf/benchmark/benchmark.native.js | 67 +++++ .../minmaxf/benchmark/c/native/Makefile | 146 +++++++++++ .../minmaxf/benchmark/c/native/benchmark.c | 139 ++++++++++ .../special/minmaxf/benchmark/julia/REQUIRE | 2 + .../minmaxf/benchmark/julia/benchmark.jl | 144 +++++++++++ .../math/base/special/minmaxf/binding.gyp | 170 ++++++++++++ .../math/base/special/minmaxf/docs/repl.txt | 69 +++++ .../special/minmaxf/docs/types/index.d.ts | 93 +++++++ .../base/special/minmaxf/docs/types/test.ts | 126 +++++++++ .../base/special/minmaxf/examples/c/Makefile | 146 +++++++++++ .../base/special/minmaxf/examples/c/example.c | 33 +++ .../base/special/minmaxf/examples/index.js | 34 +++ .../math/base/special/minmaxf/include.gypi | 53 ++++ .../stdlib/math/base/special/minmaxf.h | 38 +++ .../math/base/special/minmaxf/lib/assign.js | 87 +++++++ .../math/base/special/minmaxf/lib/index.js | 54 ++++ .../math/base/special/minmaxf/lib/main.js | 56 ++++ .../math/base/special/minmaxf/lib/native.js | 58 +++++ .../math/base/special/minmaxf/manifest.json | 78 ++++++ .../math/base/special/minmaxf/package.json | 70 +++++ .../math/base/special/minmaxf/src/Makefile | 70 +++++ .../math/base/special/minmaxf/src/addon.c | 42 +++ .../math/base/special/minmaxf/src/main.c | 63 +++++ .../base/special/minmaxf/test/test.assign.js | 223 ++++++++++++++++ .../math/base/special/minmaxf/test/test.js | 40 +++ .../base/special/minmaxf/test/test.main.js | 121 +++++++++ .../base/special/minmaxf/test/test.native.js | 130 ++++++++++ 29 files changed, 2743 insertions(+) create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/README.md create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/c/native/benchmark.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/REQUIRE create mode 100755 lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/benchmark.jl create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/binding.gyp create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/include.gypi create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/include/stdlib/math/base/special/minmaxf.h create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/lib/native.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/manifest.json create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/package.json create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/src/Makefile create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/src/addon.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/src/main.c create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js create mode 100644 lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.native.js 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..0eb515d6d2f9 --- /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..857ed79fa90f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js @@ -0,0 +1,149 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var 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 maxf-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..4f85ea5a6b60 --- /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 Float64Array' ); + } + 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..070e263e4625 --- /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) 2018 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +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..eeec739973d5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt @@ -0,0 +1,69 @@ + +{{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..abe4a22efe74 --- /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) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/// + +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..db32da24c7ba --- /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) 2019 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import 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..a2fe299a785c --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js @@ -0,0 +1,34 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var 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': [ + '[ 3.14, 4.2 ] +* +* var bool = ( v === out ); +* // returns true +* +* @example +* var out = new Float32Array( 2 ); +* var v = minmaxf( 3.14, NaN, out, 1, 0 ); +* // returns [ NaN, NaN ] +* +* @example +* var out = new Float32Array( 2 ); +* var v = minmaxf( +0.0, -0.0, out, 1, 0 ); +* // returns [ -0.0, 0.0 ] +*/ +function minmaxf( x, y, out, stride, offset ) { + if ( isnanf( x ) || isnanf( y ) ) { + out[ offset ] = NaN; + out[ offset + stride ] = NaN; + return out; + } + if ( x === y && x === 0.0 ) { + if ( isNegativeZerof( x ) ) { + out[ offset ] = x; + out[ offset + stride ] = y; + return out; + } + out[ offset ] = y; + out[ offset + stride ] = x; + return out; + } + if ( x < y ) { + out[ offset ] = x; + out[ offset + stride ] = y; + return out; + } + out[ offset ] = y; + out[ offset + stride ] = x; + return out; +} + + +// EXPORTS // + +module.exports = minmaxf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js new file mode 100644 index 000000000000..23e61b5c7746 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js @@ -0,0 +1,54 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Return the minimum and maximum of two single-precision floating-point numbers. +* +* @module @stdlib/math/base/special/minmaxf +* +* @example +* var minmaxf = require( '@stdlib/math/base/special/minmaxf' ); +* +* var v = minmaxf( 3.14, 4.2 ); +* // returns [ 3.14, 4.2 ] +* +* v = minmaxf( 3.14, NaN ); +* // returns [ NaN, NaN ] +* +* v = minmaxf( +0.0, -0.0 ); +* // returns [ -0.0, 0.0 ] +* +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var assign = require( './assign.js' ); +var minmaxf = require( './main.js' ); + + +// MAIN // + +setReadOnly( minmaxf, 'assign', assign ); + + +// EXPORTS // + +module.exports = minmaxf; diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js new file mode 100644 index 000000000000..07f26ddc1bfe --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var assign = require( './assign.js' ); +var Float32Array = require( '@stdlib/array/float32' ); + + +// MAIN // + +/** +* Returns the minimum and maximum of two single-precision floating-point numbers. +* +* @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 ); + return assign( x, y, out, 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..12a8484e81ec --- /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..ec46603d736f --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js @@ -0,0 +1,223 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var 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( 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 = [ 0.0, 0.0 ]; + 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 (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..3a455a152ad8 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js @@ -0,0 +1,40 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2022 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var 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..79f3940c2491 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js @@ -0,0 +1,121 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2018 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var 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 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, 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`', 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`', 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', 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( 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(); +}); 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(); +}); From 376780197446068b6f0c62945d6f62c26ad37c14 Mon Sep 17 00:00:00 2001 From: stdlib-bot <82920195+stdlib-bot@users.noreply.github.com> Date: Mon, 19 May 2025 19:59:24 +0000 Subject: [PATCH 02/12] chore: update copyright years --- lib/node_modules/@stdlib/math/base/special/minmaxf/README.md | 2 +- .../@stdlib/math/base/special/minmaxf/benchmark/benchmark.js | 2 +- .../math/base/special/minmaxf/benchmark/julia/benchmark.jl | 2 +- .../@stdlib/math/base/special/minmaxf/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/minmaxf/docs/types/test.ts | 2 +- .../@stdlib/math/base/special/minmaxf/examples/index.js | 2 +- .../@stdlib/math/base/special/minmaxf/lib/assign.js | 2 +- lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js | 2 +- lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js | 2 +- .../@stdlib/math/base/special/minmaxf/test/test.assign.js | 2 +- lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js | 2 +- .../@stdlib/math/base/special/minmaxf/test/test.main.js | 2 +- 12 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md b/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md index 0eb515d6d2f9..f421c4264ac7 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2025 The Stdlib Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js index 857ed79fa90f..9305a2cf72fa 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/benchmark.jl b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/julia/benchmark.jl index 070e263e4625..e907278cfcc2 100755 --- 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 @@ -2,7 +2,7 @@ # # @license Apache-2.0 # -# Copyright (c) 2018 The Stdlib Authors. +# Copyright (c) 2025 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/index.d.ts index abe4a22efe74..b9daf1565cfa 100644 --- 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 @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/types/test.ts index db32da24c7ba..2b2d050ad0d2 100644 --- 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 @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2019 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js index a2fe299a785c..50d2a864e3c2 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js index 540bf9f46c2e..07acf47e9415 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js index 23e61b5c7746..140abf5fa07f 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js index 07f26ddc1bfe..ddc7969f81a8 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.assign.js index ec46603d736f..bf400a7daaee 100644 --- 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js index 3a455a152ad8..ff00bb92971c 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2022 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/test/test.main.js index 79f3940c2491..49038349a058 100644 --- 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 @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2025 The Stdlib Authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From 18f0198101014aa739bca3d91c7e0f111c278a79 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 13:23:41 -0700 Subject: [PATCH 03/12] fix: correct return types --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/minmaxf/README.md | 8 ++--- .../math/base/special/minmaxf/lib/assign.js | 12 +++---- .../math/base/special/minmaxf/lib/index.js | 6 ++-- .../math/base/special/minmaxf/lib/main.js | 12 +++---- .../base/special/minmaxf/test/test.main.js | 33 +++++++++---------- 5 files changed, 34 insertions(+), 37 deletions(-) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md b/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md index f421c4264ac7..8d79d49abd0c 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/README.md @@ -46,20 +46,20 @@ Returns the minimum and maximum of two single-precision floating-point numbers i ```javascript var v = minmaxf( 4.2, 3.14 ); -// returns [ 3.14, 4.2 ] +// returns [ 3.14, 4.2 ] v = minmaxf( +0.0, -0.0 ); -// returns [ -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 ] +// returns [ NaN, NaN ] v = minmaxf( NaN, 3.14 ); -// returns [ NaN, NaN ] +// returns [ NaN, NaN ] ``` #### minmaxf.assign( x, y, out, stride, offset ) diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js index 07acf47e9415..f4259c49122d 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/assign.js @@ -38,22 +38,22 @@ var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); * @returns {Collection} minimum and maximum values * * @example -* var out = new Float32Array( 2 ); +* var out = [ 0.0, 0.0 ]; * var v = minmaxf( 3.14, 4.2, out, 1, 0 ); -* // returns [ 3.14, 4.2 ] +* // returns [ 3.14, 4.2 ] * * var bool = ( v === out ); * // returns true * * @example -* var out = new Float32Array( 2 ); +* var out = [ 0.0, 0.0 ]; * var v = minmaxf( 3.14, NaN, out, 1, 0 ); -* // returns [ NaN, NaN ] +* // returns [ NaN, NaN ] * * @example -* var out = new Float32Array( 2 ); +* var out = [ 0.0, 0.0 ]; * var v = minmaxf( +0.0, -0.0, out, 1, 0 ); -* // returns [ -0.0, 0.0 ] +* // returns [ -0.0, 0.0 ] */ function minmaxf( x, y, out, stride, offset ) { if ( isnanf( x ) || isnanf( y ) ) { diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js index 140abf5fa07f..90779f99b96b 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/index.js @@ -27,13 +27,13 @@ * var minmaxf = require( '@stdlib/math/base/special/minmaxf' ); * * var v = minmaxf( 3.14, 4.2 ); -* // returns [ 3.14, 4.2 ] +* // returns [ 3.14, 4.2 ] * * v = minmaxf( 3.14, NaN ); -* // returns [ NaN, NaN ] +* // returns [ NaN, NaN ] * * v = minmaxf( +0.0, -0.0 ); -* // returns [ -0.0, 0.0 ] +* // returns [ -0.0, 0.0 ] * */ diff --git a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js index ddc7969f81a8..861d250caf65 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/main.js @@ -21,7 +21,6 @@ // MODULES // var assign = require( './assign.js' ); -var Float32Array = require( '@stdlib/array/float32' ); // MAIN // @@ -31,23 +30,22 @@ var Float32Array = require( '@stdlib/array/float32' ); * * @param {number} x - first number * @param {number} y - second number -* @returns {Float32Array} minimum and maximum values +* @returns {Array} minimum and maximum values * * @example * var v = minmaxf( 3.14, 4.2 ); -* // returns [ 3.14, 4.2 ] +* // returns [ 3.14, 4.2 ] * * @example * var v = minmaxf( 3.14, NaN ); -* // returns [ NaN, NaN ] +* // returns [ NaN, NaN ] * * @example * var v = minmaxf( +0.0, -0.0 ); -* // returns [ -0.0, 0.0 ] +* // returns [ -0.0, 0.0 ] */ function minmaxf( x, y ) { - var out = new Float32Array( 2 ); - return assign( x, y, out, 1, 0 ); + return assign( x, y, [ 0.0, 0.0 ], 1, 0 ); } 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 index 49038349a058..fd170e8a064a 100644 --- 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 @@ -24,7 +24,6 @@ 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 minmaxf = require( './../lib/main.js' ); @@ -41,11 +40,11 @@ tape( 'main export is a function', function test( t ) { tape( 'the function returns `NaN` for both the minimum and maximum value if provided a `NaN`', function test( t ) { var v; - v = minmaxf( NaN, float64ToFloat32( 3.14 ) ); + 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( float64ToFloat32( 3.14 ), NaN ); + v = minmaxf( 3.14, NaN ); t.strictEqual( isnanf( v[ 0 ] ), true, 'returns expected value' ); t.strictEqual( isnanf( v[ 1 ] ), true, 'returns expected value' ); @@ -59,13 +58,13 @@ tape( 'the function returns `NaN` for both the minimum and maximum value if prov tape( 'the function returns `-Infinity` as the minimum value if provided `-Infinity`', function test( t ) { var v; - v = minmaxf( NINF, float64ToFloat32( 3.14 ) ); + v = minmaxf( NINF, 3.14 ); t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); - t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); - v = minmaxf( float64ToFloat32( 3.14 ), NINF ); + v = minmaxf( 3.14, NINF ); t.strictEqual( v[ 0 ], NINF, 'returns expected value' ); - t.strictEqual( v[ 1 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); t.end(); }); @@ -73,12 +72,12 @@ tape( 'the function returns `-Infinity` as the minimum value if provided `-Infin tape( 'the function returns `+Infinity` as the maximum value if provided `+Infinity`', function test( t ) { var v; - v = minmaxf( PINF, float64ToFloat32( 3.14 ) ); - t.strictEqual( v[ 0 ], float64ToFloat32( 3.14 ), 'returns expected value' ); + v = minmaxf( PINF, 3.14 ); + t.strictEqual( v[ 0 ], 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' ); + v = minmaxf( 3.14, PINF ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); t.strictEqual( v[ 1 ], PINF, 'returns expected value' ); t.end(); @@ -109,13 +108,13 @@ tape( 'the function returns correctly signed zeros', function test( t ) { tape( 'the function returns the minimum and maximum values', 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( 4.2, 3.14 ); + t.strictEqual( v[ 0 ], 3.14, 'returns expected value' ); + t.strictEqual( v[ 1 ], 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' ); + 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(); }); From 9c33cf8e34a11f19c3e49c093bf0a37a46bd89c1 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 13:37:04 -0700 Subject: [PATCH 04/12] chore: fix lint error --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/minmaxf/lib/native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 12a8484e81ec..e5656e435397 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/native.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/lib/native.js @@ -36,7 +36,7 @@ var addon = require( './../src/addon.node' ); * * @example * var v = minmaxf( 3.14, 4.2 ); -* // returns [ 3.14, 4.2 ] +* // returns [ ~3.14, ~4.2 ] * * @example * var v = minmaxf( 3.14, NaN ); From 80f1008f92d43790462cf8b58cb993cfc90302d5 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 13:46:04 -0700 Subject: [PATCH 05/12] chore: fix lint error --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/minmaxf/benchmark/benchmark.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 9305a2cf72fa..8f04dac5a187 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/benchmark/benchmark.js @@ -104,7 +104,7 @@ bench( pkg+'::minf,maxf', function benchmark( b ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - // eslint-disable-next-line maxf-len + // 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' ); From f9acf9f83cb63e3daa3a4b4b62ec6fa032120f89 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 13:59:59 -0700 Subject: [PATCH 06/12] chore: fix lint error --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: passed - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/minmaxf/docs/repl.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 index eeec739973d5..641e2ce36c6b 100644 --- a/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt +++ b/lib/node_modules/@stdlib/math/base/special/minmaxf/docs/repl.txt @@ -1,6 +1,7 @@ {{alias}}( x, y ) - Returns the minimum and maximum of two single-precision floating-point numbers. + 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. @@ -29,8 +30,8 @@ {{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. + 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. From 661748f804d45c7ee8955df32b74a3339df9bc29 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 16:09:08 -0700 Subject: [PATCH 07/12] test: remove type conversion --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/minmaxf/test/test.assign.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 index bf400a7daaee..0650490dd01e 100644 --- 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 @@ -157,16 +157,16 @@ tape( 'the function supports providing an output object (array)', function test( var v; out = [ 0.0, 0.0 ]; - v = minmaxf( float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 1, 0 ); + v = minmaxf( 4.2, 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' ); + 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( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 1, 0 ); + v = minmaxf( -4.2, 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.strictEqual( v[ 0 ], -4.2, 'returns expected value' ); + t.strictEqual( v[ 1 ], 3.14, 'returns expected value' ); t.end(); }); From e144ecee87ab3ff5b1621ddc87bef9cae5edc8d1 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 16:11:02 -0700 Subject: [PATCH 08/12] chore: disable lint rule --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../@stdlib/math/base/special/minmaxf/test/test.assign.js | 8 ++++++++ 1 file changed, 8 insertions(+) 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 index 0650490dd01e..8d7f83eb2cb8 100644 --- 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 @@ -144,6 +144,8 @@ tape( 'the function returns the minimum and maximum values', function test( t ) t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); out = new Float32Array( 2 ); + + // eslint-disable-next-line max-len 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' ); @@ -182,6 +184,8 @@ tape( 'the function supports providing an output object (typed array)', function t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); out = new Float32Array( 2 ); + + // eslint-disable-next-line max-len 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' ); @@ -195,6 +199,8 @@ tape( 'the function supports specifying a stride', function test( t ) { var val; out = new Float32Array( 4 ); + + // eslint-disable-next-line max-len val = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 2, 0 ); t.strictEqual( val, out, 'returns output array' ); @@ -211,6 +217,8 @@ tape( 'the function supports specifying an offset', function test( t ) { var val; out = new Float32Array( 4 ); + + // eslint-disable-next-line max-len val = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 2, 1 ); t.strictEqual( val, out, 'returns output array' ); From e71d210e8c239f2f67772435ae10312ddb4017f4 Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Mon, 19 May 2025 18:46:32 -0700 Subject: [PATCH 09/12] chore: disable lint rule at the top --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../math/base/special/minmaxf/test/test.assign.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) 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 index 8d7f83eb2cb8..f8533930564b 100644 --- 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 @@ -16,6 +16,8 @@ * limitations under the License. */ +/* eslint-disable max-len */ + 'use strict'; // MODULES // @@ -144,8 +146,6 @@ tape( 'the function returns the minimum and maximum values', function test( t ) t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); out = new Float32Array( 2 ); - - // eslint-disable-next-line max-len 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' ); @@ -184,8 +184,6 @@ tape( 'the function supports providing an output object (typed array)', function t.strictEqual( v[ 1 ], float64ToFloat32( 4.2 ), 'returns expected value' ); out = new Float32Array( 2 ); - - // eslint-disable-next-line max-len 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' ); @@ -199,8 +197,6 @@ tape( 'the function supports specifying a stride', function test( t ) { var val; out = new Float32Array( 4 ); - - // eslint-disable-next-line max-len val = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 2, 0 ); t.strictEqual( val, out, 'returns output array' ); @@ -217,8 +213,6 @@ tape( 'the function supports specifying an offset', function test( t ) { var val; out = new Float32Array( 4 ); - - // eslint-disable-next-line max-len val = minmaxf( -float64ToFloat32( 4.2 ), float64ToFloat32( 3.14 ), out, 2, 1 ); t.strictEqual( val, out, 'returns output array' ); From 0915533d659cbe6bf075b1d65c2b6d6efcd3b039 Mon Sep 17 00:00:00 2001 From: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> Date: Mon, 26 May 2025 11:36:31 -0700 Subject: [PATCH 10/12] Update benchmark.native.js Signed-off-by: Karan Anand <119553199+anandkaranubc@users.noreply.github.com> --- .../math/base/special/minmaxf/benchmark/benchmark.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 4f85ea5a6b60..d337113b61c4 100644 --- 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 @@ -60,7 +60,7 @@ bench( pkg+'::native', opts, function benchmark( b ) { } b.toc(); if ( !isFloat32Array( z ) ) { - b.fail( 'should return a Float64Array' ); + b.fail( 'should return a Float32Array' ); } b.pass( 'benchmark finished' ); b.end(); From ad2ee84f0b7d21ca887bd4ff6b91b82a2b28c0fa Mon Sep 17 00:00:00 2001 From: Karan Anand Date: Tue, 10 Jun 2025 20:24:22 -0700 Subject: [PATCH 11/12] bench: use `random_uniform` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- .../minmaxf/benchmark/c/native/benchmark.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) 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 index 71114b855829..d7b1bf5e8b09 100644 --- 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 @@ -75,13 +75,15 @@ static double tic( void ) { } /** -* Generates a random number on the interval [0,1). +* Generates a random number on the interval [min,max). * -* @return random number +* @param min minimum value (inclusive) +* @param max maximum value (exclusive) +* @return random number */ -static float rand_float( void ) { - int r = rand(); - return (float)r / ( (float)RAND_MAX + 1.0f ); +static float random_uniform( const float min, const float max ) { + float v = (float)rand() / ( (float)RAND_MAX + 1.0f ); + return min + ( v*(max-min) ); } /** @@ -99,8 +101,8 @@ static double benchmark( void ) { int i; for( i = 0; i < 100; i++ ) { - x[ i ] = ( 1000.0f*rand_float() ) - 500.0f; - y[ i ] = ( 1000.0f*rand_float() ) - 500.0f; + x[ i ] = random_uniform( -500.0f, 500.0f ); + y[ i ] = random_uniform( -500.0f, 500.0f ); } t = tic(); From 038529a1307af08934f6a69955a10e0cb39d05ee Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Fri, 13 Jun 2025 17:59:28 -0400 Subject: [PATCH 12/12] refactor: use tuple for return type Signed-off-by: Philipp Burckhardt --- .../@stdlib/math/base/special/minmaxf/docs/types/index.d.ts | 2 +- .../@stdlib/math/base/special/minmaxf/docs/types/test.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 index b9daf1565cfa..27f9a7699d97 100644 --- 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 @@ -44,7 +44,7 @@ interface MinMaxf { * var v = minmaxf( +0.0, -0.0 ); * // returns [ -0.0, 0.0 ] */ - ( x: number, y: number ): Array; + ( x: number, y: number ): [ number, number ]; /** * Returns the minimum and maximum of two single-precision floating-point numbers and assigns results to a provided output array. 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 index 2b2d050ad0d2..55ec43444067 100644 --- 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 @@ -23,7 +23,7 @@ import minmaxf = require( './index' ); // The function returns an array of numbers... { - minmaxf( 3.0, -0.2 ); // $ExpectType number[] + minmaxf( 3.0, -0.2 ); // $ExpectType [number, number] } // The compiler throws an error if the function is provided an argument which is not a number...