Skip to content

Commit a99cc94

Browse files
committed
refactor: update offsetOut calculation
1 parent 02ffc2d commit a99cc94

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

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: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
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"
2526
#include <node_api.h>
2627

2728
/**
@@ -39,13 +40,7 @@ static napi_value addon( napi_env env, napi_callback_info info ) {
3940
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
4041
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 3 );
4142

42-
int io;
43-
if ( strideOut < 0 ) {
44-
io = -strideOut;
45-
} else {
46-
io = 0;
47-
}
48-
43+
int io = stdlib_strided_stride2offset( 2, strideOut );
4944
double *out = Out;
5045
CBLAS_INT n;
5146
out[ io ] = API_SUFFIX(stdlib_strided_dnannsumkbn2)( N, X, strideX, &n );
@@ -71,11 +66,10 @@ static napi_value addon_method( napi_env env, napi_callback_info info ) {
7166
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, X, N, strideX, argv, 1 );
7267
STDLIB_NAPI_ARGV_STRIDED_FLOAT64ARRAY( env, Out, 2, strideOut, argv, 4 );
7368

74-
int io = offsetOut;
7569
double *out = Out;
7670
CBLAS_INT n;
77-
out[ io ] = API_SUFFIX(stdlib_strided_dnannsumkbn2_ndarray)( N, X, strideX, offsetX, &n );
78-
out[ io+strideOut ] = (double)n;
71+
out[ offsetOut ] = API_SUFFIX(stdlib_strided_dnannsumkbn2_ndarray)( N, X, strideX, offsetX, &n );
72+
out[ offsetOut+strideOut ] = (double)n;
7973

8074
return NULL;
8175
}

0 commit comments

Comments
 (0)