Skip to content

Commit fcedaac

Browse files
authored
fix: update the return type and remove unnecessary branches/tests in blas/ext/base/ssumpw
PR-URL: #3321 Reviewed-by: Athan Reines <[email protected]>
1 parent 4bc5c7e commit fcedaac

File tree

11 files changed

+23
-82
lines changed

11 files changed

+23
-82
lines changed

lib/node_modules/@stdlib/blas/ext/base/ssumpw/README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ Computes the sum of single-precision floating-point strided array elements using
178178
```c
179179
const float x[] = { 1.0f, -2.0f, 2.0f };
180180

181-
double v = stdlib_strided_ssumpw( 3, x, 1 );
182-
// returns 1.0
181+
float v = stdlib_strided_ssumpw( 3, x, 1 );
182+
// returns 1.0f
183183
```
184184
185185
The function accepts the following arguments:
@@ -189,7 +189,7 @@ The function accepts the following arguments:
189189
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
190190
191191
```c
192-
double stdlib_strided_ssumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
192+
float stdlib_strided_ssumpw( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
193193
```
194194

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

202-
double v = stdlib_strided_ssumpw_ndarray( 3, x, 1, 0 );
203-
// returns 1.0
202+
float v = stdlib_strided_ssumpw_ndarray( 3, x, 1, 0 );
203+
// returns 1.0f
204204
```
205205
206206
The function accepts the following arguments:
@@ -211,7 +211,7 @@ The function accepts the following arguments:
211211
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
212212
213213
```c
214-
double stdlib_strided_ssumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
214+
float stdlib_strided_ssumpw_ndarray( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
215215
```
216216

217217
</section>

lib/node_modules/@stdlib/blas/ext/base/ssumpw/benchmark/c/benchmark.length.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ static double benchmark1( int iterations, int len ) {
131131
static double benchmark2( int iterations, int len ) {
132132
double elapsed;
133133
float x[ len ];
134-
double v;
134+
float v;
135135
double t;
136136
int i;
137137

lib/node_modules/@stdlib/blas/ext/base/ssumpw/include/stdlib/blas/ext/base/ssumpw.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ extern "C" {
3131
/**
3232
* Computes the sum of single-precision floating-point strided array elements using pairwise summation.
3333
*/
34-
double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
34+
float API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX );
3535

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

4141
#ifdef __cplusplus
4242
}

lib/node_modules/@stdlib/blas/ext/base/ssumpw/lib/ndarray.js

-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

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

2726

2827
// VARIABLES //
@@ -78,9 +77,6 @@ function ssumpw( N, x, strideX, offsetX ) {
7877
}
7978
ix = offsetX;
8079
if ( strideX === 0 ) {
81-
if ( isnan( x[ ix ] ) ) {
82-
return 0.0;
83-
}
8480
return N * x[ ix ];
8581
}
8682
if ( N < 8 ) {

lib/node_modules/@stdlib/blas/ext/base/ssumpw/manifest.json

-3
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
"@stdlib/napi/argv-int64",
4242
"@stdlib/napi/argv-strided-float32array",
4343
"@stdlib/napi/create-double",
44-
"@stdlib/math/base/assert/is-nanf",
4544
"@stdlib/blas/base/shared",
4645
"@stdlib/strided/base/stride2offset"
4746
]
@@ -57,7 +56,6 @@
5756
"libraries": [],
5857
"libpath": [],
5958
"dependencies": [
60-
"@stdlib/math/base/assert/is-nanf",
6159
"@stdlib/blas/base/shared",
6260
"@stdlib/strided/base/stride2offset"
6361
]
@@ -73,7 +71,6 @@
7371
"libraries": [],
7472
"libpath": [],
7573
"dependencies": [
76-
"@stdlib/math/base/assert/is-nanf",
7774
"@stdlib/blas/base/shared",
7875
"@stdlib/strided/base/stride2offset"
7976
]

lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/addon.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
3737
STDLIB_NAPI_ARGV_INT64( env, N, argv, 0 );
3838
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
3939
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
40-
STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_ssumpw)( N, X, strideX ), v )
40+
STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumpw)( N, X, strideX ), v )
4141
return v;
4242
}
4343

@@ -54,7 +54,7 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) {
5454
STDLIB_NAPI_ARGV_INT64( env, strideX, argv, 2 );
5555
STDLIB_NAPI_ARGV_INT64( env, offsetX, argv, 3 );
5656
STDLIB_NAPI_ARGV_STRIDED_FLOAT32ARRAY( env, X, N, strideX, argv, 1 );
57-
STDLIB_NAPI_CREATE_DOUBLE( env, API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, offsetX ), v )
57+
STDLIB_NAPI_CREATE_DOUBLE( env, (double)API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, offsetX ), v )
5858
return v;
5959
}
6060

lib/node_modules/@stdlib/blas/ext/base/ssumpw/src/main.c

+12-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
*/
1818

1919
#include "stdlib/blas/ext/base/ssumpw.h"
20-
#include "stdlib/math/base/assert/is_nanf.h"
2120
#include "stdlib/blas/base/shared.h"
2221
#include "stdlib/strided/base/stride2offset.h"
2322

@@ -37,9 +36,9 @@
3736
* @param strideX stride length
3837
* @return output value
3938
*/
40-
double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) {
39+
float API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX ) {
4140
CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
42-
API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, ox );
41+
return API_SUFFIX(stdlib_strided_ssumpw_ndarray)( N, X, strideX, ox );
4342
}
4443

4544
/**
@@ -59,29 +58,26 @@ double API_SUFFIX(stdlib_strided_ssumpw)( const CBLAS_INT N, const float *X, con
5958
* @param offsetX starting index
6059
* @return output value
6160
*/
62-
double API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
61+
float API_SUFFIX(stdlib_strided_ssumpw_ndarray)( const CBLAS_INT N, const float *X, const CBLAS_INT strideX, const CBLAS_INT offsetX ) {
6362
CBLAS_INT ix;
6463
CBLAS_INT M;
6564
CBLAS_INT n;
6665
CBLAS_INT i;
67-
double sum;
68-
double s0;
69-
double s1;
70-
double s2;
71-
double s3;
72-
double s4;
73-
double s5;
74-
double s6;
75-
double s7;
66+
float sum;
67+
float s0;
68+
float s1;
69+
float s2;
70+
float s3;
71+
float s4;
72+
float s5;
73+
float s6;
74+
float s7;
7675

7776
if ( N <= 0 ) {
7877
return 0.0f;
7978
}
8079
ix = offsetX;
8180
if ( strideX == 0 ) {
82-
if ( stdlib_base_is_nanf( X[ ix ] ) ) {
83-
return 0.0f;
84-
}
8581
return N * X[ ix ];
8682
}
8783
if ( N < 8 ) {

lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.js

-12
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
168168
t.end();
169169
});
170170

171-
tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', function test( t ) {
172-
var x;
173-
var v;
174-
175-
x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );
176-
177-
v = ssumpw( x.length, x, 0, 0 );
178-
t.strictEqual( v, 0.0, 'returns expected value' );
179-
180-
t.end();
181-
});
182-
183171
tape( 'the function supports an `offset` parameter', function test( t ) {
184172
var N;
185173
var x;

lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ndarray.native.js

-12
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
177177
t.end();
178178
});
179179

180-
tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', opts, function test( t ) {
181-
var x;
182-
var v;
183-
184-
x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );
185-
186-
v = ssumpw( x.length, x, 0, 0 );
187-
t.strictEqual( v, 0.0, 'returns expected value' );
188-
189-
t.end();
190-
});
191-
192180
tape( 'the function supports an `offset` parameter', opts, function test( t ) {
193181
var N;
194182
var x;

lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.js

-12
Original file line numberDiff line numberDiff line change
@@ -168,18 +168,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
168168
t.end();
169169
});
170170

171-
tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', function test( t ) {
172-
var x;
173-
var v;
174-
175-
x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );
176-
177-
v = ssumpw( x.length, x, 0 );
178-
t.strictEqual( v, 0.0, 'returns expected value' );
179-
180-
t.end();
181-
});
182-
183171
tape( 'the function supports view offsets', function test( t ) {
184172
var x0;
185173
var x1;

lib/node_modules/@stdlib/blas/ext/base/ssumpw/test/test.ssumpw.native.js

-12
Original file line numberDiff line numberDiff line change
@@ -259,18 +259,6 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
259259
t.end();
260260
});
261261

262-
tape( 'if provided a `stride` parameter equal to `0` and the first element is `NaN`, the function returns 0.0', opts, function test( t ) {
263-
var x;
264-
var v;
265-
266-
x = new Float32Array( [ NaN, -2.0, -4.0, 5.0, 3.0 ] );
267-
268-
v = ssumpw( x.length, x, 0 );
269-
t.strictEqual( v, 0.0, 'returns expected value' );
270-
271-
t.end();
272-
});
273-
274262
tape( 'the function supports view offsets', opts, function test( t ) {
275263
var x0;
276264
var x1;

0 commit comments

Comments
 (0)