diff --git a/lib/node_modules/@stdlib/stats/base/ndarray/snanmskrange/README.md b/lib/node_modules/@stdlib/stats/base/ndarray/snanmskrange/README.md index afd70fea93ca..3b68b33fc251 100644 --- a/lib/node_modules/@stdlib/stats/base/ndarray/snanmskrange/README.md +++ b/lib/node_modules/@stdlib/stats/base/ndarray/snanmskrange/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. @@ -20,12 +20,10 @@ limitations under the License. # snanmskrange -> Calculate the [range][range] of a one-dimensional single-precision floating-point ndarray according to a mask, ignoring `NaN` values. +> Calculate the range of a one-dimensional single-precision floating-point ndarray according to a mask, ignoring `NaN` values.
-The [**range**][range] is defined as the difference between the maximum and minimum values. -
@@ -40,7 +38,7 @@ var snanmskrange = require( '@stdlib/stats/base/ndarray/snanmskrange' ); #### snanmskrange( arrays ) -Computes the [range][range] of a one-dimensional single-precision floating-point ndarray according to a mask, ignoring `NaN` values. +Computes the range of a one-dimensional single-precision floating-point ndarray according to a mask, ignoring `NaN` values. ```javascript var Float32Vector = require( '@stdlib/ndarray/vector/float32' ); @@ -105,6 +103,132 @@ console.log( v ); + + +
+ +## C APIs + +
+ +
+ + + +
+ +### Usage + +```c +#include "stdlib/stats/base/ndarray/snanmskrange.h" +``` + +#### stdlib_stats_snanmskrange( arrays ) + +Compute the range 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_snanmskrange( 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_snanmskrange( const struct ndarray *arrays[] ); +``` + +
+ + + +
+ +
+ + + +
+ +### Examples + +```c +#include "stdlib/stats/base/ndarray/snanmskrange.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_snanmskrange( arrays ); + printf( "range: %f\n", v ); + + stdlib_ndarray_free( X ); + stdlib_ndarray_free( Mask ); + + return 0; +} +``` + +
+ + + +
+ + +