Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 11, 2024
1 parent 487bb94 commit dc9082f
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 106 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<section class="release" id="unreleased">

## Unreleased (2024-09-10)
## Unreleased (2024-09-11)

<section class="packages">

Expand Down Expand Up @@ -134,6 +134,8 @@ A total of 5 people contributed to this release. Thank you to the following cont

<details>

- [`e8fd916`](https://github.com/stdlib-js/stdlib/commit/e8fd916df0a473709b2ef1caec858f4ca8187720) - **refactor:** use utility to resolve the first indexed element _(by Athan Reines)_
- [`18deecf`](https://github.com/stdlib-js/stdlib/commit/18deecf00e8d7a8069c0ebfe69a4479c249c98d4) - **refactor:** reduce code duplication by calling \"ndarray\" API _(by Athan Reines)_
- [`44ebe3c`](https://github.com/stdlib-js/stdlib/commit/44ebe3cfc43a0518991823f98e2e6d96632a0d26) - **docs:** document C API _(by Athan Reines)_
- [`ae54d13`](https://github.com/stdlib-js/stdlib/commit/ae54d13ecd92912dea70b2d31525d7f54c3a26f1) - **feat:** add C \"ndarray\" API _(by Athan Reines)_
- [`65b685c`](https://github.com/stdlib-js/stdlib/commit/65b685c163ae4f701766bce6db1a7dfca35d780f) - **docs:** update description _(by Athan Reines)_
Expand Down
51 changes: 38 additions & 13 deletions base/daxpy/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
Expand All @@ -65,7 +66,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
},
{
Expand All @@ -82,7 +84,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
},

Expand All @@ -104,6 +107,7 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
Expand All @@ -127,7 +131,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/strided/base/min-view-buffer-index"
]
},
{
"task": "examples",
Expand All @@ -145,7 +151,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/strided/base/min-view-buffer-index"
]
},

{
Expand All @@ -164,6 +172,7 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
Expand All @@ -185,7 +194,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
},
{
Expand All @@ -202,7 +212,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
},

Expand All @@ -223,6 +234,7 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
Expand All @@ -245,7 +257,9 @@
"-lblas"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/strided/base/min-view-buffer-index"
]
},
{
"task": "examples",
Expand All @@ -262,7 +276,9 @@
"-lblas"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/strided/base/min-view-buffer-index"
]
},

{
Expand All @@ -283,6 +299,7 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/min-view-buffer-index",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
Expand All @@ -306,7 +323,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/strided/base/min-view-buffer-index"
]
},
{
"task": "examples",
Expand All @@ -324,7 +343,9 @@
"-lpthread"
],
"libpath": [],
"dependencies": []
"dependencies": [
"@stdlib/strided/base/min-view-buffer-index"
]
},

{
Expand All @@ -342,6 +363,7 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset",
"@stdlib/napi/export",
"@stdlib/napi/argv",
"@stdlib/napi/argv-double",
Expand All @@ -363,7 +385,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
},
{
Expand All @@ -380,7 +403,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
},

Expand All @@ -398,7 +422,8 @@
"libraries": [],
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared"
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
]
}
]
Expand Down
52 changes: 4 additions & 48 deletions base/daxpy/src/daxpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#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`.
Expand All @@ -30,54 +31,9 @@
* @param strideY Y stride length
*/
void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY ) {
CBLAS_INT ix;
CBLAS_INT iy;
CBLAS_INT i;
CBLAS_INT m;

if ( N <= 0 ) {
return;
}
// If `alpha` is `0`, then `y` is unchanged...
if ( alpha == 0.0 ) {
return;
}
// If both strides are equal to `1`, use unrolled loops...
if ( strideX == 1 && strideY == 1 ) {
m = N % 4;

// If we have a remainder, do a clean-up loop...
if ( m > 0 ) {
for ( i = 0; i < m; i++ ) {
Y[ i ] += alpha * X[ i ];
}
if ( N < 4 ) {
return;
}
}
for ( i = m; i < N; i += 4 ) {
Y[ i ] += alpha * X[ i ];
Y[ i+1 ] += alpha * X[ i+1 ];
Y[ i+2 ] += alpha * X[ i+2 ];
Y[ i+3 ] += alpha * X[ i+3 ];
}
return;
}
if ( strideX < 0 ) {
ix = (1-N) * strideX;
} else {
ix = 0;
}
if ( strideY < 0 ) {
iy = (1-N) * strideY;
} else {
iy = 0;
}
for ( i = 0; i < N; i++ ) {
Y[ iy ] += alpha * X[ ix ];
ix += strideX;
iy += strideY;
}
CBLAS_INT ox = stdlib_strided_stride2offset( N, strideX );
CBLAS_INT oy = stdlib_strided_stride2offset( N, strideY );
API_SUFFIX(c_daxpy_ndarray)( N, alpha, X, strideX, ox, Y, strideY, oy );
return;
}

Expand Down
26 changes: 4 additions & 22 deletions base/daxpy/src/daxpy_cblas.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "stdlib/blas/base/daxpy.h"
#include "stdlib/blas/base/daxpy_cblas.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/min_view_buffer_index.h"

/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
Expand Down Expand Up @@ -47,26 +48,7 @@ void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X
* @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 ox;
CBLAS_INT oy;

double *x = X;
double *y = Y;

// TODO: replace with @stdlib/strided/base/min-view-buffer-index
if ( N > 0 && strideX < 0 ) {
ox = offsetX + ( (N-1)*strideX ); // decrements the offset
} else {
ox = offsetX;
}
if ( N > 0 && strideY < 0 ) {
oy = offsetY + ( (N-1)*strideY ); // decrements the offset
} else {
oy = offsetY;
}
// Adjust the array pointers:
x += ox;
y += oy;

API_SUFFIX(cblas_daxpy)( N, alpha, x, strideX, y, strideY );
X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
API_SUFFIX(cblas_daxpy)( N, alpha, X, strideX, Y, strideY );
}
26 changes: 4 additions & 22 deletions base/daxpy/src/daxpy_f.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "stdlib/blas/base/daxpy.h"
#include "stdlib/blas/base/daxpy_fortran.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/min_view_buffer_index.h"

/**
* Multiplies a vector `X` by a constant and adds the result to `Y`.
Expand Down Expand Up @@ -47,26 +48,7 @@ void API_SUFFIX(c_daxpy)( const CBLAS_INT N, const double alpha, const double *X
* @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 ox;
CBLAS_INT oy;

double *x = X;
double *y = Y;

// TODO: replace with @stdlib/strided/base/min-view-buffer-index
if ( N > 0 && strideX < 0 ) {
ox = offsetX + ( (N-1)*strideX ); // decrements the offset
} else {
ox = offsetX;
}
if ( N > 0 && strideY < 0 ) {
oy = offsetY + ( (N-1)*strideY ); // decrements the offset
} else {
oy = offsetY;
}
// Adjust the array pointers:
x += ox;
y += oy;

daxpy( &N, &alpha, x, &strideX, y, &strideY );
X += stdlib_strided_min_view_buffer_index( N, strideX, offsetX ); // adjust array pointer
Y += stdlib_strided_min_view_buffer_index( N, strideY, offsetY ); // adjust array pointer
daxpy( &N, &alpha, X, &strideX, Y, &strideY );
}

0 comments on commit dc9082f

Please sign in to comment.