Skip to content

Commit f80e82f

Browse files
authored
refactor: update offset handling and function parameter description for blas/ext/base/dnannsumkbn2
PR-URL: #3123 Reviewed-by: Athan Reines <[email protected]>
1 parent 19343f5 commit f80e82f

File tree

8 files changed

+16
-21
lines changed

8 files changed

+16
-21
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ The function accepts the following arguments:
207207
- **N**: `[in] CBLAS_INT` number of indexed elements.
208208
- **X**: `[in] double*` input array.
209209
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
210-
- **n**: `[out] CBLAS_INT*` number of non-NaN elements.
210+
- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
211211
212212
```c
213213
double stdlib_strided_dnannsumkbn2( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n );
@@ -231,7 +231,7 @@ The function accepts the following arguments:
231231
- **X**: `[in] double*` input array.
232232
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
233233
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
234-
- **n**: `[out] CBLAS_INT*` number of non-NaN elements.
234+
- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
235235
236236
```c
237237
double stdlib_strided_dnannsumkbn2_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );

lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/lib/dnannsumkbn2.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,7 @@ function dnannsumkbn2( N, x, strideX, out, strideOut ) {
5858
var io;
5959

6060
ix = stride2offset( N, strideX );
61-
if ( strideOut < 0 ) {
62-
io = -strideOut;
63-
} else {
64-
io = 0;
65-
}
61+
io = stride2offset( 2, strideOut );
6662
return ndarray( N, x, strideX, ix, out, strideOut, io );
6763
}
6864

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "stdlib/napi/argv.h"
2323
#include "stdlib/napi/argv_int64.h"
2424
#include "stdlib/napi/argv_strided_float64array.h"
25+
#include "stdlib/strided/base/stride2offset.h"
26+
#include <stdint.h>
2527
#include <node_api.h>
2628

2729
/**
@@ -39,13 +41,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
3941
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
4042
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 3 );
4143

42-
int io;
43-
if ( strideOut < 0 ) {
44-
io = -strideOut;
45-
} else {
46-
io = 0;
47-
}
48-
44+
int64_t io = stdlib_strided_stride2offset( 2, strideOut );
4945
double *out = Out;
5046
CBLAS_INT n;
5147
out[ io ] = API_SUFFIX(stdlib_strided_dnannsumkbn2)( N, X, strideX, &n );
@@ -71,11 +67,10 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) {
7167
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
7268
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 );
7369

74-
int io = offsetOut;
7570
double *out = Out;
7671
CBLAS_INT n;
77-
out[ io ] = API_SUFFIX(stdlib_strided_dnannsumkbn2_ndarray)( N, X, strideX, offsetX, &n );
78-
out[ io+strideOut ] = (double)n;
72+
out[ offsetOut ] = API_SUFFIX(stdlib_strided_dnannsumkbn2_ndarray)( N, X, strideX, offsetX, &n );
73+
out[ offsetOut+strideOut ] = (double)n;
7974

8075
return NULL;
8176
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @param N number of indexed elements
3737
* @param X input array
3838
* @param strideX stride length
39-
* @param n number of non-NaN elements
39+
* @param n pointer for storing the number of non-NaN elements
4040
* @return output value
4141
*/
4242
double API_SUFFIX(stdlib_strided_dnannsumkbn2)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n ) {
@@ -59,16 +59,16 @@ double API_SUFFIX(stdlib_strided_dnannsumkbn2)( const CBLAS_INT N, const double
5959
* @param X input array
6060
* @param strideX stride length
6161
* @param offsetX starting index
62-
* @param n number of non-NaN elements
62+
* @param n pointer for storing the number of non-NaN elements
6363
* @return output value
6464
*/
6565
double API_SUFFIX(stdlib_strided_dnannsumkbn2_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n ) {
66+
CBLAS_INT ix;
67+
CBLAS_INT i;
6668
double sum;
6769
double ccs;
6870
double cs;
6971
double cc;
70-
CBLAS_INT ix;
71-
CBLAS_INT i;
7272
double v;
7373
double t;
7474
double c;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
220220
var out;
221221
var x;
222222
var v;
223+
223224
x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
224225
out = new Float64Array( 2 );
225226
v = dnannsumkbn2( x.length, x, 0, out, 1 );

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
229229
var out;
230230
var x;
231231
var v;
232+
232233
x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
233234
out = new Float64Array( 2 );
234235
v = dnannsumkbn2( x.length, x, 0, out, 1 );

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
220220
var out;
221221
var x;
222222
var v;
223+
223224
x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
224225
out = new Float64Array( 2 );
225226
v = dnannsumkbn2( x.length, x, 0, 0, out, 1, 0 );

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ tape( 'if provided a `stride` parameter equal to `0`, the function returns the s
229229
var out;
230230
var x;
231231
var v;
232+
232233
x = new Float64Array( [ 1.0, -2.0, -4.0, 5.0, 3.0 ] );
233234
out = new Float64Array( 2 );
234235
v = dnannsumkbn2( x.length, x, 0, 0, out, 1, 0 );

0 commit comments

Comments
 (0)