diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/LICENSE b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/LICENSE new file mode 100644 index 000000000000..a7566ad6f2c3 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/LICENSE @@ -0,0 +1,192 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + +DEPENDENCIES & ATTRIBUTION + +The library links against the following external libraries or contains +implementations from the following external libraries, which have their own +licenses: + +* FreeBSD + +Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved. + +Developed at SunPro, a Sun Microsystems, Inc. business. +Permission to use, copy, modify, and distribute this +software is freely granted, provided that this notice +is preserved. diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/README.md b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/README.md new file mode 100644 index 000000000000..3969f8a1b5f6 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/README.md @@ -0,0 +1,200 @@ + + +# kernelLog1pf + +> Compute `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. + +
+ +## Usage + +```javascript +var kernelLog1pf = require( '@stdlib/math/base/special/kernel-log1pf' ); +``` + +#### kernelLog1pf( f ) + +Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. + +```javascript +var v = kernelLog1pf( 1.0 ); +// returns ~0.1931 + +v = kernelLog1pf( 1.4142135623730951 ); +// returns ~0.4672 + +v = kernelLog1pf( NaN ); +// returns NaN +``` + +
+ + + +
+ +## Notes + +- This function is a helper function for computing logarithms in base `e`. Argument reduction and adding the final term of the polynomial must be done by the caller for increased accuracy when different bases are used. For reference, see [`@stdlib/math/base/special/log2f`][@stdlib/math/base/special/log2f] and [`@stdlib/math/base/special/log10f`][@stdlib/math/base/special/log10f]. + +
+ + + +
+ +## Examples + + + +```javascript +var linspace = require( '@stdlib/array/base/linspace' ); +var sqrt = require( '@stdlib/math/base/special/sqrt' ); +var kernelLog1pf = require( '@stdlib/math/base/special/kernel-log1pf' ); + +var x = linspace( sqrtf( 2.0 ) / 2.0, sqrtf( 2.0 ), 100 ); + +var i; +for ( i = 0; i < x.length; i++ ) { + console.log( 'kernelLog1pf(%d) = %d', x[ i ], kernelLog1pf( x[ i ] ) ); +} +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/kernel_log1pf.h" +``` + +#### stdlib_base_kernel_log1pf( f ) + +Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. + +```c +float out = stdlib_base_kernel_log1pf( 1.0f ); +// returns ~0.1931f +``` + +The function accepts the following arguments: + +- **f**: `[in] float` input value. + +```c +float stdlib_base_kernel_log1pf( const float f ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/kernel_log1pf.h" +#include + +int main( void ) { + const float x[] = { 0.7071f, 0.7856f, 0.8642f, 0.9428f, 1.0213f, 1.0999f, 1.1785f, 1.2570f, 1.3356f, 1.4142f }; + + float out; + int i; + for ( i = 0; i < 10; i++ ) { + out = stdlib_base_kernel_log1pf( x[ i ] ); + printf ( "x[ i ]: %f, out: %f\n", x[ i ], out ); + } +} +``` + +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.js new file mode 100644 index 000000000000..716aadda47cc --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.js @@ -0,0 +1,51 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var kernelLog1pf = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() + 1.0 ) * 0.7071067811865476; + y = kernelLog1pf( x ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.native.js new file mode 100644 index 000000000000..2ac1b71e2260 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/benchmark.native.js @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var bench = require( '@stdlib/bench' ); +var randu = require( '@stdlib/random/base/randu' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + + +// VARIABLES // + +var kernelLog1pf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( kernelLog1pf instanceof Error ) +}; + + +// MAIN // + +bench( pkg+'::native', opts, function benchmark( b ) { + var x; + var y; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + x = ( randu() + 1.0 ) * 0.7071067811865476; + y = kernelLog1pf( x ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/c/native/Makefile b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/c/native/Makefile new file mode 100644 index 000000000000..a4bd7b38fd74 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/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/kernel-log1pf/benchmark/c/native/benchmark.c b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/c/native/benchmark.c new file mode 100644 index 000000000000..07df87b0b7f9 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/benchmark/c/native/benchmark.c @@ -0,0 +1,133 @@ +/** +* @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/kernel_log1pf.h" +#include +#include +#include +#include +#include + +#define NAME "kernel_log1pf" +#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 double rand_float( void ) { + int r = rand(); + return (float)r / ( (float)RAND_MAX + 1.0f ); +} + +/** +* Runs a benchmark. +* +* @return elapsed time in seconds +*/ +static double benchmark( void ) { + double elapsed; + float x; + float z; + double t; + int i; + + t = tic(); + for ( i = 0; i < ITERATIONS; i++ ) { + x = ( rand_float() + 1.0f ) * 0.7071067811865476f; + z = stdlib_base_kernel_log1pf( x ); + if ( z != z ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( z != z ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int i; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + for ( i = 0; i < REPEATS; i++ ) { + printf( "# c::%s\n", NAME ); + elapsed = benchmark(); + print_results( elapsed ); + printf( "ok %d benchmark finished\n", i+1 ); + } + print_summary( REPEATS, REPEATS ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/binding.gyp b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/binding.gyp new file mode 100644 index 000000000000..ec3992233442 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2024 The Stdlib Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A `.gyp` file for building a Node.js native add-on. +# +# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md +# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md +{ + # List of files to include in this file: + 'includes': [ + './include.gypi', + ], + + # Define variables to be used throughout the configuration for all targets: + 'variables': { + # Target name should match the add-on export name: + 'addon_target_name%': 'addon', + + # Set variables based on the host OS: + 'conditions': [ + [ + 'OS=="win"', + { + # Define the object file suffix: + 'obj': 'obj', + }, + { + # Define the object file suffix: + 'obj': 'o', + } + ], # end condition (OS=="win") + ], # end conditions + }, # end variables + + # Define compile targets: + 'targets': [ + + # Target to generate an add-on: + { + # The target name should match the add-on export name: + 'target_name': '<(addon_target_name)', + + # Define dependencies: + 'dependencies': [], + + # Define directories which contain relevant include headers: + 'include_dirs': [ + # Local include directory: + '<@(include_dirs)', + ], + + # List of source files: + 'sources': [ + '<@(src_files)', + ], + + # Settings which should be applied when a target's object files are used as linker input: + 'link_settings': { + # Define libraries: + 'libraries': [ + '<@(libraries)', + ], + + # Define library directories: + 'library_dirs': [ + '<@(library_dirs)', + ], + }, + + # C/C++ compiler flags: + 'cflags': [ + # Enable commonly used warning options: + '-Wall', + + # Aggressive optimization: + '-O3', + ], + + # C specific compiler flags: + 'cflags_c': [ + # Specify the C standard to which a program is expected to conform: + '-std=c99', + ], + + # C++ specific compiler flags: + 'cflags_cpp': [ + # Specify the C++ standard to which a program is expected to conform: + '-std=c++11', + ], + + # Linker flags: + 'ldflags': [], + + # Apply conditions based on the host OS: + 'conditions': [ + [ + 'OS=="mac"', + { + # Linker flags: + 'ldflags': [ + '-undefined dynamic_lookup', + '-Wl,-no-pie', + '-Wl,-search_paths_first', + ], + }, + ], # end condition (OS=="mac") + [ + 'OS!="win"', + { + # C/C++ flags: + 'cflags': [ + # Generate platform-independent code: + '-fPIC', + ], + }, + ], # end condition (OS!="win") + ], # end conditions + }, # end target <(addon_target_name) + + # Target to copy a generated add-on to a standard location: + { + 'target_name': 'copy_addon', + + # Declare that the output of this target is not linked: + 'type': 'none', + + # Define dependencies: + 'dependencies': [ + # Require that the add-on be generated before building this target: + '<(addon_target_name)', + ], + + # Define a list of actions: + 'actions': [ + { + 'action_name': 'copy_addon', + 'message': 'Copying addon...', + + # Explicitly list the inputs in the command-line invocation below: + 'inputs': [], + + # Declare the expected outputs: + 'outputs': [ + '<(addon_output_dir)/<(addon_target_name).node', + ], + + # Define the command-line invocation: + 'action': [ + 'cp', + '<(PRODUCT_DIR)/<(addon_target_name).node', + '<(addon_output_dir)/<(addon_target_name).node', + ], + }, + ], # end actions + }, # end target copy_addon + ], # end targets +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/repl.txt b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/repl.txt new file mode 100644 index 000000000000..62f459f9a2c0 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/repl.txt @@ -0,0 +1,30 @@ + +{{alias}}( f ) + Computes `logf(1+f) - f` for `1+f` in ~[sqrtf(2)/2, sqrtf(2)]. + + This function provides a common means for computing logarithms in base e. + Argument reduction and adding the final term of the polynomial must be done + by the caller for increased accuracy when different bases are used. + + Parameters + ---------- + f: number + Input value. + + Returns + ------- + out: number + Function value. + + Examples + -------- + > var y = {{alias}}( 1.0 ) + ~0.1931 + > y = {{alias}}( 1.4142135623730951 ) + ~0.4672 + > y = {{alias}}( NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/index.d.ts b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/index.d.ts new file mode 100644 index 000000000000..0d7b310a17d4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/index.d.ts @@ -0,0 +1,50 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. +* +* ## Notes +* +* - This function provides a common means for computing logarithms in base `e`. Argument reduction and adding the final term of the polynomial must be done by the caller for increased accuracy when different bases are used. +* +* @param f - input value +* @returns function value +* +* @example +* var v = kernelLog1pf( 1.0 ); +* // returns ~0.1931 +* +* @example +* var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +* +* var v = kernelLog1pf( sqrtf( 2.0 ) ); +* // returns ~0.4672 +* +* @example +* var v = kernelLog1pf( NaN ); +* // returns NaN +*/ +declare function kernelLog1pf( f: number ): number; + + +// EXPORTS // + +export = kernelLog1pf; diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/test.ts b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/test.ts new file mode 100644 index 000000000000..0c854034e513 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/docs/types/test.ts @@ -0,0 +1,43 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import kernelLog1pf = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + kernelLog1pf( 0.5 ); // $ExpectType number +} + +// The compiler throws an error if the function is not provided a number... +{ + kernelLog1pf( true ); // $ExpectError + kernelLog1pf( false ); // $ExpectError + kernelLog1pf( '5' ); // $ExpectError + kernelLog1pf( [] ); // $ExpectError + kernelLog1pf( {} ); // $ExpectError + kernelLog1pf( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + kernelLog1pf(); // $ExpectError + kernelLog1pf( 0, 2 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/c/Makefile b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/c/Makefile new file mode 100644 index 000000000000..25ced822f96a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/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/kernel-log1pf/examples/c/example.c b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/c/example.c new file mode 100644 index 000000000000..6277b1eca262 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/c/example.c @@ -0,0 +1,31 @@ +/** +* @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/kernel_log1pf.h" +#include + +int main( void ) { + const float x[] = { 0.7071f, 0.7856f, 0.8642f, 0.9428f, 1.0213f, 1.0999f, 1.1785f, 1.2570f, 1.3356f, 1.4142f }; + + float out; + int i; + for ( i = 0; i < 10; i++ ) { + out = stdlib_base_kernel_log1pf( x[ i ] ); + printf ( "x[ i ]: %f, out: %f\n", x[ i ], out ); + } +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/index.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/index.js new file mode 100644 index 000000000000..f1dca119ea63 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/examples/index.js @@ -0,0 +1,30 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var linspace = require( '@stdlib/array/base/linspace' ); +var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +var kernelLog1pf = require( './../lib' ); + +var x = linspace( sqrtf( 2.0 ) / 2.0, sqrtf( 2.0 ), 100 ); + +var i; +for ( i = 0; i < x.length; i++ ) { + console.log( 'kernelLog1pf(%d) = %d', x[ i ], kernelLog1pf( x[ i ] ) ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/include.gypi b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/include.gypi new file mode 100644 index 000000000000..ecfaf82a3279 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/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': [ + ' + +/* +* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. +*/ +#ifdef __cplusplus +extern "C" { +#endif + +/** +* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. +*/ +float stdlib_base_kernel_log1pf( const float f ); + +#ifdef __cplusplus +} +#endif + +#endif // !STDLIB_MATH_BASE_SPECIAL_KERNEL_LOG1PF_H diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/index.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/index.js new file mode 100644 index 000000000000..ba150132953e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/index.js @@ -0,0 +1,47 @@ +/** +* @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'; + +/** +* Compute `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. +* +* @module @stdlib/math/base/special/kernel-log1pf +* +* @example +* var sqrtf = require( '@stdlib/math/base/special/sqrtf' ); +* var kernelLog1pf = require( '@stdlib/math/base/special/kernel-log1pf' ); +* +* var v = kernelLog1pf( 1.0 ); +* // returns ~0.1931 +* +* v = kernelLog1pf( sqrtf( 2.0 ) ); +* // returns ~0.4672 +* +* v = kernelLog1pf( NaN ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/main.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/main.js new file mode 100644 index 000000000000..8de3e0cb589a --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/main.js @@ -0,0 +1,83 @@ +/** +* @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. +* +* +* ## Notice +* +* The following copyright and license were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_log.h}. The implementation follows the original, but has been modified for JavaScript. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +'use strict'; + +// MODULES // + +var polyvalP = require( './polyval_p.js' ); +var polyvalQ = require( './polyval_q.js' ); + + +// MAIN // + +/** +* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. +* +* @param {number} f - input value +* @returns {number} function value +* +* @example +* var v = kernelLog1pf( 1.0 ); +* // returns ~0.1931 +* +* @example +* var v = kernelLog1pf( 1.4142135623730951 ); +* // returns ~0.4672 +* +* @example +* var v = kernelLog1pf( NaN ); +* // returns NaN +*/ +function kernelLog1pf( f ) { + var hfsq; + var t1; + var t2; + var s; + var z; + var R; + var w; + + s = f / ( 2.0 + f ); + z = s * s; + w = z * z; + t1 = w * polyvalP( w ); + t2 = z * polyvalQ( w ); + R = t2 + t1; + hfsq = 0.5 * f * f; + return s * ( hfsq + R ); +} + + +// EXPORTS // + +module.exports = kernelLog1pf; diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/native.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/native.js new file mode 100644 index 000000000000..db3b69df7ec5 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/native.js @@ -0,0 +1,54 @@ +/** +* @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 addon = require( './../src/addon.node' ); + + +// MAIN // + +/** +* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. +* +* @private +* @param {number} f - input value +* @returns {number} function value +* +* @example +* var v = kernelLog1pf( 1.0 ); +* // returns ~0.1931 +* +* @example +* var v = kernelLog1pf( 1.4142135623730951 ); +* // returns ~0.4672 +* +* @example +* var v = kernelLog1pf( NaN ); +* // returns NaN +*/ +function kernelLog1pf( f ) { + return addon( f ); +} + + +// EXPORTS // + +module.exports = kernelLog1pf; diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_p.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_p.js new file mode 100644 index 000000000000..203b4d15bae4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_p.js @@ -0,0 +1,47 @@ +/** +* @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. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 0.40000972152; + } + return 0.40000972152 + (x * 0.24279078841); +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_q.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_q.js new file mode 100644 index 000000000000..1f09b54ca5da --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/lib/polyval_q.js @@ -0,0 +1,47 @@ +/** +* @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. +*/ + +/* This is a generated file. Do not edit directly. */ +'use strict'; + +// MAIN // + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @private +* @param {number} x - value at which to evaluate the polynomial +* @returns {number} evaluated polynomial +*/ +function evalpoly( x ) { + if ( x === 0.0 ) { + return 0.66666662693; + } + return 0.66666662693 + (x * 0.28498786688); +} + + +// EXPORTS // + +module.exports = evalpoly; diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/manifest.json b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/manifest.json new file mode 100644 index 000000000000..6bfc690068b2 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/manifest.json @@ -0,0 +1,67 @@ +{ + "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/math/base/napi/unary" + ] + }, + { + "task": "benchmark", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + }, + { + "task": "examples", + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/package.json b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/package.json new file mode 100644 index 000000000000..00c3a3deecae --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/math/base/special/kernel-log1pf", + "version": "0.0.0", + "description": "Compute logf(1+f) - f for 1+f in ~[sqrtf(2)/2, sqrtf(2)].", + "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", + "scripts": "./scripts", + "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", + "logf", + "kernel", + "logarithm" + ] +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/scripts/evalpoly.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/scripts/evalpoly.js new file mode 100644 index 000000000000..dc76c66ccb94 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/scripts/evalpoly.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. +*/ + +/* +* This script compiles modules for evaluating polynomial functions. If any polynomial coefficients change, this script should be rerun to update the compiled files. +*/ +'use strict'; + +// MODULES // + +var resolve = require( 'path' ).resolve; +var readFileSync = require( '@stdlib/fs/read-file' ).sync; +var writeFileSync = require( '@stdlib/fs/write-file' ).sync; +var currentYear = require( '@stdlib/time/current-year' ); +var substringBefore = require( '@stdlib/string/substring-before' ); +var substringAfter = require( '@stdlib/string/substring-after' ); +var format = require( '@stdlib/string/format' ); +var licenseHeader = require( '@stdlib/_tools/licenses/header' ); +var compile = require( '@stdlib/math/base/tools/evalpoly-compile' ); +var compileC = require( '@stdlib/math/base/tools/evalpoly-compile-c' ); + + +// VARIABLES // + +// Polynomial coefficients ordered in ascending degree... +var P = [ + 4.0000972152e-01, // 0xaaaaaa.0p-24 + 2.4279078841e-01, // 0xccce13.0p-25 +]; +var Q = [ + 6.66666662693e-01, // 0x91e9ee.0p-25 + 2.8498786688e-01, // 0xf89e26.0p-26 +]; + +// Header to add to output files: +var header = licenseHeader( 'Apache-2.0', 'js', { + 'year': currentYear(), + 'copyright': 'The Stdlib Authors' +}); +header += '\n/* This is a generated file. Do not edit directly. */\n'; + + +// FUNCTIONS // + +/** +* Inserts a compiled function into file content. +* +* @private +* @param {string} text - source content +* @param {string} id - function identifier +* @param {string} str - function string +* @returns {string} updated content +*/ +function insert( text, id, str ) { + var before; + var after; + var begin; + var end; + + begin = '// BEGIN: '+id; + end = '// END: '+id; + + before = substringBefore( text, begin ); + after = substringAfter( text, end ); + + return format( '%s// BEGIN: %s\n\n%s\n%s%s', before, id, str, end, after ); +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var fpath; + var copts; + var opts; + var file; + var str; + + opts = { + 'encoding': 'utf8' + }; + + fpath = resolve( __dirname, '..', 'lib', 'polyval_p.js' ); + str = header + compile( P ); + writeFileSync( fpath, str, opts ); + + fpath = resolve( __dirname, '..', 'lib', 'polyval_q.js' ); + str = header + compile( Q ); + writeFileSync( fpath, str, opts ); + + copts = { + 'dtype': 'float', + 'name': '' + }; + + fpath = resolve( __dirname, '..', 'src', 'main.c' ); + file = readFileSync( fpath, opts ); + + copts.name = 'polyval_p'; + str = compileC( P, copts ); + file = insert( file, copts.name, str ); + + copts.name = 'polyval_q'; + str = compileC( Q, copts ); + file = insert( file, copts.name, str ); + + writeFileSync( fpath, file, opts ); +} + +main(); diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/Makefile b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/Makefile new file mode 100644 index 000000000000..7733b6180cb4 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/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/kernel-log1pf/src/addon.c b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/addon.c new file mode 100644 index 000000000000..f974ccc545ef --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/addon.c @@ -0,0 +1,23 @@ +/** +* @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/kernel_log1pf.h" +#include "stdlib/math/base/napi/unary.h" + +// cppcheck-suppress shadowFunction +STDLIB_MATH_BASE_NAPI_MODULE_F_F( stdlib_base_kernel_log1pf ) diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/main.c b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/main.c new file mode 100644 index 000000000000..c5015145105e --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/src/main.c @@ -0,0 +1,107 @@ +/** +* @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. +* +* +* ## Notice +* +* The following copyright, license, and long comment were part of the original implementation available as part of [FreeBSD]{@link https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/k_log.c}. The implementation follows the original, but has been modified according to project conventions. +* +* ```text +* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. +* +* Developed at SunPro, a Sun Microsystems, Inc. business. +* Permission to use, copy, modify, and distribute this +* software is freely granted, provided that this notice +* is preserved. +* ``` +*/ + +#include "stdlib/math/base/special/kernel_log1pf.h" +#include + +/* Begin auto-generated functions. The following functions are auto-generated. Do not edit directly. */ + +// BEGIN: polyval_p + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @param x value at which to evaluate the polynomial +* @return evaluated polynomial +*/ +static float polyval_p( const float x ) { + return 0.40000972152 + (x * 0.24279078841); +} + +// END: polyval_p + +// BEGIN: polyval_q + +/** +* Evaluates a polynomial. +* +* ## Notes +* +* - The implementation uses [Horner's rule][horners-method] for efficient computation. +* +* [horners-method]: https://en.wikipedia.org/wiki/Horner%27s_method +* +* @param x value at which to evaluate the polynomial +* @return evaluated polynomial +*/ +static float polyval_q( const float x ) { + return 0.66666662693 + (x * 0.28498786688); +} + +// END: polyval_q + +/* End auto-generated functions. */ + +/** +* Computes `logf(1+f) - f` for `1+f` in `~[sqrtf(2)/2, sqrtf(2)]`. +* +* @param f input value +* @return output value +* +* @example +* float out = stdlib_base_kernel_log1pf( 1.0f ); +* // returns ~0.1931f +*/ +float stdlib_base_kernel_log1pf( const float f ) { + float hfsq; + float t1; + float t2; + float R; + float s; + float z; + float w; + + s = f / ( 2.0f + f ); + z = s * s; + w = z * z; + t1 = w * polyval_p( w ); + t2 = z * polyval_q( w ); + R = t2 + t1; + hfsq = 0.5f * f * f; + return s * ( hfsq + R ); +} diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/tests/test.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/tests/test.js new file mode 100644 index 000000000000..62a34216611d --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/tests/test.js @@ -0,0 +1,73 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var kernelLog1pf = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof kernelLog1pf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', function test( t ) { + var v = kernelLog1pf( NaN ); + t.equal( isnanf( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function correctly computes `logf(1+f) - f` for `1+f` satisfying `sqrtf( 2 ) / 2 < 1+f < sqrtf( 2 )`', function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = [ + 1.4142135623730951 + ]; + expected = [ + 0.46716000147788844 + ]; + + for ( i = 0; i < x.length; i++ ) { + y = kernelLog1pf( x[ i ] ); + e = float64ToFloat32( expected[ i ] ); + if ( y === e ) { + t.equal( y, e, 'x: '+x[ i ]+'. E: '+e ); + } else { + delta = absf( y - e ); + tol = 2.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/tests/test.native.js b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/tests/test.native.js new file mode 100644 index 000000000000..1e93447cca38 --- /dev/null +++ b/lib/node_modules/@stdlib/math/base/special/kernel-log1pf/tests/test.native.js @@ -0,0 +1,82 @@ +/** +* @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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var absf = require( '@stdlib/math/base/special/absf' ); +var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + + +// VARIABLES // + +var kernelLog1pf = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( kernelLog1pf instanceof Error ) +}; + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof kernelLog1pf, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `NaN` if provided `NaN`', opts, function test( t ) { + var v = kernelLog1pf( NaN ); + t.equal( isnan( v ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function correctly computes `logf(1+f) - f` for `1+f` satisfying `sqrtf( 2 ) / 2 < 1+f < sqrtf( 2 )`', opts, function test( t ) { + var expected; + var delta; + var tol; + var x; + var y; + var i; + var e; + + x = [ + 1.4142135623730951 + ]; + expected = [ + 0.46716000147788844 + ]; + + for ( i = 0; i < x.length; i++ ) { + y = kernelLog1pf( x[ i ] ); + e = float64ToFloat32( expected[ i ] ); + if ( y === e ) { + t.equal( y, e, 'x: '+x[ i ]+'. E: '+e ); + } else { + delta = absf( y - e ); + tol = 8.0 * EPS * absf( e ); + t.ok( delta <= tol, 'within tolerance. x: '+x[ i ]+'. y: '+y+'. E: '+e+'. tol: '+tol+'. Δ: '+delta+'.' ); + } + } + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/README.md b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/README.md index 93d13d5a9f6e..70818ac6fa58 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/README.md +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/README.md @@ -51,7 +51,7 @@ The [arithmetic mean][arithmetic-mean] is defined as var dsnanmeanwd = require( '@stdlib/stats/base/dsnanmeanwd' ); ``` -#### dsnanmeanwd( N, x, stride ) +#### dsnanmeanwd( N, x, strideX ) Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array `x`, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result. @@ -59,9 +59,8 @@ Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-p var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -var N = x.length; -var v = dsnanmeanwd( N, x, 1 ); +var v = dsnanmeanwd( x.length, x, 1 ); // returns ~0.3333 ``` @@ -69,18 +68,16 @@ The function has the following parameters: - **N**: number of indexed elements. - **x**: input [`Float32Array`][@stdlib/array/float32]. -- **stride**: index increment for `x`. +- **strideX**: stride length for `x`. -The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`, +The `N` and stride parameters determine which elements in `x` are accessed at runtime. For example, to compute the [arithmetic mean][arithmetic-mean] of every other element in `x`, ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 1.0, 2.0, 2.0, -7.0, -2.0, 3.0, 4.0, 2.0, NaN ] ); -var N = floor( x.length / 2 ); -var v = dsnanmeanwd( N, x, 2 ); +var v = dsnanmeanwd( 4, x, 2 ); // returns 1.25 ``` @@ -90,18 +87,15 @@ Note that indexing is relative to the first index. To introduce an offset, use [ ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x0 = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); var x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element -var N = floor( x0.length / 2 ); - -var v = dsnanmeanwd( N, x1, 2 ); +var v = dsnanmeanwd( 4, x1, 2 ); // returns 1.25 ``` -#### dsnanmeanwd.ndarray( N, x, stride, offset ) +#### dsnanmeanwd.ndarray( N, x, strideX, offsetX ) Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics. @@ -109,26 +103,23 @@ Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-p var Float32Array = require( '@stdlib/array/float32' ); var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -var N = x.length; -var v = dsnanmeanwd.ndarray( N, x, 1, 0 ); +var v = dsnanmeanwd.ndarray( x.length, x, 1, 0 ); // returns ~0.33333 ``` The function has the following additional parameters: -- **offset**: starting index for `x`. +- **offsetX**: starting index for `x`. -While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other value in `x` starting from the second value +While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameter supports indexing semantics based on a starting index. For example, to calculate the [arithmetic mean][arithmetic-mean] for every other element in `x` starting from the second element ```javascript var Float32Array = require( '@stdlib/array/float32' ); -var floor = require( '@stdlib/math/base/special/floor' ); var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -var N = floor( x.length / 2 ); -var v = dsnanmeanwd.ndarray( N, x, 2, 1 ); +var v = dsnanmeanwd.ndarray( 4, x, 2, 1 ); // returns 1.25 ``` @@ -181,6 +172,107 @@ console.log( v ); + + +
+ +### Usage + +```c +#include "stdlib/stats/base/dsnanmeanwd.h" +``` + +#### stdlib_strided_dsnanmeanwd( N, \*X, strideX ) + +Computes the arithmetic mean of a single-precision floating-point strided array `x`, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result. + +```c +const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f }; + +double v = stdlib_strided_dsnanmeanwd( 6, x, 2 ); +// returns 1.25 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. + +```c +double stdlib_strided_dsnanmeanwd( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); +``` + +#### stdlib_strided_dsnanmeanwd_ndarray( N, \*X, strideX, offsetX ) + +Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics. + +```c +const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f }; + +double v = stdlib_strided_dsnanmeanwd_ndarray( 6, x, 2, 0 ); +// returns 1.25 +``` + +The function accepts the following arguments: + +- **N**: `[in] CBLAS_INT` number of indexed elements. +- **X**: `[in] float*` input array. +- **strideX**: `[in] CBLAS_INT` stride length for `X`. +- **offsetX**: `[in] CBLAS_INT` starting index for `X`. + +```c +double stdlib_strided_dsnanmeanwd_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/dsnanmeanwd.h" +#include + +int main( void ) { + // Create a strided array: + const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f }; + + // Specify the number of elements: + const int N = 6; + + // Specify the stride length: + const int strideX = 2; + + // Compute the arithmetic mean: + double v = stdlib_strided_dsnanmeanwd( N, x, strideX ); + + // Print the result: + printf( "mean: %f\n", v ); +} +``` + +
+ + + + + + + * * *
diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.js index 575114a709f7..210ea86873fd 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.js @@ -21,16 +21,30 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var dsnanmeanwd = require( './../lib/dsnanmeanwd.js' ); // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.2 ) ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -39,17 +53,7 @@ var dsnanmeanwd = require( './../lib/dsnanmeanwd.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.native.js index c34e6b4d376d..292ba3ab1780 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.native.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,6 +41,19 @@ var opts = { // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.2 ) ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -48,17 +62,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.js index 4d1fbdbdf728..cef9bd58b343 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.js @@ -21,16 +21,30 @@ // MODULES // var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var pkg = require( './../package.json' ).name; var dsnanmeanwd = require( './../lib/ndarray.js' ); // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.2 ) ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -39,17 +53,7 @@ var dsnanmeanwd = require( './../lib/ndarray.js' ); * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.native.js index 6099d61b01fc..642ae71cec1e 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/benchmark.ndarray.native.js @@ -22,10 +22,11 @@ var resolve = require( 'path' ).resolve; var bench = require( '@stdlib/bench' ); -var randu = require( '@stdlib/random/base/randu' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var filledarrayBy = require( '@stdlib/array/filled-by' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); -var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); var pkg = require( './../package.json' ).name; @@ -40,6 +41,19 @@ var opts = { // FUNCTIONS // +/** +* Returns a random value or `NaN`. +* +* @private +* @returns {number} random number or `NaN` +*/ +function rand() { + if ( bernoulli( 0.2 ) ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + /** * Creates a benchmark function. * @@ -48,17 +62,7 @@ var opts = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x; - var i; - - x = new Float32Array( len ); - for ( i = 0; i < x.length; i++ ) { - if ( randu() < 0.2 ) { - x[ i ] = NaN; - } else { - x[ i ] = ( randu()*20.0 ) - 10.0; - } - } + var x = filledarrayBy( len, 'float32', rand ); return benchmark; function benchmark( b ) { diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/c/benchmark.length.c index 39e750975707..5f49519a0447 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/c/benchmark.length.c +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/benchmark/c/benchmark.length.c @@ -94,7 +94,7 @@ static float rand_float( void ) { * @param len array length * @return elapsed time in seconds */ -static double benchmark( int iterations, int len ) { +static double benchmark1( int iterations, int len ) { double elapsed; float x[ len ]; double v; @@ -102,6 +102,7 @@ static double benchmark( int iterations, int len ) { int i; for ( i = 0; i < len; i++ ) { + // cppcheck-suppress uninitvar x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; } v = 0.0; @@ -120,6 +121,40 @@ static double benchmark( int iterations, int len ) { return elapsed; } +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark2( int iterations, int len ) { + double elapsed; + float x[ len ]; + double v; + double t; + int i; + + for ( i = 0; i < len; i++ ) { + // cppcheck-suppress uninitvar + x[ i ] = ( rand_float()*20000.0f ) - 10000.0f; + } + v = 0.0; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + v = stdlib_strided_dsnanmeanwd_ndarray( len, x, 1, 0 ); + if ( v != v ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( v != v ) { + printf( "should not return NaN\n" ); + } + return elapsed; +} + /** * Main execution sequence. */ @@ -142,7 +177,18 @@ int main( void ) { for ( j = 0; j < REPEATS; j++ ) { count += 1; printf( "# c::%s:len=%d\n", NAME, len ); - elapsed = benchmark( iter, len ); + elapsed = benchmark1( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + for ( i = MIN; i <= MAX; i++ ) { + len = pow( 10, i ); + iter = ITERATIONS / pow( 10, i-1 ); + for ( j = 0; j < REPEATS; j++ ) { + count += 1; + printf( "# c::%s:ndarray:len=%d\n", NAME, len ); + elapsed = benchmark2( iter, len ); print_results( iter, elapsed ); printf( "ok %d benchmark finished\n", count ); } diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/repl.txt b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/repl.txt index 418ac4c8d5a7..e850ba4a96b2 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/repl.txt +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/repl.txt @@ -1,11 +1,11 @@ -{{alias}}( N, x, stride ) +{{alias}}( N, x, strideX ) Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result. - The `N` and `stride` parameters determine which elements in `x` are accessed - at runtime. + The `N` and stride parameters determine which elements in the strided array + are accessed at runtime. Indexing is relative to the first index. To introduce an offset, use a typed array view. @@ -22,8 +22,8 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. Returns ------- @@ -37,28 +37,25 @@ > {{alias}}( x.length, x, 1 ) ~0.3333 - // Using `N` and `stride` parameters: + // Using `N` and stride parameters: > x = new {{alias:@stdlib/array/float32}}( [ -2.0, 1.0, 1.0, -5.0, 2.0, -1.0, NaN ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > var stride = 2; - > {{alias}}( N, x, stride ) + > {{alias}}( 3, x, 2 ) ~0.3333 // Using view offsets: > var x0 = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] ); > var x1 = new {{alias:@stdlib/array/float32}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); - > N = {{alias:@stdlib/math/base/special/floor}}( x0.length / 2 ); - > stride = 2; - > {{alias}}( N, x1, stride ) + > {{alias}}( 3, x1, 2 ) ~-0.3333 -{{alias}}.ndarray( N, x, stride, offset ) + +{{alias}}.ndarray( N, x, strideX, offsetX ) Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics. While typed array views mandate a view offset based on the underlying - buffer, the `offset` parameter supports indexing semantics based on a + buffer, the offset parameter supports indexing semantics based on a starting index. Parameters @@ -69,10 +66,10 @@ x: Float32Array Input array. - stride: integer - Index increment. + strideX: integer + Stride length. - offset: integer + offsetX: integer Starting index. Returns @@ -89,8 +86,7 @@ // Using offset parameter: > var x = new {{alias:@stdlib/array/float32}}( [ 1.0, -2.0, 3.0, 2.0, 5.0, -1.0, NaN ] ); - > var N = {{alias:@stdlib/math/base/special/floor}}( x.length / 2 ); - > {{alias}}.ndarray( N, x, 2, 1 ) + > {{alias}}.ndarray( 3, x, 2, 1 ) ~-0.3333 See Also diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/types/index.d.ts b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/types/index.d.ts index 0c2119fa87cc..f989e4f30962 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/docs/types/index.d.ts @@ -38,15 +38,15 @@ interface Routine { * var v = dsnanmeanwd( x.length, x, 1 ); * // returns ~0.3333 */ - ( N: number, x: Float32Array, stride: number ): number; + ( N: number, x: Float32Array, strideX: number ): number; /** * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics. * * @param N - number of indexed elements * @param x - input array - * @param stride - stride length - * @param offset - starting index + * @param strideX - stride length + * @param offsetX - starting index * @returns arithmetic mean * * @example @@ -57,7 +57,7 @@ interface Routine { * var v = dsnanmeanwd.ndarray( x.length, x, 1, 0 ); * // returns ~0.3333 */ - ndarray( N: number, x: Float32Array, stride: number, offset: number ): number; + ndarray( N: number, x: Float32Array, strideX: number, offsetX: number ): number; } /** @@ -65,7 +65,7 @@ interface Routine { * * @param N - number of indexed elements * @param x - input array -* @param stride - stride length +* @param strideX - stride length * @returns arithmetic mean * * @example diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/examples/c/example.c index 06a583cc1edd..40de65e3f2c3 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/examples/c/example.c +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/examples/c/example.c @@ -17,21 +17,20 @@ */ #include "stdlib/stats/base/dsnanmeanwd.h" -#include #include int main( void ) { // Create a strided array: - float x[] = { 1.0, 2.0, 0.0/0.0, 3.0, 0.0/0.0, 4.0, 5.0, 6.0, 0.0/0.0, 7.0, 8.0, 0.0/0.0 }; + const float x[] = { 1.0f, 2.0f, 0.0f/0.0f, 3.0f, 0.0f/0.0f, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, 0.0f/0.0f }; // Specify the number of elements: - int64_t N = 6; + const int N = 6; // Specify the stride length: - int64_t stride = 2; + const int strideX = 2; // Compute the arithmetic mean: - double v = stdlib_strided_dsnanmeanwd( N, x, stride ); + double v = stdlib_strided_dsnanmeanwd( N, x, strideX ); // Print the result: printf( "mean: %f\n", v ); diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/include.gypi b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/include.gypi index 868c5c12e852..26476a8c2655 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/include.gypi +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/include.gypi @@ -36,7 +36,7 @@ # Source files: 'src_files': [ - '<(src_dir)/addon.cpp', + '<(src_dir)/addon.c', ' +#include "stdlib/blas/base/shared.h" /* * If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler. @@ -31,7 +31,12 @@ extern "C" { /** * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and return an extended precision result. */ -double stdlib_strided_dsnanmeanwd( const int64_t N, const float *X, const int64_t stride ); +double API_SUFFIX(stdlib_strided_dsnanmeanwd)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ); + +/** +* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics. +*/ +double API_SUFFIX(stdlib_strided_dsnanmeanwd_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ); #ifdef __cplusplus } diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.js index d0dc54b65649..64f2c96f730a 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.js @@ -18,6 +18,12 @@ 'use strict'; +// MODULES // + +var stride2offset = require( '@stdlib/strided/base/stride2offset' ); +var ndarray = require( './ndarray.js' ); + + // MAIN // /** @@ -43,50 +49,19 @@ * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} arithmetic mean * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = dsnanmeanwd( N, x, 1 ); +* var v = dsnanmeanwd( x.length, x, 1 ); * // returns ~0.3333 */ -function dsnanmeanwd( N, x, stride ) { - var mu; - var ix; - var v; - var n; - var i; - - if ( N <= 0 ) { - return NaN; - } - if ( N === 1 || stride === 0 ) { - return x[ 0 ]; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; - } - mu = 0.0; - n = 0; - for ( i = 0; i < N; i++ ) { - v = x[ ix ]; - if ( v === v ) { - n += 1; - mu += ( v-mu ) / n; - } - ix += stride; - } - if ( n === 0 ) { - return NaN; - } - return mu; +function dsnanmeanwd( N, x, strideX ) { + return ndarray( N, x, strideX, stride2offset( N, strideX ) ); } diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.native.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.native.js index f6075d835429..a45ed43370ec 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.native.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/dsnanmeanwd.native.js @@ -30,20 +30,19 @@ var addon = require( './../src/addon.node' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length +* @param {integer} strideX - stride length * @returns {number} arithmetic mean * * @example * var Float32Array = require( '@stdlib/array/float32' ); * * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = dsnanmeanwd( N, x, 1 ); +* var v = dsnanmeanwd( x.length, x, 1 ); * // returns ~0.3333 */ -function dsnanmeanwd( N, x, stride ) { - return addon( N, x, stride ); +function dsnanmeanwd( N, x, strideX ) { + return addon( N, x, strideX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/index.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/index.js index b24b76ac2575..e84793d1a98c 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/index.js @@ -28,20 +28,17 @@ * var dsnanmeanwd = require( '@stdlib/stats/base/dsnanmeanwd' ); * * var x = new Float32Array( [ 1.0, -2.0, NaN, 2.0 ] ); -* var N = x.length; * -* var v = dsnanmeanwd( N, x, 1 ); +* var v = dsnanmeanwd( x.length, x, 1 ); * // returns ~0.3333 * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * var dsnanmeanwd = require( '@stdlib/stats/base/dsnanmeanwd' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = dsnanmeanwd.ndarray( N, x, 2, 1 ); +* var v = dsnanmeanwd.ndarray( 4, x, 2, 1 ); * // returns 1.25 */ diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.js index a73ce982cd6b..6eca1731ac59 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.js @@ -43,21 +43,19 @@ * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} arithmetic mean * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = dsnanmeanwd( N, x, 2, 1 ); +* var v = dsnanmeanwd( 4, x, 2, 1 ); * // returns 1.25 */ -function dsnanmeanwd( N, x, stride, offset ) { +function dsnanmeanwd( N, x, strideX, offsetX ) { var mu; var ix; var v; @@ -67,10 +65,10 @@ function dsnanmeanwd( N, x, stride, offset ) { if ( N <= 0 ) { return NaN; } - if ( N === 1 || stride === 0 ) { - return x[ offset ]; + if ( N === 1 || strideX === 0 ) { + return x[ offsetX ]; } - ix = offset; + ix = offsetX; mu = 0.0; n = 0; for ( i = 0; i < N; i++ ) { @@ -79,7 +77,7 @@ function dsnanmeanwd( N, x, stride, offset ) { n += 1; mu += ( v-mu ) / n; } - ix += stride; + ix += strideX; } if ( n === 0 ) { return NaN; diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.native.js index e4433f7c17ea..e51f62d7eee1 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/lib/ndarray.native.js @@ -20,8 +20,7 @@ // MODULES // -var Float32Array = require( '@stdlib/array/float32' ); -var addon = require( './dsnanmeanwd.native.js' ); +var addon = require( './../src/addon.node' ); // MAIN // @@ -31,27 +30,20 @@ var addon = require( './dsnanmeanwd.native.js' ); * * @param {PositiveInteger} N - number of indexed elements * @param {Float32Array} x - input array -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - starting index +* @param {integer} strideX - stride length +* @param {NonNegativeInteger} offsetX - starting index * @returns {number} arithmetic mean * * @example * var Float32Array = require( '@stdlib/array/float32' ); -* var floor = require( '@stdlib/math/base/special/floor' ); * * var x = new Float32Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0, NaN ] ); -* var N = floor( x.length / 2 ); * -* var v = dsnanmeanwd( N, x, 2, 1 ); +* var v = dsnanmeanwd( 4, x, 2, 1 ); * // returns 1.25 */ -function dsnanmeanwd( N, x, stride, offset ) { - var view; - if ( stride < 0 ) { - offset += (N-1) * stride; - } - view = new Float32Array( x.buffer, x.byteOffset+(x.BYTES_PER_ELEMENT*offset), x.length-offset ); // eslint-disable-line max-len - return addon( N, view, stride ); +function dsnanmeanwd( N, x, strideX, offsetX ) { + return addon.ndarray( N, x, strideX, offsetX ); } diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/manifest.json b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/manifest.json index 000fc3754f2a..7a0fdb1d890b 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/manifest.json +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/manifest.json @@ -1,5 +1,8 @@ { - "options": {}, + "options": { + "task": "build", + "wasm": false + }, "fields": [ { "field": "src", @@ -24,17 +27,73 @@ ], "confs": [ { + "task": "build", + "wasm": false, "src": [ - "./src/dsnanmeanwd.c" + "./src/main.c" ], "include": [ "./include" ], - "libraries": [ - "-lm" + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/argv-int64", + "@stdlib/napi/argv-strided-float32array", + "@stdlib/napi/create-double" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] + }, + { + "task": "", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" ], + "libraries": [], "libpath": [], - "dependencies": [] + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/strided/base/stride2offset" + ] } ] } diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/addon.c b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/addon.c new file mode 100644 index 000000000000..b498ff687389 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/addon.c @@ -0,0 +1,60 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +#include "stdlib/stats/base/dsnanmeanwd.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/argv_int64.h" +#include "stdlib/napi/argv_strided_float32array.h" +#include "stdlib/napi/create_double.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_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dsnanmean( N, X, strideX ), v ); + return v; +} + +/** +* 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_method( napi_env env, napi_callback_info info ) { + STDLIB_NAPI_ARGV( env, info, argv, argc, 4 ); + STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 ); + STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 ); + STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 ); + STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 ); + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_strided_dsnanmean_ndarray( N, X, strideX, offsetX ), v ); + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN_WITH_METHOD( addon, "ndarray", addon_method ) diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/addon.cpp b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/addon.cpp deleted file mode 100644 index 28a6d30ea4f6..000000000000 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/addon.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/** -* @license Apache-2.0 -* -* Copyright (c) 2020 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/stats/base/dsnanmeanwd.h" -#include -#include -#include -#include -#include - -/** -* Add-on namespace. -*/ -namespace stdlib_stats_base_dsnanmeanwd { - - /** - * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result. - * - * ## Notes - * - * - When called from JavaScript, the function expects three arguments: - * - * - `N`: number of indexed elements - * - `X`: input array - * - `stride`: stride length - */ - napi_value node_dsnanmeanwd( napi_env env, napi_callback_info info ) { - napi_status status; - - size_t argc = 3; - napi_value argv[ 3 ]; - status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr ); - assert( status == napi_ok ); - - if ( argc < 3 ) { - napi_throw_error( env, nullptr, "invalid invocation. Must provide 3 arguments." ); - return nullptr; - } - - napi_valuetype vtype0; - status = napi_typeof( env, argv[ 0 ], &vtype0 ); - assert( status == napi_ok ); - if ( vtype0 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. First argument must be a number." ); - return nullptr; - } - - bool res; - status = napi_is_typedarray( env, argv[ 1 ], &res ); - assert( status == napi_ok ); - if ( res == false ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - - napi_valuetype vtype2; - status = napi_typeof( env, argv[ 2 ], &vtype2 ); - assert( status == napi_ok ); - if ( vtype2 != napi_number ) { - napi_throw_type_error( env, nullptr, "invalid argument. Third argument must be a number." ); - return nullptr; - } - - int64_t N; - status = napi_get_value_int64( env, argv[ 0 ], &N ); - assert( status == napi_ok ); - - int64_t stride; - status = napi_get_value_int64( env, argv[ 2 ], &stride ); - assert( status == napi_ok ); - - napi_typedarray_type vtype1; - size_t xlen; - void *X; - status = napi_get_typedarray_info( env, argv[ 1 ], &vtype1, &xlen, &X, nullptr, nullptr ); - assert( status == napi_ok ); - if ( vtype1 != napi_float32_array ) { - napi_throw_type_error( env, nullptr, "invalid argument. Second argument must be a Float32Array." ); - return nullptr; - } - if ( (N-1)*llabs(stride) >= (int64_t)xlen ) { - napi_throw_range_error( env, nullptr, "invalid argument. Second argument has insufficient elements based on the associated stride and the number of indexed elements." ); - return nullptr; - } - - napi_value v; - status = napi_create_double( env, stdlib_strided_dsnanmeanwd( N, (float *)X, stride ), &v ); - assert( status == napi_ok ); - - return v; - } - - napi_value Init( napi_env env, napi_value exports ) { - napi_status status; - napi_value fcn; - status = napi_create_function( env, "exports", NAPI_AUTO_LENGTH, node_dsnanmeanwd, NULL, &fcn ); - assert( status == napi_ok ); - return fcn; - } - - NAPI_MODULE( NODE_GYP_MODULE_NAME, Init ) -} // end namespace stdlib_stats_base_dsnanmeanwd diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/dsnanmeanwd.c b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/main.c similarity index 62% rename from lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/dsnanmeanwd.c rename to lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/main.c index d4ce81c47fd8..770764e2a7c5 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/dsnanmeanwd.c +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/src/main.c @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 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. @@ -17,7 +17,8 @@ */ #include "stdlib/stats/base/dsnanmeanwd.h" -#include +#include "stdlib/blas/base/shared.h" +#include "stdlib/strided/base/stride2offset.h" /** * Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values, using Welford's algorithm with extended accumulation, and returning an extended precision result. @@ -40,29 +41,39 @@ * - Welford, B. P. 1962. "Note on a Method for Calculating Corrected Sums of Squares and Products." _Technometrics_ 4 (3). Taylor & Francis: 419–20. doi:[10.1080/00401706.1962.10490022](https://doi.org/10.1080/00401706.1962.10490022). * - van Reeken, A. J. 1968. "Letters to the Editor: Dealing with Neely's Algorithms." _Communications of the ACM_ 11 (3): 149–50. doi:[10.1145/362929.362961](https://doi.org/10.1145/362929.362961). * -* @param N number of indexed elements -* @param X input array -* @param stride stride length -* @return output value +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @return output value */ -double stdlib_strided_dsnanmeanwd( const int64_t N, const float *X, const int64_t stride ) { - int64_t ix; - int64_t i; - int64_t n; +double API_SUFFIX(stdlib_strided_dsnanmeanwd)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) { + const CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX ); + return API_SUFFIX(stdlib_strided_dsnanmeanwd_ndarray)( N, X, strideX, ox ); +} + +/** +* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using Welford's algorithm with extended accumulation and alternative indexing semantics. +* +* @param N number of indexed elements +* @param X input array +* @param strideX stride length +* @param offsetX starting index for X +* @return output value +*/ +double API_SUFFIX(stdlib_strided_dsnanmeanwd_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) { + CBLAS_INT ix; + CBLAS_INT i; + CBLAS_INT n; double mu; double v; if ( N <= 0 ) { return 0.0 / 0.0; // NaN } - if ( N == 1 || stride == 0 ) { - return X[ 0 ]; - } - if ( stride < 0 ) { - ix = (1-N) * stride; - } else { - ix = 0; + if ( N == 1 || strideX == 0 ) { + return X[ offsetX ]; } + ix = offsetX; mu = 0.0; n = 0; for ( i = 0; i < N; i++ ) { @@ -71,7 +82,7 @@ double stdlib_strided_dsnanmeanwd( const int64_t N, const float *X, const int64_ n += 1; mu += ( v-mu ) / (double)n; } - ix += stride; + ix += strideX; } if ( n == 0 ) { return 0.0 / 0.0; // NaN diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.js index 986c58b23b23..d2df0996040c 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var dsnanmeanwd = require( './../lib/dsnanmeanwd.js' ); @@ -90,7 +89,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -106,15 +104,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, 2 ); + v = dsnanmeanwd( 4, x, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -130,8 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) NaN // 0 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, -2 ); + v = dsnanmeanwd( 4, x, -2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -152,7 +147,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -169,9 +163,8 @@ tape( 'the function supports view offsets', function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dsnanmeanwd( N, x1, 2 ); + v = dsnanmeanwd( 5, x1, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.native.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.native.js index 031edd6f6001..6c3171e40910 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.native.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.dsnanmeanwd.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -181,7 +180,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -197,15 +195,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, 2 ); + v = dsnanmeanwd( 4, x, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -221,8 +217,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test NaN // 0 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, -2 ); + v = dsnanmeanwd( 4, x, -2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -243,7 +238,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f tape( 'the function supports view offsets', opts, function test( t ) { var x0; var x1; - var N; var v; x0 = new Float32Array([ @@ -260,9 +254,8 @@ tape( 'the function supports view offsets', opts, function test( t ) { ]); x1 = new Float32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element - N = floor(x1.length / 2); - v = dsnanmeanwd( N, x1, 2 ); + v = dsnanmeanwd( 5, x1, 2 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.js index be773e2d611b..ad352138b374 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.js @@ -21,7 +21,6 @@ // MODULES // var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var dsnanmeanwd = require( './../lib/ndarray.js' ); @@ -90,7 +89,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', function test( t ) { - var N; var x; var v; @@ -106,15 +104,13 @@ tape( 'the function supports a `stride` parameter', function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, 2, 0 ); + v = dsnanmeanwd( 4, x, 2, 0 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', function test( t ) { - var N; var x; var v; @@ -130,8 +126,7 @@ tape( 'the function supports a negative `stride` parameter', function test( t ) NaN // 0 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, -2, 6 ); + v = dsnanmeanwd( 4, x, -2, 6 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -150,7 +145,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', function test( t ) { - var N; var x; var v; @@ -166,9 +160,8 @@ tape( 'the function supports an `offset` parameter', function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, 2, 1 ); + v = dsnanmeanwd( 5, x, 2, 1 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); diff --git a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.native.js b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.native.js index 9622342c1110..61b541344781 100644 --- a/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.native.js +++ b/lib/node_modules/@stdlib/stats/base/dsnanmeanwd/test/test.ndarray.native.js @@ -22,7 +22,6 @@ var resolve = require( 'path' ).resolve; var tape = require( 'tape' ); -var floor = require( '@stdlib/math/base/special/floor' ); var isnan = require( '@stdlib/math/base/assert/is-nan' ); var Float32Array = require( '@stdlib/array/float32' ); var tryRequire = require( '@stdlib/utils/try-require' ); @@ -99,7 +98,6 @@ tape( 'if provided an `N` parameter equal to `1`, the function returns the first }); tape( 'the function supports a `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -115,15 +113,13 @@ tape( 'the function supports a `stride` parameter', opts, function test( t ) { NaN // 4 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, 2, 0 ); + v = dsnanmeanwd( 4, x, 2, 0 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); }); tape( 'the function supports a negative `stride` parameter', opts, function test( t ) { - var N; var x; var v; @@ -139,8 +135,7 @@ tape( 'the function supports a negative `stride` parameter', opts, function test NaN // 0 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, -2, 6 ); + v = dsnanmeanwd( 4, x, -2, 6 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end(); @@ -159,7 +154,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the f }); tape( 'the function supports an `offset` parameter', opts, function test( t ) { - var N; var x; var v; @@ -175,9 +169,8 @@ tape( 'the function supports an `offset` parameter', opts, function test( t ) { NaN, NaN // 4 ]); - N = floor( x.length / 2 ); - v = dsnanmeanwd( N, x, 2, 1 ); + v = dsnanmeanwd( 5, x, 2, 1 ); t.strictEqual( v, 1.25, 'returns expected value' ); t.end();