Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/node_modules/@stdlib/stats/strided/snanmeanpn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ console.log( v );

```c
#include "stdlib/stats/strided/snanmeanpn.h"
include "stdlib/constants/float32/nan.h"
```

#### stdlib_strided_snanmeanpn( N, \*X, strideX )

Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.

```c
const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
const float x[] = { 1.0f, -2.0f, STDLIB_CONSTANT_FLOAT32_NAN, 2.0f };

float v = stdlib_strided_snanmeanpn( 4, x, 1 );
// returns ~0.33333f
Expand All @@ -224,7 +225,7 @@ float stdlib_strided_snanmeanpn( const CBLAS_INT N, const float *X, const CBLAS_
Computes the [arithmetic mean][arithmetic-mean] of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.

```c
const float x[] = { 1.0f, -2.0f, 0.0f/0.0f, 2.0f };
const float x[] = { 1.0f, -2.0f, STDLIB_CONSTANT_FLOAT32_NAN, 2.0f };

float v = stdlib_strided_snanmeanpn_ndarray( 4, x, 1, 0 );
// returns ~0.33333f
Expand Down Expand Up @@ -265,7 +266,7 @@ float stdlib_strided_snanmeanpn_ndarray( const CBLAS_INT N, const float *X, cons

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 };
const float x[] = { 1.0f, 2.0f, STDLIB_CONSTANT_FLOAT32_NAN, 3.0f, STDLIB_CONSTANT_FLOAT32_NAN, 4.0f, 5.0f, 6.0f, 0.0f/0.0f, 7.0f, 8.0f, STDLIB_CONSTANT_FLOAT32_NAN };

// Specify the number of elements:
const int N = 6;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

#include "stdlib/stats/strided/snanmeanpn.h"
#include "stdlib/constants/float32/nan.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
Expand Down Expand Up @@ -103,7 +104,7 @@ static double benchmark1( int iterations, int len ) {

for ( i = 0; i < len; i++ ) {
if ( rand_float() < 0.2f ) {
x[ i ] = 0.0f / 0.0f; // NaN
x[ i ] = STDLIB_CONSTANT_FLOAT32_NAN;
} else {
x[ i ] = ( rand_float() * 20000.0f ) - 10000.0f;
}
Expand Down Expand Up @@ -141,7 +142,7 @@ static double benchmark2( int iterations, int len ) {

for ( i = 0; i < len; i++ ) {
if ( rand_float() < 0.2 ) {
x[ i ] = 0.0 / 0.0; // NaN
x[ i ] = STDLIB_CONSTANT_FLOAT32_NAN;
} else {
x[ i ] = ( rand_float() * 20000.0 ) - 10000.0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@
*/

#include "stdlib/stats/strided/snanmeanpn.h"
#include "stdlib/constants/float32/nan.h"
#include <stdio.h>

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 };
const float x[] = { 1.0f, 2.0f, STDLIB_CONSTANT_FLOAT32_NAN, 3.0f, STDLIB_CONSTANT_FLOAT32_NAN, 4.0f, 5.0f, 6.0f, STDLIB_CONSTANT_FLOAT32_NAN, 7.0f, 8.0f, STDLIB_CONSTANT_FLOAT32_NAN };

// Specify the number of elements:
const int N = 6;
Expand Down
12 changes: 8 additions & 4 deletions lib/node_modules/@stdlib/stats/strided/snanmeanpn/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"@stdlib/napi/argv",
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double"
"@stdlib/napi/create-double",
"@stdlib/constants/float32/nan"
]
},
{
Expand All @@ -60,7 +61,8 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
"@stdlib/strided/base/stride2offset",
"@stdlib/constants/float32/nan"
]
},
{
Expand All @@ -76,7 +78,8 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
"@stdlib/strided/base/stride2offset",
"@stdlib/constants/float32/nan"
]
},
{
Expand All @@ -92,7 +95,8 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
"@stdlib/strided/base/stride2offset",
"@stdlib/constants/float32/nan"
]
}
]
Expand Down
5 changes: 3 additions & 2 deletions lib/node_modules/@stdlib/stats/strided/snanmeanpn/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "stdlib/stats/strided/snanmeanpn.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/stride2offset.h"
#include "stdlib/constants/float32/nan.h"

/**
* Computes the arithmetic mean of a single-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm.
Expand Down Expand Up @@ -62,7 +63,7 @@ float API_SUFFIX(stdlib_strided_snanmeanpn_ndarray)( const CBLAS_INT N, const fl
float v;

if ( N <= 0 ) {
return 0.0f / 0.0f; // NaN
return STDLIB_CONSTANT_FLOAT32_NAN;
}
if ( N == 1 || strideX == 0 ) {
return X[ offsetX ];
Expand All @@ -82,7 +83,7 @@ float API_SUFFIX(stdlib_strided_snanmeanpn_ndarray)( const CBLAS_INT N, const fl
ix += strideX;
}
if ( n == 0 ) {
return 0.0f / 0.0f; // NaN
return STDLIB_CONSTANT_FLOAT32_NAN;
}
dn = (double)n;
s = (double)s / dn;
Expand Down