Skip to content

Commit

Permalink
fix: update the return type and remove unnecessary branches/tests in …
Browse files Browse the repository at this point in the history
…`blas/ext/base/ssumpw`

PR-URL: #3321
Reviewed-by: Athan Reines <[email protected]>
  • Loading branch information
headlessNode authored Dec 4, 2024
1 parent 4bc5c7e commit fcedaac
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 82 deletions.
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
3 changes: 0 additions & 3 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-strided-float32array",
"@stdlib/napi/create-double",
"@stdlib/math/base/assert/is-nanf",
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
Expand All @@ -57,7 +56,6 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
Expand All @@ -73,7 +71,6 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/math/base/assert/is-nanf",
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
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
28 changes: 12 additions & 16 deletions lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

#include "stdlib/blas/ext/base/ssumpw.h"
#include "stdlib/math/base/assert/is_nanf.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/stride2offset.h"

Expand All @@ -37,9 +36,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 +58,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

1 comment on commit fcedaac

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
blas/ext/base/ssumpw $\color{green}435/435$
$\color{green}+100.00\%$
$\color{green}24/24$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}435/435$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.