diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmax/lib/index.js b/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmax/lib/index.js index fd8dcda353eb..b2923b366809 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmax/lib/index.js +++ b/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmax/lib/index.js @@ -37,9 +37,23 @@ // 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' ); +// MAIN // + +var snanmskmax; +var tmp = tryRequire( join( __dirname, './native.js' ) ); +if ( isError( tmp ) ) { + snanmskmax = main; +} else { + snanmskmax = tmp; +} + + // EXPORTS // -module.exports = main; +module.exports = snanmskmax; diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmin/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmin/README.md index 849c3c5adfd4..30a4b96493a0 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmin/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/snanmskmin/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2025 The Stdlib Authors. +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. @@ -103,6 +103,132 @@ console.log( v ); + + +
+ +## C APIs + +
+ +
+ + + +
+ +### Usage + +```c +#include "stdlib/stats/base/ndarray/snanmskmin.h" +``` + +#### stdlib_stats_snanmskmin( arrays ) + +Compute the minimum value of a one-dimensional single-precision floating-point ndarray according to a mask, ignoring `NaN` values. + +```c +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/index_modes.h" +#include + +// ... + +// Create ndarray and mask... +struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)data, ndims, shape, xstrides, offset, order, imode, nsubmodes, submodes ); +struct ndarray *mask = stdlib_ndarray_allocate( STDLIB_NDARRAY_UINT8, (uint8_t *)mdata, ndims, shape, mstrides, offset, order, imode, nsubmodes, submodes ); + +const struct ndarray *arrays[] = { x, mask }; + +float v = stdlib_stats_snanmskmin( arrays ); + +// ... + +// Free memory: +stdlib_ndarray_free( x ); +stdlib_ndarray_free( mask ); +``` + +The function accepts the following arguments: + +- **arrays**: `[2](const struct ndarray *)` array containing ndarrays (a one-dimensional input ndarray and a one-dimensional mask ndarray). + +```c +float stdlib_stats_snanmskmin( const struct ndarray *arrays[] ); +``` + +
+ + + +
+ +
+ + + +
+ +### Examples + +```c +#include "stdlib/stats/base/ndarray/snanmskmin.h" +#include "stdlib/ndarray/ctor.h" +#include "stdlib/ndarray/dtypes.h" +#include "stdlib/ndarray/orders.h" +#include "stdlib/ndarray/index_modes.h" +#include +#include + +int main( void ) { + float x[] = { 1.0f, -2.0f, 4.0f, 2.0f, 0.0f/0.0f }; + uint8_t mask[] = { 0, 0, 1, 0, 0 }; + + int64_t ndims = 1; + int64_t shape[] = { 5 }; + int64_t strides[] = { 4 }; + int64_t mstrides[] = { 1 }; + int64_t offset = 0; + enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR; + enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR; + int8_t submodes[] = { imode }; + int64_t nsubmodes = 1; + + struct ndarray *X = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)x, ndims, shape, strides, offset, order, imode, nsubmodes, submodes ); + if ( X == NULL ) { + printf( "Error allocating memory.\n" ); + return 1; + } + + struct ndarray *Mask = stdlib_ndarray_allocate( STDLIB_NDARRAY_UINT8, (uint8_t *)mask, ndims, shape, mstrides, offset, order, imode, nsubmodes, submodes ); + if ( Mask == NULL ) { + printf( "Error allocating memory.\n" ); + stdlib_ndarray_free( X ); + return 1; + } + + const struct ndarray *arrays[] = { X, Mask }; + + float v = stdlib_stats_snanmskmin( arrays ); + printf( "min: %f\n", v ); + + stdlib_ndarray_free( X ); + stdlib_ndarray_free( Mask ); + + return 0; +} +``` + +
+ + + +
+ + +