Skip to content

Commit 020e09e

Browse files
committed
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into develop
2 parents adbee81 + 28bdda3 commit 020e09e

File tree

88 files changed

+1058
-450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+1058
-450
lines changed

.github/workflows/lint_copyright_years.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ jobs:
9696
fi
9797
9898
# Check if file contains stdlib copyright notice:
99-
year=$(grep -oP \
100-
'Copyright \(c\) \K[0-9]{4}(?= The Stdlib Authors\.)' \
101-
"$file")
99+
year=$(grep -o 'Copyright (c) [0-9]\{4\} The Stdlib Authors\.' "$file" | sed -E 's/^Copyright \(c\) ([0-9]{4}) The Stdlib Authors\./\1/' || true)
102100
103101
if [[ -n "$year" ]]; then
104102
if [[ "$year" == "$current_year" ]]; then

.github/workflows/run_tests_coverage.yml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,22 @@ jobs:
131131
if: github.event_name != 'workflow_dispatch'
132132
id: changed-directories
133133
continue-on-error: true
134+
env:
135+
STDLIB_BOT_GITHUB_TOKEN: ${{ secrets.STDLIB_BOT_GITHUB_TOKEN }}
134136
run: |
135137
if [ -n "${{ github.event.pull_request.number }}" ]; then
136138
# Get the list of changed files in pull request:
137-
ancestor_commit=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
138-
files=$(git diff --diff-filter=AM --name-only $ancestor_commit ${{ github.event.pull_request.head.sha }})
139+
page=1
140+
files=""
141+
while true; do
142+
changed_files=$(curl -s -H "Accept: application/vnd.github.v3+json" -H "Authorization: Bearer $STDLIB_BOT_GITHUB_TOKEN" "https://api.github.com/repos/stdlib-js/stdlib/pulls/${{ github.event.pull_request.number }}/files?page=$page&per_page=100" | jq -r '.[] | .filename')
143+
if [ -z "$changed_files" ]; then
144+
break
145+
fi
146+
files="$files $changed_files"
147+
page=$((page+1))
148+
done
149+
files=$(echo "$files" | tr '\n' ' ' | sed 's/ $//')
139150
else
140151
# Get changed files by comparing the current commit to the commit before the push event or with its parent:
141152
if [ "${{ github.event.before }}" == "0000000000000000000000000000000000000000" ]; then
@@ -178,7 +189,7 @@ jobs:
178189
if [ -z "$table" ]; then
179190
report="## Coverage Report\n\nNo coverage information available."
180191
else
181-
if [ "${{ github.event_name }}" == "pull_request" ]; then
192+
if [ "${{ github.event_name }}" == "pull_request_target" ]; then
182193
compare_url="https://github.com/stdlib-js/stdlib/compare/${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}"
183194
compare_txt="The above coverage report was generated for the [changes in this PR]($compare_url)."
184195
elif [ "${{ github.event_name }}" == "push" ]; then
@@ -193,18 +204,34 @@ jobs:
193204
194205
# Post report as comment to PR:
195206
- name: 'Post report as comment to PR'
196-
if: github.event_name == 'pull_request'
207+
if: github.event_name == 'pull_request_target'
197208
# Pin action to full length commit SHA
198209
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
199210
with:
200211
github-token: ${{ secrets.CHATBOT_GITHUB_TOKEN }}
201212
script: |
202-
github.rest.issues.createComment({
213+
const { data: comments } = await github.rest.issues.listComments({
203214
issue_number: context.issue.number,
204215
owner: context.repo.owner,
205216
repo: context.repo.repo,
206-
body: '${{ steps.create-report.outputs.report }}'
207-
})
217+
});
218+
219+
const botComment = comments.find( comment => comment.user.login === 'stdlib-bot' && comment.body.includes( '## Coverage Report' ) );
220+
if ( botComment ) {
221+
await github.rest.issues.updateComment({
222+
owner: context.repo.owner,
223+
repo: context.repo.repo,
224+
comment_id: botComment.id,
225+
body: `${{ steps.create-report.outputs.report }}`,
226+
});
227+
} else {
228+
await github.rest.issues.createComment({
229+
issue_number: context.issue.number,
230+
owner: context.repo.owner,
231+
repo: context.repo.repo,
232+
body: `${{ steps.create-report.outputs.report }}`,
233+
});
234+
}
208235
209236
# Post report as comment to commit:
210237
- name: 'Post report as comment to commit'
@@ -246,7 +273,7 @@ jobs:
246273
run: |
247274
cd ./www-test-code-coverage
248275
249-
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
276+
if [[ "${{ github.event_name }}" == "pull_request_target" ]]; then
250277
BRANCH_NAME="pr-${{ github.event.pull_request.number }}"
251278
git fetch origin $BRANCH_NAME || true
252279
git checkout $BRANCH_NAME || git checkout -b $BRANCH_NAME

CONTRIBUTORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Mohammad Kaif <[email protected]>
5959
Momtchil Momtchev <[email protected]>
6060
Muhammad Haris <[email protected]>
6161
Naresh Jagadeesan <[email protected]>
62+
Neeraj Pathak <[email protected]>
6263
NightKnight <[email protected]>
6364
Nithin Katta <[email protected]>
6465
Nourhan Hasan <[email protected]>

lib/node_modules/@stdlib/blas/base/zcopy/README.md

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,140 @@ console.log( y.get( y.length-1 ).toString() );
211211

212212
<!-- /.examples -->
213213

214+
<!-- C interface documentation. -->
215+
216+
* * *
217+
218+
<section class="c">
219+
220+
## C APIs
221+
222+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
223+
224+
<section class="intro">
225+
226+
</section>
227+
228+
<!-- /.intro -->
229+
230+
<!-- C usage documentation. -->
231+
232+
<section class="usage">
233+
234+
### Usage
235+
236+
```c
237+
#include "stdlib/blas/base/zcopy.h"
238+
```
239+
240+
#### c_zcopy( N, \*X, strideX, \*Y, strideY )
241+
242+
Copies values from `X` into `Y`.
243+
244+
```c
245+
const double x[] = { 1.0, 2.0, 3.0, 4.0 }; // interleaved real and imaginary components
246+
double y[] = { 0.0, 0.0, 0.0, 0.0 };
247+
248+
c_zcopy( 2, (void *)x, 1, (void *)y, 1 );
249+
```
250+
251+
The function accepts the following arguments:
252+
253+
- **N**: `[in] CBLAS_INT` number of indexed elements.
254+
- **X**: `[in] void*` input array.
255+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
256+
- **Y**: `[out] void*` output array.
257+
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
258+
259+
```c
260+
void c_zcopy( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY );
261+
```
262+
263+
#### c_zcopy_ndarray( N, \*X, strideX, offsetX, \*Y, strideY, offsetY )
264+
265+
Copies values from `X` into `Y` using alternative indexing semantics.
266+
267+
```c
268+
const double x[] = { 1.0, 2.0, 3.0, 4.0 }; // interleaved real and imaginary components
269+
double y[] = { 0.0, 0.0, 0.0, 0.0 };
270+
271+
c_zcopy_ndarray( 2, (void *)x, 1, 0, (void *)y, 1, 0 );
272+
```
273+
274+
The function accepts the following arguments:
275+
276+
- **N**: `[in] CBLAS_INT` number of indexed elements.
277+
- **X**: `[in] void*` input array.
278+
- **strideX**: `[in] CBLAS_INT` index increment for `X`.
279+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
280+
- **Y**: `[out] void*` output array.
281+
- **strideY**: `[in] CBLAS_INT` index increment for `Y`.
282+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
283+
284+
```c
285+
void c_zcopy_ndarray( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
286+
```
287+
288+
</section>
289+
290+
<!-- /.usage -->
291+
292+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
293+
294+
<section class="notes">
295+
296+
</section>
297+
298+
<!-- /.notes -->
299+
300+
<!-- C API usage examples. -->
301+
302+
<section class="examples">
303+
304+
### Examples
305+
306+
```c
307+
#include "stdlib/blas/base/zcopy.h"
308+
#include <stdio.h>
309+
310+
int main( void ) {
311+
// Create strided arrays:
312+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0 };
313+
double y[] = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
314+
315+
// Specify the number of elements:
316+
const int N = 4;
317+
318+
// Specify stride lengths:
319+
const int strideX = 1;
320+
const int strideY = -1;
321+
322+
// Copy elements:
323+
c_zcopy( N, (void *)x, strideX, (void *)y, strideY );
324+
325+
// Print the result:
326+
for ( int i = 0; i < N; i++ ) {
327+
printf( "y[ %i ] = %lf + %lfj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
328+
}
329+
330+
// Copy elements using alternative indexing semantics:
331+
c_zcopy_ndarray( N, (void *)x, -strideX, N-1, (void *)y, strideY, N-1 );
332+
333+
// Print the result:
334+
for ( int i = 0; i < N; i++ ) {
335+
printf( "y[ %i ] = %lf + %lfj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
336+
}
337+
}
338+
```
339+
340+
</section>
341+
342+
<!-- /.examples -->
343+
344+
</section>
345+
346+
<!-- /.c -->
347+
214348
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
215349
216350
<section class="links">

