Skip to content

Commit 2aae52e

Browse files
committed
refactor: move ndarray API to separate source file
1 parent 1fbd681 commit 2aae52e

File tree

3 files changed

+71
-42
lines changed

3 files changed

+71
-42
lines changed

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

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@
5858
"blas": "",
5959
"wasm": false,
6060
"src": [
61-
"./src/daxpy.c"
61+
"./src/daxpy.c",
62+
"./src/daxpy_ndarray.c"
6263
],
6364
"include": [
6465
"./include"
@@ -76,7 +77,8 @@
7677
"blas": "",
7778
"wasm": false,
7879
"src": [
79-
"./src/daxpy.c"
80+
"./src/daxpy.c",
81+
"./src/daxpy_ndarray.c"
8082
],
8183
"include": [
8284
"./include"
@@ -186,7 +188,8 @@
186188
"blas": "",
187189
"wasm": false,
188190
"src": [
189-
"./src/daxpy.c"
191+
"./src/daxpy.c",
192+
"./src/daxpy_ndarray.c"
190193
],
191194
"include": [
192195
"./include"
@@ -204,7 +207,8 @@
204207
"blas": "",
205208
"wasm": false,
206209
"src": [
207-
"./src/daxpy.c"
210+
"./src/daxpy.c",
211+
"./src/daxpy_ndarray.c"
208212
],
209213
"include": [
210214
"./include"
@@ -354,7 +358,8 @@
354358
"blas": "",
355359
"wasm": false,
356360
"src": [
357-
"./src/daxpy.c"
361+
"./src/daxpy.c",
362+
"./src/daxpy_ndarray.c"
358363
],
359364
"include": [
360365
"./include"
@@ -377,7 +382,8 @@
377382
"blas": "",
378383
"wasm": false,
379384
"src": [
380-
"./src/daxpy.c"
385+
"./src/daxpy.c",
386+
"./src/daxpy_ndarray.c"
381387
],
382388
"include": [
383389
"./include"
@@ -395,7 +401,8 @@
395401
"blas": "",
396402
"wasm": false,
397403
"src": [
398-
"./src/daxpy.c"
404+
"./src/daxpy.c",
405+
"./src/daxpy_ndarray.c"
399406
],
400407
"include": [
401408
"./include"
@@ -414,7 +421,8 @@
414421
"blas": "",
415422
"wasm": true,
416423
"src": [
417-
"./src/daxpy.c"
424+
"./src/daxpy.c",
425+
"./src/daxpy_ndarray.c"
418426
],
419427
"include": [
420428
"./include"

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

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -36,37 +36,3 @@ void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X
3636
API_SUFFIX(c_daxpy_ndarray)( N, alpha, X, strideX, ox, Y, strideY, oy );
3737
return;
3838
}
39-
40-
/**
41-
* Multiplies a vector `X` by a constant and adds the result to `Y` using alternative indexing semantics.
42-
*
43-
* @param N number of indexed elements
44-
* @param alpha scalar
45-
* @param X input array
46-
* @param strideX X stride length
47-
* @param offsetX starting X index
48-
* @param Y output array
49-
* @param strideY Y stride length
50-
* @param offsetY starting Y index
51-
*/
52-
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 ) {
53-
CBLAS_INT ix;
54-
CBLAS_INT iy;
55-
CBLAS_INT i;
56-
57-
if ( N <= 0 ) {
58-
return;
59-
}
60-
// If `alpha` is `0`, then `y` is unchanged...
61-
if ( alpha == 0.0 ) {
62-
return;
63-
}
64-
ix = offsetX;
65-
iy = offsetY;
66-
for ( i = 0; i < N; i++ ) {
67-
Y[ iy ] += alpha * X[ ix ];
68-
ix += strideX;
69-
iy += strideY;
70-
}
71-
return;
72-
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "stdlib/blas/base/daxpy.h"
20+
#include "stdlib/blas/base/shared.h"
21+
#include "stdlib/strided/base/stride2offset.h"
22+
23+
/**
24+
* Multiplies a vector `X` by a constant and adds the result to `Y` using alternative indexing semantics.
25+
*
26+
* @param N number of indexed elements
27+
* @param alpha scalar
28+
* @param X input array
29+
* @param strideX X stride length
30+
* @param offsetX starting X index
31+
* @param Y output array
32+
* @param strideY Y stride length
33+
* @param offsetY starting Y index
34+
*/
35+
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 ) {
36+
CBLAS_INT ix;
37+
CBLAS_INT iy;
38+
CBLAS_INT i;
39+
40+
if ( N <= 0 ) {
41+
return;
42+
}
43+
// If `alpha` is `0`, then `y` is unchanged...
44+
if ( alpha == 0.0 ) {
45+
return;
46+
}
47+
ix = offsetX;
48+
iy = offsetY;
49+
for ( i = 0; i < N; i++ ) {
50+
Y[ iy ] += alpha * X[ ix ];
51+
ix += strideX;
52+
iy += strideY;
53+
}
54+
return;
55+
}

0 commit comments

Comments
 (0)