Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update the return type and remove unnecessary branches/tests in blas/ext/base/ssumpw #3321

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 6 additions & 6 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ Computes the sum of single-precision floating-point strided array elements using
```c
const float x[] = { 1.0f, -2.0f, 2.0f };

double v = stdlib_strided_ssumpw( 3, x, 1 );
// returns 1.0
float v = stdlib_strided_ssumpw( 3, x, 1 );
// returns 1.0f
```

The function accepts the following arguments:
Expand All @@ -189,7 +189,7 @@ The function accepts the following arguments:
- **strideX**: `[in] CBLAS_INT` stride length for `X`.

```c
double stdlib_strided_ssumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
float stdlib_strided_ssumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
```

#### stdlib_strided_ssumpw_ndarray( N, \*X, strideX, offsetX )
Expand All @@ -199,8 +199,8 @@ Computes the sum of single-precision floating-point strided array elements using
```c
const float x[] = { 1.0f, -2.0f, 2.0f };

double v = stdlib_strided_ssumpw_ndarray( 3, x, 1, 0 );
// returns 1.0
float v = stdlib_strided_ssumpw_ndarray( 3, x, 1, 0 );
// returns 1.0f
```

The function accepts the following arguments:
Expand All @@ -211,7 +211,7 @@ The function accepts the following arguments:
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.

```c
double stdlib_strided_ssumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
float stdlib_strided_ssumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ static double benchmark1( int iterations, int len ) {
static double benchmark2( int iterations, int len ) {
double elapsed;
float x[ len ];
double v;
float v;
double t;
int i;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ extern "C" {
/**
* Computes the sum of single-precision floating-point strided array elements using pairwise summation.
*/
double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
float API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );

/**
* Computes the sum of single-precision floating-point strided array elements using pairwise summation and alternative indexing semantics.
*/
double API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
float API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );

#ifdef __cplusplus
}
Expand Down
4 changes: 0 additions & 4 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/lib/ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

var float64ToFloat32 = require( '@stdlib/number/float64/base/to-float32' );
var floor = require( '@stdlib/math/base/special/floor' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );


// VARIABLES //
Expand Down Expand Up @@ -78,9 +77,6 @@ function ssumpw( N, x, strideX, offsetX ) {
}
ix = offsetX;
if ( strideX === 0 ) {
if ( isnan( x[ ix ] ) ) {
return 0.0;
}
return N * x[ ix ];
}
if ( N < 8 ) {
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_ssumpw)( N, X, strideX ), v )
STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumpw)( N, X, strideX ), v )
return v;
}

Expand All @@ -54,7 +54,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) {
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, offsetX ), v )
STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, offsetX ), v )
return v;
}

Expand Down
27 changes: 12 additions & 15 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
* @param strideX stride length
* @return output value
*/
double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) {
float API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) {
CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, ox );
return API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, ox );
}

/**
Expand All @@ -59,29 +59,26 @@ double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, con
* @param offsetX starting index
* @return output value
*/
double API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
float API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
CBLAS_INT ix;
CBLAS_INT M;
CBLAS_INT n;
CBLAS_INT i;
double sum;
double s0;
double s1;
double s2;
double s3;
double s4;
double s5;
double s6;
double s7;
float sum;
float s0;
float s1;
float s2;
float s3;
float s4;
float s5;
float s6;
float s7;

if ( N <= 0 ) {
return 0.0f;
}
ix = offsetX;
if ( strideX == 0 ) {
if ( stdlib_base_is_nanf( X[ ix ] ) ) {
return 0.0f;
}
return N * X[ ix ];
}
if ( N < 8 ) {
Expand Down
12 changes: 0 additions & 12 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
t.end();
});

tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', function test( t ) {
var x;
var v;

x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );

v = ssumpw( x.length, x, 0, 0 );
t.strictEqual( v, 0.0, 'returns expected value' );

t.end();
});

tape( 'the function supports an `offset` parameter', function test( t ) {
var N;
var x;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
t.end();
});

tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', opts, function test( t ) {
var x;
var v;

x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );

v = ssumpw( x.length, x, 0, 0 );
t.strictEqual( v, 0.0, 'returns expected value' );

t.end();
});

tape( 'the function supports an `offset` parameter', opts, function test( t ) {
var N;
var x;
Expand Down
12 changes: 0 additions & 12 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
t.end();
});

tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', function test( t ) {
var x;
var v;

x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );

v = ssumpw( x.length, x, 0 );
t.strictEqual( v, 0.0, 'returns expected value' );

t.end();
});

tape( 'the function supports view offsets', function test( t ) {
var x0;
var x1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,18 +259,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
t.end();
});

tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', opts, function test( t ) {
var x;
var v;

x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );

v = ssumpw( x.length, x, 0 );
t.strictEqual( v, 0.0, 'returns expected value' );

t.end();
});

tape( 'the function supports view offsets', opts, function test( t ) {
var x0;
var x1;
Expand Down
Loading