lib/node_modules/@stdlib/blas/base/zcopy/benchmark/c/benchmark.length.c

Lines changed: 49 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;
100100
double *y;
@@ -127,6 +127,46 @@ static double benchmark( int iterations, int len ) {
127127
return elapsed;
128128
}
129129

130+
/**
131+
* Runs a benchmark.
132+
*
133+
* @param iterations number of iterations
134+
* @param len array length
135+
* @return elapsed time in seconds
136+
*/
137+
static double benchmark2( int iterations, int len ) {
138+
double elapsed;
139+
double *x;
140+
double *y;
141+
double t;
142+
int i;
143+
144+
x = (double *) malloc( len*2 * sizeof( double ) );
145+
y = (double *) malloc( len*2 * sizeof( double ) );
146+
for ( i = 0; i < len; i++ ) {
147+
x[ i ] = ( rand_double()*10000.0 ) - 5000.0;
148+
x[ i+1 ] = ( rand_double()*10000.0 ) - 5000.0;
149+
y[ i ] = 0.0;
150+
y[ i+1 ] = 0.0;
151+
}
152+
t = tic();
153+
for ( i = 0; i < iterations; i++ ) {
154+
c_zcopy_ndarray( len, (void *)x, 1, 0, (void *)y, 1, 0 );
155+
if ( y[ 0 ] != y[ 0 ] ) {
156+
printf( "should not return NaN\n" );
157+
break;
158+
}
159+
}
160+
elapsed = tic() - t;
161+
if ( y[ 0 ] != y[ 0 ] ) {
162+
printf( "should not return NaN\n" );
163+
}
164+
free( x );
165+
free( y );
166+
167+
return elapsed;
168+
}
169+
130170
/**
131171
* Main execution sequence.
132172
*/
@@ -149,7 +189,14 @@ int main( void ) {
149189
for ( j = 0; j < REPEATS; j++ ) {
150190
count += 1;
151191
printf( "# c::%s:len=%d\n", NAME, len );
152-
elapsed = benchmark( iter, len );
192+
elapsed = benchmark1( iter, len );
193+
print_results( iter, elapsed );
194+
printf( "ok %d benchmark finished\n", count );
195+
}
196+
for ( j = 0; j < REPEATS; j++ ) {
197+
count += 1;
198+
printf( "# c::%s:ndarray:len=%d\n", NAME, len );
199+
elapsed = benchmark2( iter, len );
153200
print_results( iter, elapsed );
154201
printf( "ok %d benchmark finished\n", count );
155202
}

lib/node_modules/@stdlib/blas/base/zcopy/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 < N; i++ ) {
3939
printf( "y[ %i ] = %lf + %lfj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
4040
}
41+
42+
// Copy elements using alternative indexing semantics:
43+
c_zcopy_ndarray( N, (void *)x, -strideX, N-1, (void *)y, strideY, N-1 );
44+
45+
// Print the result:
46+
for ( int i = 0; i < N; i++ ) {
47+
printf( "y[ %i ] = %lf + %lfj\n", i, y[ i*2 ], y[ (i*2)+1 ] );
48+
}
4149
}

