From 83d2136b0c22b09150c3fc84221bc9e711e1460f Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Mon, 10 Aug 2026 12:51:13 +0530 Subject: [PATCH 1/4] feat(stats/base/ndarray/dnanmeanpn): port to native C addon check test and benchmark only --- .../stats/base/ndarray/dnanmeanpn/README.md | 147 ++++++++++++++ .../ndarray/dnanmeanpn/benchmark/benchmark.js | 4 +- .../dnanmeanpn/benchmark/benchmark.native.js | 125 ++++++++++++ .../ndarray/dnanmeanpn/benchmark/c/Makefile | 146 ++++++++++++++ .../dnanmeanpn/benchmark/c/benchmark.length.c | 185 +++++++++++++++++ .../stats/base/ndarray/dnanmeanpn/binding.gyp | 170 ++++++++++++++++ .../ndarray/dnanmeanpn/examples/c/Makefile | 146 ++++++++++++++ .../ndarray/dnanmeanpn/examples/c/example.c | 74 +++++++ .../base/ndarray/dnanmeanpn/include.gypi | 53 +++++ .../stdlib/stats/base/ndarray/dnanmeanpn.h | 40 ++++ .../base/ndarray/dnanmeanpn/lib/index.js | 8 +- .../base/ndarray/dnanmeanpn/lib/native.js | 59 ++++++ .../base/ndarray/dnanmeanpn/manifest.json | 110 ++++++++++ .../base/ndarray/dnanmeanpn/package.json | 4 + .../base/ndarray/dnanmeanpn/src/Makefile | 70 +++++++ .../stats/base/ndarray/dnanmeanpn/src/addon.c | 62 ++++++ .../stats/base/ndarray/dnanmeanpn/src/main.c | 33 +++ .../base/ndarray/dnanmeanpn/test/test.js | 177 +++------------- .../base/ndarray/dnanmeanpn/test/test.main.js | 184 +++++++++++++++++ .../ndarray/dnanmeanpn/test/test.native.js | 190 ++++++++++++++++++ 20 files changed, 1836 insertions(+), 151 deletions(-) create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.native.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/benchmark.length.c create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/binding.gyp create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/examples/c/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/examples/c/example.c create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include.gypi create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include/stdlib/stats/base/ndarray/dnanmeanpn.h create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/lib/native.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/manifest.json create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/Makefile create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/addon.c create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.main.js create mode 100644 lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.native.js diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md index 3092d0167186..6624d4072d1d 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md @@ -119,6 +119,153 @@ console.log( v ); * * * +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/stats/base/ndarray/dnanmeanpn.h" +``` + +#### stdlib_stats_dnanmeanpn( arrays ) + +Computes the [arithmetic mean][arithmetic-mean] of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using a two-pass error correction algorithm. + +```c +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/base/bytes_per_element.h" +#include + +// Create an ndarray: +const double data[] = { 1.0, -2.0, 0.0/0.0, 2.0 }; +int64_t shape[] = { 4 }; +int64_t strides[] = { STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; +int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; + +struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, 1, shape, strides, 0, STDLIB_NDARRAY_ROW_MAJOR, STDLIB_NDARRAY_INDEX_ERROR, 1, submodes ); + +// Compute the arithmetic mean: +const struct ndarray *arrays[] = { x }; +double v = stdlib_stats_dnanmeanpn( arrays ); +// returns ~0.3333 + +// Free allocated memory: +stdlib_ndarray_free( x ); +``` + +The function accepts the following arguments: + +- **arrays**: `[in] struct ndarray**` list containing a one-dimensional input ndarray. + +```c +double stdlib_stats_dnanmeanpn( const struct ndarray *arrays[] ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/stats/base/ndarray/dnanmeanpn.h" +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/base/bytes_per_element.h" +#include +#include +#include + +int main( void ) { + // Create a data buffer: + const double data[] = { 1.0, -2.0, 0.0/0.0, 2.0, 5.0, -6.0, 7.0, -8.0 }; + + // Specify the number of array dimensions: + const int64_t ndims = 1; + + // Specify the array shape: + int64_t shape[] = { 4 }; + + // Specify the array strides: + int64_t strides[] = { 2*STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; + + // Specify the byte offset: + const int64_t offset = 0; + + // Specify the array order: + const enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + + // Specify the index mode: + const enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + + // Specify the subscript index modes: + int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; + const int64_t nsubmodes = 1; + + // Create an ndarray: + struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); + if ( x == NULL ) { + fprintf( stderr, "Error allocating memory. +" ); + exit( 1 ); + } + + // Define a list of ndarrays: + const struct ndarray *arrays[] = { x }; + + // Compute the arithmetic mean: + double v = stdlib_stats_dnanmeanpn( arrays ); + + // Print the result: + printf( "mean: %lf +", v ); + + // Free allocated memory: + stdlib_ndarray_free( x ); +} +``` + +
+ + + +
+ + + +* * * +
## References diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js index ff813734631b..1299d95e7fc8 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js @@ -29,7 +29,7 @@ var isnan = require( '@stdlib/math/base/assert/is-nan' ); var pow = require( '@stdlib/math/base/special/pow' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; -var dnanmeanpn = require( './../lib' ); +var dnanmeanpn = require( './../lib/main.js' ); // VARIABLES // @@ -112,7 +112,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( format( '%s:len=%d', pkg, len ), f ); + bench( format( '%s::main:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.native.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.native.js new file mode 100644 index 000000000000..7e1c55a05fe3 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.native.js @@ -0,0 +1,125 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pow = require( '@stdlib/math/base/special/pow' ); +var fillBy = require( '@stdlib/ndarray/fill-by' ); +var zeros = require( '@stdlib/ndarray/zeros' ); +var bernoulli = require( '@stdlib/random/base/bernoulli' ); +var uniform = require( '@stdlib/random/base/uniform' ); +var format = require( '@stdlib/string/format' ); +var tryRequire = require( '@stdlib/utils/try-require' ); +var pkg = require( './../package.json' ).name; + +var dnanmeanpn = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( dnanmeanpn instanceof Error ) +}; + + +// VARIABLES // + +var options = { + 'dtype': 'float64' +}; + + +// FUNCTIONS // + +/** +* Returns a random number. +* +* @private +* @returns {number} random number +*/ +function rand() { + if ( bernoulli( 0.8 ) < 1 ) { + return NaN; + } + return uniform( -10.0, 10.0 ); +} + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = fillBy( zeros( [ len ], options ), rand ); + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var v; + var i; + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + v = dnanmeanpn( [ x ] ); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( v ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); + } +} + + +// MAIN // + +/** +* Main execution sequence. +* +* @private +*/ +function main() { + var len; + var min; + var max; + var f; + var i; + + min = 1; // 10^min + max = 6; // 10^max + + for ( i = min; i <= max; i++ ) { + len = pow( 10, i ); + f = createBenchmark( len ); + bench( format( '%s::native:len=%d', pkg, len ), opts, f ); + } +} + +main(); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/Makefile b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/Makefile new file mode 100644 index 000000000000..0756dc7da20a --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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.length.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/stats/base/ndarray/dnanmeanpn/benchmark/c/benchmark.length.c b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/benchmark.length.c new file mode 100644 index 000000000000..5c5abaa6ed4c --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/c/benchmark.length.c @@ -0,0 +1,185 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/ndarray/dnanmeanpn.h" +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/base/bytes_per_element.h" +#include +#include +#include +#include +#include +#include + +#define NAME "dnanmeanpn" +#define ITERATIONS 1000000 +#define REPEATS 3 +#define MIN 1 +#define MAX 6 + +/** +* 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 iterations number of iterations +* @param elapsed elapsed time in seconds +*/ +static void print_results( int iterations, 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_double( void ) { + int r = rand(); + return (double)r / ( (double)RAND_MAX + 1.0 ); +} + +/** +* Runs a benchmark. +* +* @param iterations number of iterations +* @param len array length +* @return elapsed time in seconds +*/ +static double benchmark( int iterations, int len ) { + enum STDLIB_NDARRAY_INDEX_MODE imode; + const struct ndarray *arrays[ 1 ]; + enum STDLIB_NDARRAY_ORDER order; + int8_t submodes[ 1 ]; + int64_t strides[ 1 ]; + int64_t shape[ 1 ]; + int64_t nsubmodes; + struct ndarray *x; + int64_t offset; + double elapsed; + int64_t ndims; + double *data; + double v; + double t; + int i; + + ndims = 1; + shape[ 0 ] = len; + strides[ 0 ] = STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT; + offset = 0; + order = STDLIB_NDARRAY_ROW_MAJOR; + imode = STDLIB_NDARRAY_INDEX_ERROR; + submodes[ 0 ] = imode; + nsubmodes = 1; + + data = (double *) malloc( len * sizeof( double ) ); + for ( i = 0; i < len; i++ ) { + data[ i ] = ( rand_double() * 20000.0 ) - 10000.0; + } + // cppcheck-suppress invalidPointerCast + x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); + arrays[ 0 ] = x; + + v = 0.0; + t = tic(); + for ( i = 0; i < iterations; i++ ) { + v = stdlib_stats_dnanmeanpn( arrays ); + if ( v != v ) { + printf( "should not return NaN\n" ); + break; + } + } + elapsed = tic() - t; + if ( v != v ) { + printf( "should not return NaN\n" ); + } + stdlib_ndarray_free( x ); + free( data ); + arrays[ 0 ] = NULL; + + return elapsed; +} + +/** +* Main execution sequence. +*/ +int main( void ) { + double elapsed; + int count; + int iter; + int len; + int i; + int j; + + // Use the current time to seed the random number generator: + srand( time( NULL ) ); + + print_version(); + count = 0; + 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:len=%d\n", NAME, len ); + elapsed = benchmark( iter, len ); + print_results( iter, elapsed ); + printf( "ok %d benchmark finished\n", count ); + } + } + print_summary( count, count ); +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/binding.gyp b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/binding.gyp new file mode 100644 index 000000000000..0d6508a12e99 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/binding.gyp @@ -0,0 +1,170 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/stats/base/ndarray/dnanmeanpn/examples/c/Makefile b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/examples/c/Makefile new file mode 100644 index 000000000000..c8f8e9a1517b --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/examples/c/Makefile @@ -0,0 +1,146 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/stats/base/ndarray/dnanmeanpn/examples/c/example.c b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/examples/c/example.c new file mode 100644 index 000000000000..14a1d56f5264 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/examples/c/example.c @@ -0,0 +1,74 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/ndarray/dnanmeanpn.h" +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/index_modes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/base/bytes_per_element.h" +#include +#include +#include + +int main( void ) { + // Create a data buffer: + const double data[] = { 1.0, -2.0, 3.0, -4.0, 0.0/0.0, -6.0, 7.0, -8.0 }; + + // Specify the number of array dimensions: + const int64_t ndims = 1; + + // Specify the array shape: + int64_t shape[] = { 4 }; + + // Specify the array strides: + int64_t strides[] = { 2*STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; + + // Specify the byte offset: + const int64_t offset = 0; + + // Specify the array order: + const enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + + // Specify the index mode: + const enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + + // Specify the subscript index modes: + int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; + const int64_t nsubmodes = 1; + + // Create an ndarray: + // cppcheck-suppress invalidPointerCast + struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); + if ( x == NULL ) { + fprintf( stderr, "Error allocating memory.\n" ); + exit( 1 ); + } + + // Define a list of ndarrays: + const struct ndarray *arrays[] = { x }; + + // Compute the arithmetic mean: + double v = stdlib_stats_dnanmeanpn( arrays ); + + // Print the result: + printf( "mean: %lf\n", v ); + + // Free allocated memory: + stdlib_ndarray_free( x ); +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include.gypi b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include.gypi new file mode 100644 index 000000000000..bee8d41a2caf --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include.gypi @@ -0,0 +1,53 @@ +# @license Apache-2.0 +# +# Copyright (c) 2026 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': [ + '} arrays - array-like object containing ndarrays +* @returns {number} arithmetic mean +* +* @example +* var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* +* var x = new Float64Vector( [ 1.0, -2.0, NaN, 2.0 ] ); +* +* var v = dnanmeanpn( [ x ] ); +* // returns ~0.3333 +*/ +function dnanmeanpn( arrays ) { + var x = arrays[ 0 ]; + return addon( getData( x ), serialize( x ) ); +} + + +// EXPORTS // + +module.exports = dnanmeanpn; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/manifest.json b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/manifest.json new file mode 100644 index 000000000000..5164e3e758fb --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/manifest.json @@ -0,0 +1,110 @@ +{ + "options": { + "task": "build", + "wasm": false + }, + "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", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/stats/strided/dnanmeanpn", + "@stdlib/ndarray/ctor", + "@stdlib/ndarray/base/napi/addon-arguments", + "@stdlib/napi/export", + "@stdlib/napi/argv", + "@stdlib/napi/create-double" + ] + }, + { + "task": "benchmark", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/stats/strided/dnanmeanpn", + "@stdlib/ndarray/ctor", + "@stdlib/ndarray/dtypes", + "@stdlib/ndarray/index-modes", + "@stdlib/ndarray/orders", + "@stdlib/ndarray/base/bytes-per-element" + ] + }, + { + "task": "examples", + "wasm": false, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/stats/strided/dnanmeanpn", + "@stdlib/ndarray/ctor", + "@stdlib/ndarray/dtypes", + "@stdlib/ndarray/index-modes", + "@stdlib/ndarray/orders", + "@stdlib/ndarray/base/bytes-per-element" + ] + }, + { + "task": "", + "wasm": true, + "src": [ + "./src/main.c" + ], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [ + "@stdlib/blas/base/shared", + "@stdlib/stats/strided/dnanmeanpn", + "@stdlib/ndarray/ctor" + ] + } + ] +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/package.json b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/package.json index 3ac0352ec449..d9c2bbdbe9e2 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/package.json +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/package.json @@ -14,11 +14,15 @@ } ], "main": "./lib", + "browser": "./lib/main.js", + "gypfile": true, "directories": { "benchmark": "./benchmark", "doc": "./docs", "example": "./examples", + "include": "./include", "lib": "./lib", + "src": "./src", "test": "./test" }, "types": "./docs/types", diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/Makefile b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/Makefile new file mode 100644 index 000000000000..2caf905cedbe --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/Makefile @@ -0,0 +1,70 @@ +#/ +# @license Apache-2.0 +# +# Copyright (c) 2026 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/stats/base/ndarray/dnanmeanpn/src/addon.c b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/addon.c new file mode 100644 index 000000000000..9e4caf24b106 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/addon.c @@ -0,0 +1,62 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/ndarray/dnanmeanpn.h" +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/base/napi/addon_arguments.h" +#include "stdlib/napi/export.h" +#include "stdlib/napi/argv.h" +#include "stdlib/napi/create_double.h" +#include +#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, 2 ); + + // Process provided arguments: + struct ndarray *arrays[ 1 ]; + napi_value err; + napi_status status = stdlib_ndarray_napi_addon_arguments( env, argv, 2, 1, arrays, &err ); + assert( status == napi_ok ); + if ( err != NULL ) { + status = napi_throw( env, err ); + assert( status == napi_ok ); + return NULL; + } + // Create a const-qualified view of the argument pointer list: + const struct ndarray *arr[ 1 ] = { + arrays[ 0 ] + }; + // Perform computation: + STDLIB_NAPI_CREATE_DOUBLE( env, stdlib_stats_dnanmeanpn( arr ), v ); + + // Free allocated memory: + stdlib_ndarray_free( arrays[ 0 ] ); + arrays[ 0 ] = NULL; + + return v; +} + +STDLIB_NAPI_MODULE_EXPORT_FCN( addon ) diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c new file mode 100644 index 000000000000..43596dd976ff --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c @@ -0,0 +1,33 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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/ndarray/dnanmeanpn.h" +#include "stdlib/stats/strided/dnanmeanpn.h" +#include "stdlib/ndarray/ctor.h" +#include "stdlib/blas/base/shared.h" + +/** +* Computes the arithmetic mean of a one-dimensional double-precision floating-point ndarray. +* +* @param arrays list containing an input ndarray +* @return arithmetic mean +*/ +double stdlib_stats_dnanmeanpn( const struct ndarray *arrays[] ) { + const struct ndarray *x = arrays[ 0 ]; + return API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( stdlib_ndarray_dimension( x, 0 ), (const double *)stdlib_ndarray_data( x ), stdlib_ndarray_stride_elements( x, 0 ), stdlib_ndarray_offset_elements( x ) ); +} diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js index b8fbf72e3948..b7ad1cd7476b 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js @@ -21,164 +21,45 @@ // MODULES // var tape = require( 'tape' ); -var isnan = require( '@stdlib/math/base/assert/is-nan' ); -var Float64Array = require( '@stdlib/array/float64' ); -var ndarray = require( '@stdlib/ndarray/base/ctor' ); -var dnanmeanpn = require( './../lib' ); - - -// FUNCTIONS // - -/** -* Returns a one-dimensional ndarray. -* -* @private -* @param {Collection} buffer - underlying data buffer -* @param {NonNegativeInteger} length - number of indexed elements -* @param {integer} stride - stride length -* @param {NonNegativeInteger} offset - index offset -* @returns {ndarray} one-dimensional ndarray -*/ -function vector( buffer, length, stride, offset ) { - return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); -} +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var proxyquire = require( 'proxyquire' ); // TESTS // tape( 'main export is a function', function test( t ) { - t.ok( true, __filename ); - t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); - t.end(); -}); - -tape( 'the function has an arity of 1', function test( t ) { - t.strictEqual( dnanmeanpn.length, 1, 'has expected arity' ); - t.end(); -}); - -tape( 'the function computes the arithmetic mean (ignoring NaNs)', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 2.0, 1.0, NaN, 2.0, -2.0, NaN ] ); - - v = dnanmeanpn( [ vector( x, 6, 1, 0 ) ] ); - t.strictEqual( v, 0.75, 'returns expected mean' ); - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0 ] ); - v = dnanmeanpn( [ vector( x, 7, 1, 0 ) ] ); - t.strictEqual( v, 0.5, 'returns expected value' ); - - x = new Float64Array( [ -4.0, NaN ] ); - v = dnanmeanpn( [ vector( x, 2, 1, 0 ) ] ); - t.strictEqual( v, -4.0, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided an empty input ndarray, the function returns NaN', function test( t ) { - var x; - var v; - - x = new Float64Array( [] ); - v = dnanmeanpn( [ vector( x, 0, 1, 0 ) ] ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); -}); - -tape( 'when provided an input ndarray containing only NaN values, the function returns NaN', function test( t ) { - var x; - var v; + var dnanmeanpn; - x = new Float64Array( [ NaN, NaN, NaN ] ); - v = dnanmeanpn( [ vector( x, 3, 1, 0 ) ] ); - t.strictEqual( isnan( v ), true, 'returns NaN' ); - t.end(); -}); - -tape( 'when provided an input ndarray containing a single element, the function returns that element', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dnanmeanpn( [ vector( x, 1, 1, 0 ) ] ); - t.strictEqual( v, 1.0, 'returns expected value' ); - - t.end(); -}); - -tape( 'the function supports positive strides', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 0 - 2.0, - 2.0, // 1 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 3 - 2.0, - NaN // 4 - ]); - - v = dnanmeanpn( [ vector( x, 5, 2, 0 ) ] ); - t.strictEqual( v, 1.25, 'returns expected value' ); - t.end(); -}); - -tape( 'the function supports negative strides', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 1.0, // 4 - 2.0, - 2.0, // 3 - -7.0, - -2.0, // 2 - 3.0, - 4.0, // 1 - 2.0, - NaN // 0 - ]); - - v = dnanmeanpn( [ vector( x, 5, -2, 8 ) ] ); - t.strictEqual( v, 1.25, 'returns expected value' ); - t.end(); -}); - -tape( 'when provided an input ndarray having a stride equal to 0, the function returns the first indexed element', function test( t ) { - var x; - var v; - - x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); - v = dnanmeanpn( [ vector( x, 5, 0, 0 ) ] ); - t.strictEqual( v, 1.0, 'returns expected value' ); + if ( IS_BROWSER ) { + t.ok( true, __filename ); + t.end(); + return; + } + dnanmeanpn = proxyquire( './../lib', { + './native.js': new Error( 'beep' ) + }); + t.ok( true, __filename ); + t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); t.end(); }); -tape( 'the function supports view offsets', function test( t ) { - var x; - var v; - - x = new Float64Array([ - 2.0, - 1.0, // 0 - 2.0, - -2.0, // 1 - -2.0, - 2.0, // 2 - 3.0, - 4.0, // 3 - NaN, - NaN // 4 - ]); - - v = dnanmeanpn( [ vector( x, 5, 2, 1 ) ] ); - t.strictEqual( v, 1.25, 'returns expected value' ); +tape( 'main export is a function (native)', function test( t ) { + var dnanmeanpn; + + if ( IS_BROWSER ) { + t.ok( true, __filename ); + t.end(); + return; + } + dnanmeanpn = proxyquire( './../lib', { + './main.js': new Error( 'beep' ), + '@stdlib/utils/try-require': function tryRequire() { + return function dnanmeanpn() {}; + } + }); + t.ok( true, __filename ); + t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); t.end(); }); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.main.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.main.js new file mode 100644 index 000000000000..6b5d9ca0c337 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.main.js @@ -0,0 +1,184 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var Float64Array = require( '@stdlib/array/float64' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var dnanmeanpn = require( './../lib/main.js' ); + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', function test( t ) { + t.strictEqual( dnanmeanpn.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function computes the arithmetic mean (ignoring NaNs)', function test( t ) { + var x; + var v; + + x = new Float64Array( [ 2.0, 1.0, NaN, 2.0, -2.0, NaN ] ); + + v = dnanmeanpn( [ vector( x, 6, 1, 0 ) ] ); + t.strictEqual( v, 0.75, 'returns expected mean' ); + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0 ] ); + v = dnanmeanpn( [ vector( x, 7, 1, 0 ) ] ); + t.strictEqual( v, 0.5, 'returns expected value' ); + + x = new Float64Array( [ -4.0, NaN ] ); + v = dnanmeanpn( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( v, -4.0, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided an empty input ndarray, the function returns NaN', function test( t ) { + var x; + var v; + + x = new Float64Array( [] ); + v = dnanmeanpn( [ vector( x, 0, 1, 0 ) ] ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'when provided an input ndarray containing only NaN values, the function returns NaN', function test( t ) { + var x; + var v; + + x = new Float64Array( [ NaN, NaN, NaN ] ); + v = dnanmeanpn( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'when provided an input ndarray containing a single element, the function returns that element', function test( t ) { + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + v = dnanmeanpn( [ vector( x, 1, 1, 0 ) ] ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports positive strides', function test( t ) { + var x; + var v; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0, + NaN // 4 + ]); + + v = dnanmeanpn( [ vector( x, 5, 2, 0 ) ] ); + t.strictEqual( v, 1.25, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', function test( t ) { + var x; + var v; + + x = new Float64Array([ + 1.0, // 4 + 2.0, + 2.0, // 3 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 1 + 2.0, + NaN // 0 + ]); + + v = dnanmeanpn( [ vector( x, 5, -2, 8 ) ] ); + t.strictEqual( v, 1.25, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided an input ndarray having a stride equal to 0, the function returns the first indexed element', function test( t ) { + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + v = dnanmeanpn( [ vector( x, 5, 0, 0 ) ] ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', function test( t ) { + var x; + var v; + + x = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + NaN, + NaN // 4 + ]); + + v = dnanmeanpn( [ vector( x, 5, 2, 1 ) ] ); + t.strictEqual( v, 1.25, 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.native.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.native.js new file mode 100644 index 000000000000..c56c460bc634 --- /dev/null +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.native.js @@ -0,0 +1,190 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var ndarray = require( '@stdlib/ndarray/base/ctor' ); +var tryRequire = require( '@stdlib/utils/try-require' ); + +var dnanmeanpn = tryRequire( resolve( __dirname, './../lib/native.js' ) ); +var opts = { + 'skip': ( dnanmeanpn instanceof Error ) +}; + + +// FUNCTIONS // + +/** +* Returns a one-dimensional ndarray. +* +* @private +* @param {Collection} buffer - underlying data buffer +* @param {NonNegativeInteger} length - number of indexed elements +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - index offset +* @returns {ndarray} one-dimensional ndarray +*/ +function vector( buffer, length, stride, offset ) { + return new ndarray( 'float64', buffer, [ length ], [ stride ], offset, 'row-major' ); +} + + +// TESTS // + +tape( 'main export is a function', opts, function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function has an arity of 1', opts, function test( t ) { + t.strictEqual( dnanmeanpn.length, 1, 'has expected arity' ); + t.end(); +}); + +tape( 'the function computes the arithmetic mean (ignoring NaNs)', opts, function test( t ) { + var x; + var v; + + x = new Float64Array( [ 2.0, 1.0, NaN, 2.0, -2.0, NaN ] ); + + v = dnanmeanpn( [ vector( x, 6, 1, 0 ) ] ); + t.strictEqual( v, 0.75, 'returns expected mean' ); + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, NaN, 0.0, 3.0 ] ); + v = dnanmeanpn( [ vector( x, 7, 1, 0 ) ] ); + t.strictEqual( v, 0.5, 'returns expected value' ); + + x = new Float64Array( [ -4.0, NaN ] ); + v = dnanmeanpn( [ vector( x, 2, 1, 0 ) ] ); + t.strictEqual( v, -4.0, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided an empty input ndarray, the function returns NaN', opts, function test( t ) { + var x; + var v; + + x = new Float64Array( [] ); + v = dnanmeanpn( [ vector( x, 0, 1, 0 ) ] ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'when provided an input ndarray containing only NaN values, the function returns NaN', opts, function test( t ) { + var x; + var v; + + x = new Float64Array( [ NaN, NaN, NaN ] ); + v = dnanmeanpn( [ vector( x, 3, 1, 0 ) ] ); + t.strictEqual( isnan( v ), true, 'returns NaN' ); + t.end(); +}); + +tape( 'when provided an input ndarray containing a single element, the function returns that element', opts, function test( t ) { + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + v = dnanmeanpn( [ vector( x, 1, 1, 0 ) ] ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports positive strides', opts, function test( t ) { + var x; + var v; + + x = new Float64Array([ + 1.0, // 0 + 2.0, + 2.0, // 1 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 3 + 2.0, + NaN // 4 + ]); + + v = dnanmeanpn( [ vector( x, 5, 2, 0 ) ] ); + t.strictEqual( v, 1.25, 'returns expected value' ); + t.end(); +}); + +tape( 'the function supports negative strides', opts, function test( t ) { + var x; + var v; + + x = new Float64Array([ + 1.0, // 4 + 2.0, + 2.0, // 3 + -7.0, + -2.0, // 2 + 3.0, + 4.0, // 1 + 2.0, + NaN // 0 + ]); + + v = dnanmeanpn( [ vector( x, 5, -2, 8 ) ] ); + t.strictEqual( v, 1.25, 'returns expected value' ); + t.end(); +}); + +tape( 'when provided an input ndarray having a stride equal to 0, the function returns the first indexed element', opts, function test( t ) { + var x; + var v; + + x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] ); + v = dnanmeanpn( [ vector( x, 5, 0, 0 ) ] ); + t.strictEqual( v, 1.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports view offsets', opts, function test( t ) { + var x; + var v; + + x = new Float64Array([ + 2.0, + 1.0, // 0 + 2.0, + -2.0, // 1 + -2.0, + 2.0, // 2 + 3.0, + 4.0, // 3 + NaN, + NaN // 4 + ]); + + v = dnanmeanpn( [ vector( x, 5, 2, 1 ) ] ); + t.strictEqual( v, 1.25, 'returns expected value' ); + + t.end(); +}); From 074d3c1077a7896f4d1fd353d5de76632ca1eedb Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Mon, 10 Aug 2026 13:56:05 +0530 Subject: [PATCH 2/4] fix(stats/base/ndarray/dnanmeanpn): fix linting errors in index.js and README.md --- .../stats/base/ndarray/dnanmeanpn/README.md | 62 +++++++++---------- .../base/ndarray/dnanmeanpn/lib/index.js | 12 +++- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md index 6624d4072d1d..5d6a07fb6725 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md @@ -208,51 +208,51 @@ double stdlib_stats_dnanmeanpn( const struct ndarray *arrays[] ); #include int main( void ) { - // Create a data buffer: - const double data[] = { 1.0, -2.0, 0.0/0.0, 2.0, 5.0, -6.0, 7.0, -8.0 }; + // Create a data buffer: + const double data[] = { 1.0, -2.0, 0.0/0.0, 2.0, 5.0, -6.0, 7.0, -8.0 }; - // Specify the number of array dimensions: - const int64_t ndims = 1; + // Specify the number of array dimensions: + const int64_t ndims = 1; - // Specify the array shape: - int64_t shape[] = { 4 }; + // Specify the array shape: + int64_t shape[] = { 4 }; - // Specify the array strides: - int64_t strides[] = { 2*STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; + // Specify the array strides: + int64_t strides[] = { 2*STDLIB_NDARRAY_FLOAT64_BYTES_PER_ELEMENT }; - // Specify the byte offset: - const int64_t offset = 0; + // Specify the byte offset: + const int64_t offset = 0; - // Specify the array order: - const enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + // Specify the array order: + const enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; - // Specify the index mode: - const enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + // Specify the index mode: + const enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; - // Specify the subscript index modes: - int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; - const int64_t nsubmodes = 1; + // Specify the subscript index modes: + int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR }; + const int64_t nsubmodes = 1; - // Create an ndarray: - struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); - if ( x == NULL ) { - fprintf( stderr, "Error allocating memory. + // Create an ndarray: + struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); + if ( x == NULL ) { + fprintf( stderr, "Error allocating memory. " ); - exit( 1 ); - } + exit( 1 ); + } - // Define a list of ndarrays: - const struct ndarray *arrays[] = { x }; + // Define a list of ndarrays: + const struct ndarray *arrays[] = { x }; - // Compute the arithmetic mean: - double v = stdlib_stats_dnanmeanpn( arrays ); + // Compute the arithmetic mean: + double v = stdlib_stats_dnanmeanpn( arrays ); - // Print the result: - printf( "mean: %lf + // Print the result: + printf( "mean: %lf ", v ); - // Free allocated memory: - stdlib_ndarray_free( x ); + // Free allocated memory: + stdlib_ndarray_free( x ); } ``` diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/lib/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/lib/index.js index ac91681fbbfe..cdd29c1073ab 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/lib/index.js @@ -35,12 +35,20 @@ // MODULES // +var join = require( 'path' ).join; var tryRequire = require( '@stdlib/utils/try-require' ); +var isError = require( '@stdlib/assert/is-error' ); var main = require( './main.js' ); -var dnanmeanpn = tryRequire( require( 'path' ).resolve( __dirname, 'native.js' ) ); -if ( dnanmeanpn instanceof Error ) { + +// MAIN // + +var dnanmeanpn; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { dnanmeanpn = main; +} else { + dnanmeanpn = tmp; } From eb88f5a3714231880af68623c58675c62c9f2222 Mon Sep 17 00:00:00 2001 From: Ujjwal Verma Date: Mon, 10 Aug 2026 14:07:05 +0530 Subject: [PATCH 3/4] fix(stats/base/ndarray/dnanmeanpn): fix linting error in test.js --- .../base/ndarray/dnanmeanpn/test/test.js | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js index b7ad1cd7476b..e7081896c6d4 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/test/test.js @@ -21,45 +21,57 @@ // MODULES // var tape = require( 'tape' ); -var IS_BROWSER = require( '@stdlib/assert/is-browser' ); var proxyquire = require( 'proxyquire' ); +var IS_BROWSER = require( '@stdlib/assert/is-browser' ); +var dnanmeanpn = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': IS_BROWSER +}; // TESTS // tape( 'main export is a function', function test( t ) { - var dnanmeanpn; + t.ok( true, __filename ); + t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); + t.end(); +}); - if ( IS_BROWSER ) { - t.ok( true, __filename ); - t.end(); - return; - } - dnanmeanpn = proxyquire( './../lib', { - './native.js': new Error( 'beep' ) +tape( 'if a native implementation is available, the main export is the native implementation', opts, function test( t ) { + var dnanmeanpn = proxyquire( './../lib', { + '@stdlib/utils/try-require': tryRequire }); - t.ok( true, __filename ); - t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); + t.strictEqual( dnanmeanpn, mock, 'returns expected value' ); t.end(); + + function tryRequire() { + return mock; + } + + function mock() { + // Mock... + } }); -tape( 'main export is a function (native)', function test( t ) { +tape( 'if a native implementation is not available, the main export is a JavaScript implementation', opts, function test( t ) { var dnanmeanpn; + var main; + + main = require( './../lib/main.js' ); - if ( IS_BROWSER ) { - t.ok( true, __filename ); - t.end(); - return; - } dnanmeanpn = proxyquire( './../lib', { - './main.js': new Error( 'beep' ), - '@stdlib/utils/try-require': function tryRequire() { - return function dnanmeanpn() {}; - } + '@stdlib/utils/try-require': tryRequire }); - t.ok( true, __filename ); - t.strictEqual( typeof dnanmeanpn, 'function', 'main export is a function' ); + t.strictEqual( dnanmeanpn, main, 'returns expected value' ); t.end(); + + function tryRequire() { + return new Error( 'Cannot find module' ); + } }); From b442e7507e39de57a8c78feaaf31b5f7eb6b8e29 Mon Sep 17 00:00:00 2001 From: Athan Date: Mon, 10 Aug 2026 17:39:06 -0700 Subject: [PATCH 4/4] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/stats/base/ndarray/dnanmeanpn/README.md | 6 ++---- .../stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js | 2 +- .../include/stdlib/stats/base/ndarray/dnanmeanpn.h | 2 +- .../@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md index 5d6a07fb6725..0280b8419ca3 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/README.md @@ -236,8 +236,7 @@ int main( void ) { // Create an ndarray: struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT64, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); if ( x == NULL ) { - fprintf( stderr, "Error allocating memory. -" ); + fprintf( stderr, "Error allocating memory." ); exit( 1 ); } @@ -248,8 +247,7 @@ int main( void ) { double v = stdlib_stats_dnanmeanpn( arrays ); // Print the result: - printf( "mean: %lf -", v ); + printf( "mean: %lf", v ); // Free allocated memory: stdlib_ndarray_free( x ); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js index 1299d95e7fc8..63b713af9e85 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/benchmark/benchmark.js @@ -112,7 +112,7 @@ function main() { for ( i = min; i <= max; i++ ) { len = pow( 10, i ); f = createBenchmark( len ); - bench( format( '%s::main:len=%d', pkg, len ), f ); + bench( format( '%s:len=%d', pkg, len ), f ); } } diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include/stdlib/stats/base/ndarray/dnanmeanpn.h b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include/stdlib/stats/base/ndarray/dnanmeanpn.h index 29c3bde3b7ad..17d7e324ee10 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include/stdlib/stats/base/ndarray/dnanmeanpn.h +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/include/stdlib/stats/base/ndarray/dnanmeanpn.h @@ -29,7 +29,7 @@ extern "C" { #endif /** -* Computes the arithmetic mean of a one-dimensional double-precision floating-point ndarray. +* Computes the arithmetic mean of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using a two-pass error correction algorithm.. */ double stdlib_stats_dnanmeanpn( const struct ndarray *arrays[] ); diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c index 43596dd976ff..03559f8c7c6a 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c +++ b/lib/node_modules/@stdlib/stats/base/ndarray/dnanmeanpn/src/main.c @@ -22,7 +22,7 @@ #include "stdlib/blas/base/shared.h" /** -* Computes the arithmetic mean of a one-dimensional double-precision floating-point ndarray. +* Computes the arithmetic mean of a one-dimensional double-precision floating-point ndarray, ignoring `NaN` values and using a two-pass error correction algorithm. * * @param arrays list containing an input ndarray * @return arithmetic mean