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/dnanmeanpn/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,15 @@ console.log( v );

```c
#include "stdlib/stats/strided/dnanmeanpn.h"
#include "stdlib/constants/float64/nan.h"
```

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

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

```c
const double 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 double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN };

double v = stdlib_strided_dnanmeanpn( 6, x, 2 );
// returns ~4.6667
Expand All @@ -227,7 +228,7 @@ double stdlib_strided_dnanmeanpn( const CBLAS_INT N, const double *X, const CBLA
Computes the aithmetic mean of a double-precision floating-point strided array, ignoring `NaN` values and using a two-pass error correction algorithm and alternative indexing semantics.

```c
const double 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 double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN };

double v = stdlib_strided_dnanmeanpn( 6, x, 2, 0 );
// returns ~4.6667
Expand Down Expand Up @@ -268,7 +269,7 @@ double stdlib_strided_dnanmeanpn_ndarray( const CBLAS_INT N, const double *X, co

int main( void ) {
// Create a strided array:
const double 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 double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_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/dnanmeanpn.h"
#include "stdlib/constants/float64/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_double() < 0.2 ) {
x[ i ] = 0.0 / 0.0; // NaN
x[ i ] = STDLIB_CONSTANT_FLOAT64_NAN;
} else {
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
}
Expand Down Expand Up @@ -141,7 +142,7 @@ static double benchmark2( int iterations, int len ) {

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

#include "stdlib/stats/strided/dnanmeanpn.h"
#include <stdio.h>
#include "stdlib/constants/float64/nan.h"

int main( void ) {
// Create a strided array:
const double 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 double x[] = { 1.0, 2.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, STDLIB_CONSTANT_FLOAT64_NAN, 4.0, 5.0, 6.0, STDLIB_CONSTANT_FLOAT64_NAN, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN };

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

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

if ( N <= 0 ) {
return 0.0 / 0.0; // NaN
return STDLIB_CONSTANT_FLOAT64_NAN;
}
if ( N == 1 || strideX == 0 ) {
return X[ offsetX ];
Expand All @@ -80,7 +81,7 @@ double API_SUFFIX(stdlib_strided_dnanmeanpn_ndarray)( const CBLAS_INT N, const d
ix += strideX;
}
if ( n == 0 ) {
return 0.0 / 0.0; // NaN
return STDLIB_CONSTANT_FLOAT64_NAN;
}
dn = (double)n;
s /= dn;
Expand Down
Loading