lib/node_modules/@stdlib/blas/base/zcopy/include/stdlib/blas/base/zcopy.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef ZCOPY_H
2323
#define ZCOPY_H
2424

25+
#include "stdlib/blas/base/shared.h"
26+
2527
/*
2628
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2729
*/
@@ -32,7 +34,12 @@ extern "C" {
3234
/**
3335
* Copies values from one complex double-precision floating-point vector to another complex double-precision floating-point vector.
3436
*/
35-
void c_zcopy( const int N, const void *X, const int strideX, void *Y, const int strideY );
37+
void API_SUFFIX(c_zcopy)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY );
38+
39+
/**
40+
* Copies values from one complex double-precision floating-point vector to another complex double-precision floating-point vector using alternative indexing semantics.
41+
*/
42+
void API_SUFFIX(c_zcopy_ndarray)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, void *Y, const CBLAS_INT strideY, const CBLAS_INT offsetY );
3643

3744
#ifdef __cplusplus
3845
}

lib/node_modules/@stdlib/blas/base/zcopy/include/stdlib/blas/base/zcopy_cblas.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#ifndef ZCOPY_CBLAS_H
2323
#define ZCOPY_CBLAS_H
2424

25+
#include "stdlib/blas/base/shared.h"
26+
2527
/*
2628
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2729
*/
@@ -32,7 +34,7 @@ extern "C" {
3234
/**
3335
* Copies values from one complex double-precision floating-point vector to another complex double-precision floating-point vector.
3436
*/
35-
void cblas_zcopy( const int N, const void *X, const int strideX, void *Y, const int strideY );
37+
void API_SUFFIX(cblas_zcopy)( const CBLAS_INT N, const void *X, const CBLAS_INT strideX, void *Y, const CBLAS_INT strideY );
3638

3739
#ifdef __cplusplus
3840
}

lib/node_modules/@stdlib/blas/base/zcopy/lib/ndarray.native.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// MODULES //
2222

2323
var reinterpret = require( '@stdlib/strided/base/reinterpret-complex128' );
24-
var minViewBufferIndex = require( '@stdlib/strided/base/min-view-buffer-index' );
2524
var addon = require( './../src/addon.node' );
2625

2726

@@ -59,16 +58,9 @@ var addon = require( './../src/addon.node' );
5958
* // returns 2.0
6059
*/
6160
function zcopy( N, x, strideX, offsetX, y, strideY, offsetY ) {
62-
var viewX;
63-
var viewY;
64-
65-
offsetX = minViewBufferIndex( N, strideX, offsetX );
66-
offsetY = minViewBufferIndex( N, strideY, offsetY );
67-
68-
viewX = reinterpret( x, offsetX );
69-
viewY = reinterpret( y, offsetY );
70-
71-
addon( N, viewX, strideX, viewY, strideY );
61+
var viewX = reinterpret( x, 0 );
62+
var viewY = reinterpret( y, 0 );
63+
addon.ndarray( N, viewX, strideX, offsetX, viewY, strideY, offsetY );
7264
return y;
7365
}
7466

0 commit comments

Comments
 (0)