Skip to content

Commit e8fd916

Browse files
committed
refactor: use utility to resolve the first indexed element
1 parent 18deecf commit e8fd916

File tree

3 files changed

+31
-50
lines changed

3 files changed

+31
-50
lines changed

lib/node_modules/@stdlib/blas/base/daxpy/manifest.json

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"libpath": [],
4545
"dependencies": [
4646
"@stdlib/blas/base/shared",
47+
"@stdlib/strided/base/min-view-buffer-index",
4748
"@stdlib/napi/export",
4849
"@stdlib/napi/argv",
4950
"@stdlib/napi/argv-double",
@@ -106,6 +107,7 @@
106107
"libpath": [],
107108
"dependencies": [
108109
"@stdlib/blas/base/shared",
110+
"@stdlib/strided/base/min-view-buffer-index",
109111
"@stdlib/napi/export",
110112
"@stdlib/napi/argv",
111113
"@stdlib/napi/argv-double",
@@ -129,7 +131,9 @@
129131
"-lpthread"
130132
],
131133
"libpath": [],
132-
"dependencies": []
134+
"dependencies": [
135+
"@stdlib/strided/base/min-view-buffer-index"
136+
]
133137
},
134138
{
135139
"task": "examples",
@@ -147,7 +151,9 @@
147151
"-lpthread"
148152
],
149153
"libpath": [],
150-
"dependencies": []
154+
"dependencies": [
155+
"@stdlib/strided/base/min-view-buffer-index"
156+
]
151157
},
152158

153159
{
@@ -166,6 +172,7 @@
166172
"libpath": [],
167173
"dependencies": [
168174
"@stdlib/blas/base/shared",
175+
"@stdlib/strided/base/min-view-buffer-index",
169176
"@stdlib/napi/export",
170177
"@stdlib/napi/argv",
171178
"@stdlib/napi/argv-double",
@@ -227,6 +234,7 @@
227234
"libpath": [],
228235
"dependencies": [
229236
"@stdlib/blas/base/shared",
237+
"@stdlib/strided/base/min-view-buffer-index",
230238
"@stdlib/napi/export",
231239
"@stdlib/napi/argv",
232240
"@stdlib/napi/argv-double",
@@ -249,7 +257,9 @@
249257
"-lblas"
250258
],
251259
"libpath": [],
252-
"dependencies": []
260+
"dependencies": [
261+
"@stdlib/strided/base/min-view-buffer-index"
262+
]
253263
},
254264
{
255265
"task": "examples",
@@ -266,7 +276,9 @@
266276
"-lblas"
267277
],
268278
"libpath": [],
269-
"dependencies": []
279+
"dependencies": [
280+
"@stdlib/strided/base/min-view-buffer-index"
281+
]
270282
},
271283

272284
{
@@ -287,6 +299,7 @@
287299
"libpath": [],
288300
"dependencies": [
289301
"@stdlib/blas/base/shared",
302+
"@stdlib/strided/base/min-view-buffer-index",
290303
"@stdlib/napi/export",
291304
"@stdlib/napi/argv",
292305
"@stdlib/napi/argv-double",
@@ -310,7 +323,9 @@
310323
"-lpthread"
311324
],
312325
"libpath": [],
313-
"dependencies": []
326+
"dependencies": [
327+
"@stdlib/strided/base/min-view-buffer-index"
328+
]
314329
},
315330
{
316331
"task": "examples",
@@ -328,7 +343,9 @@
328343
"-lpthread"
329344
],
330345
"libpath": [],
331-
"dependencies": []
346+
"dependencies": [
347+
"@stdlib/strided/base/min-view-buffer-index"
348+
]
332349
},
333350

334351
{

lib/node_modules/@stdlib/blas/base/daxpy/src/daxpy_cblas.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stdlib/blas/base/daxpy.h"
2020
#include "stdlib/blas/base/daxpy_cblas.h"
2121
#include "stdlib/blas/base/shared.h"
22+
#include "stdlib/strided/base/min_view_buffer_index.h"
2223

2324
/**
2425
* Multiplies a vector `X` by a constant and adds the result to `Y`.
@@ -47,26 +48,7 @@ void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X
4748
* @param offsetY starting Y index
4849
*/
4950
void API_SUFFIX(c_daxpy_ndarray)( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
50-
CBLAS_INT ox;
51-
CBLAS_INT oy;
52-
53-
double *x = X;
54-
double *y = Y;
55-
56-
// TODO: replace with @stdlib/strided/base/min-view-buffer-index
57-
if ( N > 0 && strideX < 0 ) {
58-
ox = offsetX + ( (N-1)*strideX ); // decrements the offset
59-
} else {
60-
ox = offsetX;
61-
}
62-
if ( N > 0 && strideY < 0 ) {
63-
oy = offsetY + ( (N-1)*strideY ); // decrements the offset
64-
} else {
65-
oy = offsetY;
66-
}
67-
// Adjust the array pointers:
68-
x += ox;
69-
y += oy;
70-
71-
API_SUFFIX(cblas_daxpy)( N, alpha, x, strideX, y, strideY );
51+
X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
52+
Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
53+
API_SUFFIX(cblas_daxpy)( N, alpha, X, strideX, Y, strideY );
7254
}

lib/node_modules/@stdlib/blas/base/daxpy/src/daxpy_f.c

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stdlib/blas/base/daxpy.h"
2020
#include "stdlib/blas/base/daxpy_fortran.h"
2121
#include "stdlib/blas/base/shared.h"
22+
#include "stdlib/strided/base/min_view_buffer_index.h"
2223

2324
/**
2425
* Multiplies a vector `X` by a constant and adds the result to `Y`.
@@ -47,26 +48,7 @@ void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X
4748
* @param offsetY starting Y index
4849
*/
4950
void API_SUFFIX(c_daxpy_ndarray)( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY ) {
50-
CBLAS_INT ox;
51-
CBLAS_INT oy;
52-
53-
double *x = X;
54-
double *y = Y;
55-
56-
// TODO: replace with @stdlib/strided/base/min-view-buffer-index
57-
if ( N > 0 && strideX < 0 ) {
58-
ox = offsetX + ( (N-1)*strideX ); // decrements the offset
59-
} else {
60-
ox = offsetX;
61-
}
62-
if ( N > 0 && strideY < 0 ) {
63-
oy = offsetY + ( (N-1)*strideY ); // decrements the offset
64-
} else {
65-
oy = offsetY;
66-
}
67-
// Adjust the array pointers:
68-
x += ox;
69-
y += oy;
70-
71-
daxpy( &N, &alpha, x, &strideX, y, &strideY );
51+
X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
52+
Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
53+
daxpy( &N, &alpha, X, &strideX, Y, &strideY );
7254
}

0 commit comments

Comments
 (0)