Skip to content

Commit 587770d

Browse files
committed
Auto-generated commit
1 parent 05fb4ab commit 587770d

File tree

12 files changed

+302
-78
lines changed

12 files changed

+302
-78
lines changed

CHANGELOG.md

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
<section class="release" id="unreleased">
66

7-
## Unreleased (2024-09-16)
7+
## Unreleased (2024-09-17)
88

99
<section class="packages">
1010

@@ -76,6 +76,28 @@
7676

7777
<!-- /.package -->
7878

79+
<section class="package" id="blas-base-dcopy-unreleased">
80+
81+
#### [@stdlib/blas/base/dcopy](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/dcopy)
82+
83+
<details>
84+
85+
<section class="features">
86+
87+
##### Features
88+
89+
- [`40502bb`](https://github.com/stdlib-js/stdlib/commit/40502bb62ccef0eecf1132430422a35ae9e5dd3a) - add C `ndarray` implementation for `blas/base/dcopy` [(#2906)](https://github.com/stdlib-js/stdlib/pull/2906)
90+
91+
</section>
92+
93+
<!-- /.features -->
94+
95+
</details>
96+
97+
</section>
98+
99+
<!-- /.package -->
100+
79101
<section class="package" id="blas-base-dspr-unreleased">
80102

81103
#### [@stdlib/blas/base/dspr](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/base/dspr)
@@ -382,6 +404,7 @@ A total of 6 people contributed to this release. Thank you to the following cont
382404

383405
<details>
384406

407+
- [`40502bb`](https://github.com/stdlib-js/stdlib/commit/40502bb62ccef0eecf1132430422a35ae9e5dd3a) - **feat:** add C `ndarray` implementation for `blas/base/dcopy` [(#2906)](https://github.com/stdlib-js/stdlib/pull/2906) _(by Aman Bhansali, Athan Reines)_
385408
- [`7e11338`](https://github.com/stdlib-js/stdlib/commit/7e11338ae6642c1389e51557262710bd6ebe44aa) - **feat:** add `blas/ext/base/zfill` [(#2907)](https://github.com/stdlib-js/stdlib/pull/2907) _(by Muhammad Haris, Athan Reines)_
386409
- [`edcea47`](https://github.com/stdlib-js/stdlib/commit/edcea4761bc3065f9c5218c162b38ebec4a6c423) - **feat:** add C `ndarray` implementation for `blas/base/sswap` and `blas/base/dswap` [(#2905)](https://github.com/stdlib-js/stdlib/pull/2905) _(by Aman Bhansali, Athan Reines)_
387410
- [`6c769ad`](https://github.com/stdlib-js/stdlib/commit/6c769ad65cf528389012efc400b29b6e57a4f352) - **fix:** update error message _(by Athan Reines)_

base/dcopy/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,31 @@ The function accepts the following arguments:
207207
void c_dcopy( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );
208208
```
209209

210+
#### c_dcopy_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY )
211+
212+
Copies values from `x` into `y` using alternative indexing semantics.
213+
214+
```c
215+
double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0 };
216+
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0 };
217+
218+
c_dcopy_ndarray( 3, x, 1, 2, y, 1, 2 );
219+
```
220+
221+
The function accepts the following arguments:
222+
223+
- **N**: `[in] CBLAS_INT` number of indexed elements.
224+
- **X**: `[in] double*` input array.
225+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
226+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
227+
- **Y**: `[out] double*` output array.
228+
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
229+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
230+
231+
```c
232+
void c_dcopy_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
233+
```
234+
210235
</section>
211236

212237
<!-- /.usage -->
@@ -248,6 +273,14 @@ int main( void ) {
248273
for ( int i = 0; i < 8; i++ ) {
249274
printf( "y[ %i ] = %lf\n", i, y[ i ] );
250275
}
276+
277+
// Copy elements:
278+
c_dcopy_ndarray( N, x, strideX, 0, y, strideY, 6 );
279+
280+
// Print the result:
281+
for ( int i = 0; i < 8; i++ ) {
282+
printf( "y[ %i ] = %lf\n", i, y[ i ] );
283+
}
251284
}
252285
```
253286

base/dcopy/benchmark/c/benchmark.length.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static double rand_double( void ) {
9494
* @param len array length
9595
* @return elapsed time in seconds
9696
*/
97-
static double benchmark( int iterations, int len ) {
97+
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
9999
double x[ len ];
100100
double y[ len ];
@@ -120,6 +120,39 @@ static double benchmark( int iterations, int len ) {
120120
return elapsed;
121121
}
122122

123+
/**
124+
* Runs a benchmark.
125+
*
126+
* @param iterations number of iterations
127+
* @param len array length
128+
* @return elapsed time in seconds
129+
*/
130+
static double benchmark2( int iterations, int len ) {
131+
double elapsed;
132+
double x[ len ];
133+
double y[ len ];
134+
double t;
135+
int i;
136+
137+
for ( i = 0; i < len; i++ ) {
138+
x[ i ] = ( rand_double()*20000.0 ) - 10000.0;
139+
y[ i ] = 0.0;
140+
}
141+
t = tic();
142+
for ( i = 0; i < iterations; i++ ) {
143+
c_dcopy_ndarray( len, x, 1, 0, y, 1, 0 );
144+
if ( y[ 0 ] != y[ 0 ] ) {
145+
printf( "should not return NaN\n" );
146+
break;
147+
}
148+
}
149+
elapsed = tic() - t;
150+
if ( y[ 0 ] != y[ 0 ] ) {
151+
printf( "should not return NaN\n" );
152+
}
153+
return elapsed;
154+
}
155+
123156
/**
124157
* Main execution sequence.
125158
*/
@@ -142,7 +175,14 @@ int main( void ) {
142175
for ( j = 0; j < REPEATS; j++ ) {
143176
count += 1;
144177
printf( "# c::%s:len=%d\n", NAME, len );
145-
elapsed = benchmark( iter, len );
178+
elapsed = benchmark1( iter, len );
179+
print_results( iter, elapsed );
180+
printf( "ok %d benchmark finished\n", count );
181+
}
182+
for ( j = 0; j < REPEATS; j++ ) {
183+
count += 1;
184+
printf( "# c::%s:ndarray:len=%d\n", NAME, len );
185+
elapsed = benchmark2( iter, len );
146186
print_results( iter, elapsed );
147187
printf( "ok %d benchmark finished\n", count );
148188
}

base/dcopy/examples/c/example.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ int main( void ) {
3838
for ( int i = 0; i < 8; i++ ) {
3939
printf( "y[ %i ] = %lf\n", i, y[ i ] );
4040
}
41+
42+
// Copy elements:
43+
c_dcopy_ndarray( N, x, strideX, 0, y, strideY, 6 );
44+
45+
// Print the result:
46+
for ( int i = 0; i < 8; i++ ) {
47+
printf( "y[ %i ] = %lf\n", i, y[ i ] );
48+
}
4149
}

base/dcopy/include/stdlib/blas/base/dcopy.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ extern "C" {
3636
*/
3737
void API_SUFFIX(c_dcopy)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, double *Y, const CBLAS_INT strideY );
3838

39+
/**
40+
* Copies values from `X` into `Y` using alternative indexing semantics.
41+
*/
42+
void API_SUFFIX(c_dcopy_ndarray)( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
43+
3944
#ifdef __cplusplus
4045
}
4146
#endif

base/dcopy/lib/ndarray.native.js

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020

2121
// MODULES //
2222

23-
var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
24-
var offsetView = require( '@stdlib/strided/base/offset-view' );
25-
var addon = require( './dcopy.native.js' );
23+
var addon = require( './../src/addon.node' );
2624

2725

2826
// MAIN //
@@ -49,16 +47,7 @@ var addon = require( './dcopy.native.js' );
4947
* // y => <Float64Array>[ 1.0, 2.0, 3.0, 4.0, 5.0 ]
5048
*/
5149
function dcopy( N, x, strideX, offsetX, y, strideY, offsetY ) {
52-
var viewX;
53-
var viewY;
54-
55-
offsetX = minViewBufferIndex( N, strideX, offsetX );
56-
offsetY = minViewBufferIndex( N, strideY, offsetY );
57-
58-
viewX = offsetView( x, offsetX );
59-
viewY = offsetView( y, offsetY );
60-
61-
addon( N, viewX, strideX, viewY, strideY );
50+
addon.ndarray( N, x, strideX, offsetX, y, strideY, offsetY );
6251
return y;
6352
}
6453

0 commit comments

Comments
 (0)