Skip to content

Commit

Permalink
refactor: move ndarray API to separate source file
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Sep 12, 2024
1 parent 1fbd681 commit 2aae52e
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 42 deletions.
24 changes: 16 additions & 8 deletions lib/node_modules/@stdlib/blas/base/daxpy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand All @@ -76,7 +77,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand Down Expand Up @@ -186,7 +188,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand All @@ -204,7 +207,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand Down Expand Up @@ -354,7 +358,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand All @@ -377,7 +382,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand All @@ -395,7 +401,8 @@
"blas": "",
"wasm": false,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand All @@ -414,7 +421,8 @@
"blas": "",
"wasm": true,
"src": [
"./src/daxpy.c"
"./src/daxpy.c",
"./src/daxpy_ndarray.c"
],
"include": [
"./include"
Expand Down
34 changes: 0 additions & 34 deletions lib/node_modules/@stdlib/blas/base/daxpy/src/daxpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,3 @@ void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X
API_SUFFIX(c_daxpy_ndarray)( N, alpha, X, strideX, ox, Y, strideY, oy );
return;
}

/**
* Multiplies a vector `X` by a constant and adds the result to `Y` using alternative indexing semantics.
*
* @param N number of indexed elements
* @param alpha scalar
* @param X input array
* @param strideX X stride length
* @param offsetX starting X index
* @param Y output array
* @param strideY Y stride length
* @param offsetY starting Y index
*/
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 ) {
CBLAS_INT ix;
CBLAS_INT iy;
CBLAS_INT i;

if ( N <= 0 ) {
return;
}
// If `alpha` is `0`, then `y` is unchanged...
if ( alpha == 0.0 ) {
return;
}
ix = offsetX;
iy = offsetY;
for ( i = 0; i < N; i++ ) {
Y[ iy ] += alpha * X[ ix ];
ix += strideX;
iy += strideY;
}
return;
}
55 changes: 55 additions & 0 deletions lib/node_modules/@stdlib/blas/base/daxpy/src/daxpy_ndarray.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2018 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "stdlib/blas/base/daxpy.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/stride2offset.h"

/**
* Multiplies a vector `X` by a constant and adds the result to `Y` using alternative indexing semantics.
*
* @param N number of indexed elements
* @param alpha scalar
* @param X input array
* @param strideX X stride length
* @param offsetX starting X index
* @param Y output array
* @param strideY Y stride length
* @param offsetY starting Y index
*/
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 ) {
CBLAS_INT ix;
CBLAS_INT iy;
CBLAS_INT i;

if ( N <= 0 ) {
return;
}
// If `alpha` is `0`, then `y` is unchanged...
if ( alpha == 0.0 ) {
return;
}
ix = offsetX;
iy = offsetY;
for ( i = 0; i < N; i++ ) {
Y[ iy ] += alpha * X[ ix ];
ix += strideX;
iy += strideY;
}
return;
}

1 comment on commit 2aae52e

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
blas/base/daxpy $\color{green}420/420$
$\color{green}+100.00\%$
$\color{green}30/30$
$\color{green}+100.00\%$
$\color{green}4/4$
$\color{green}+100.00\%$
$\color{green}420/420$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.