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
8 changes: 5 additions & 3 deletions lib/node_modules/@stdlib/stats/strided/dnanmidrange/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,15 @@ console.log( v );

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

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

Computes the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values.

```c
const double x[] = { 1.0, 0.0/0.0, 3.0, -4.0 };
const double x[] = { 1.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, -4.0 };

double v = stdlib_strided_dnanmidrange( 4, x, 1 );
// returns -0.5
Expand All @@ -206,7 +207,7 @@ double stdlib_strided_dnanmidrange( const CBLAS_INT N, const double *X, const CB
Computes the [mid-range][mid-range] of a double-precision floating-point strided array, ignoring `NaN` values and using alternative indexing semantics.

```c
const double x[] = { 1.0, 0.0/0.0, 3.0, -4.0 };
const double x[] = { 1.0, STDLIB_CONSTANT_FLOAT64_NAN, 3.0, -4.0 };

double v = stdlib_strided_dnanmidrange_ndarray( 4, x, 1, 0 );
// returns -0.5
Expand Down Expand Up @@ -243,11 +244,12 @@ double stdlib_strided_dnanmidrange_ndarray( const CBLAS_INT N, const double *X,

```c
#include "stdlib/stats/strided/dnanmidrange.h"
#include "stdlib/constants/float64/nan.h"
#include <stdio.h>

int main( void ) {
// Create a strided array:
const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0, 0.0/0.0, 0.0/0.0 };
const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN, STDLIB_CONSTANT_FLOAT64_NAN };

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

#include "stdlib/stats/strided/dnanmidrange.h"
#include "stdlib/constants/float64/nan.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
Expand Down Expand Up @@ -104,7 +105,7 @@ static double benchmark1( int iterations, int len ) {
x = (double *)malloc( len * sizeof( double ) );
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 @@ -144,7 +145,7 @@ static double benchmark2( int iterations, int len ) {
x = (double *)malloc( len * sizeof( double ) );
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 @@ -17,11 +17,12 @@
*/

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

int main( void ) {
// Create a strided array:
const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0, 0.0/0.0, 0.0/0.0 };
const double x[] = { 1.0, -2.0, -3.0, 4.0, -5.0, -6.0, 7.0, 8.0, STDLIB_CONSTANT_FLOAT64_NAN, STDLIB_CONSTANT_FLOAT64_NAN };

// Specify the number of elements:
const int N = 5;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,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 @@ -66,7 +67,8 @@
"@stdlib/strided/base/stride2offset",
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/assert/is-positive-zero",
"@stdlib/math/base/assert/is-negative-zero"
"@stdlib/math/base/assert/is-negative-zero",
"@stdlib/constants/float64/nan"
]
},
{
Expand All @@ -85,7 +87,8 @@
"@stdlib/strided/base/stride2offset",
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/assert/is-positive-zero",
"@stdlib/math/base/assert/is-negative-zero"
"@stdlib/math/base/assert/is-negative-zero",
"@stdlib/constants/float64/nan"
]
},
{
Expand All @@ -104,7 +107,8 @@
"@stdlib/strided/base/stride2offset",
"@stdlib/math/base/assert/is-nan",
"@stdlib/math/base/assert/is-positive-zero",
"@stdlib/math/base/assert/is-negative-zero"
"@stdlib/math/base/assert/is-negative-zero",
"@stdlib/constants/float64/nan"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "stdlib/math/base/assert/is_negative_zero.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/stride2offset.h"
#include "stdlib/constants/float64/nan.h"

/**
* Computes the mid-range of a double-precision floating-point strided array, ignoring `NaN` values.
Expand Down Expand Up @@ -51,9 +52,8 @@ double API_SUFFIX(stdlib_strided_dnanmidrange_ndarray)( const CBLAS_INT N, const
double max;
double min;
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 @@ -67,7 +67,7 @@ double API_SUFFIX(stdlib_strided_dnanmidrange_ndarray)( const CBLAS_INT N, const
ix += strideX;
}
if ( i == N ) {
return 0.0 / 0.0; // NaN
return STDLIB_CONSTANT_FLOAT64_NAN;
}
min = v;
max = min;
Expand Down
Loading