Skip to content

Commit 032f9d4

Browse files
committed
Auto-generated commit
1 parent b88e93a commit 032f9d4

27 files changed

+546
-199
lines changed

.github/.keepalive

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
#/
2+
# @license Apache-2.0
3+
#
4+
# Copyright (c) 2024 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+
# Workflow name:
20+
name: test_published_package
21+
22+
# Workflow triggers:
23+
on:
24+
# Run workflow on a weekly schedule:
25+
schedule:
26+
# * is a special character in YAML so you have to quote this string
27+
- cron: '5 17 * * 4'
28+
29+
# Run workflow upon completion of `publish` workflow run:
30+
workflow_run:
31+
workflows: ["publish"]
32+
types: [completed]
33+
34+
# Allow workflow to be manually run:
35+
workflow_dispatch:
36+
37+
# Workflow jobs:
38+
jobs:
39+
test-published:
40+
# Define a display name:
41+
name: 'Test running examples of published package'
42+
43+
# Define the type of virtual host machine:
44+
runs-on: ubuntu-latest
45+
46+
# Define environment variables:
47+
env:
48+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
49+
50+
# Run workflow job if `publish` workflow run is successful or when the workflow is manually run:
51+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
52+
53+
# Define the job's steps:
54+
steps:
55+
# Checkout the repository:
56+
- name: 'Checkout repository'
57+
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0
58+
59+
# Install Node.js:
60+
- name: 'Install Node.js'
61+
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
62+
with:
63+
node-version: 20
64+
timeout-minutes: 5
65+
66+
# Create test directory and run examples:
67+
- name: 'Create test directory and run examples'
68+
run: |
69+
cd ..
70+
mkdir test-published
71+
cd test-published
72+
73+
# Copy example file:
74+
cp $GITHUB_WORKSPACE/examples/index.js .
75+
76+
# Create a minimal package.json
77+
echo '{
78+
"name": "test-published",
79+
"version": "1.0.0",
80+
"main": "index.js",
81+
"dependencies": {}
82+
}' > package.json
83+
84+
# Get package name and modify example file:
85+
PACKAGE_NAME=$(jq -r '.name' $GITHUB_WORKSPACE/package.json)
86+
ESCAPED_PACKAGE_NAME=$(echo "$PACKAGE_NAME" | sed 's/[\/&]/\\&/g')
87+
88+
sed -i "s/require( '.\/..\/lib' )/require( '$ESCAPED_PACKAGE_NAME' )/g" index.js
89+
90+
# Extract and install dependencies:
91+
DEPS=$(grep -oP "require\(\s*'([^']+)'\s*\)" index.js | sed "s/require(\s*'//" | sed "s/'\s*)//" | grep -v "^\.")
92+
for dep in $DEPS; do
93+
npm install $dep --save
94+
done
95+
96+
# Run the example:
97+
node index.js
98+
99+
# Send Slack notification if job fails:
100+
- name: 'Send notification to Slack in case of failure'
101+
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
102+
with:
103+
status: ${{ job.status }}
104+
channel: '#npm-ci'
105+
if: failure()

CHANGELOG.md

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

7-
## Unreleased (2024-11-01)
7+
## Unreleased (2024-11-22)
8+
9+
<section class="features">
10+
11+
### Features
12+
13+
- [`ec233ec`](https://github.com/stdlib-js/stdlib/commit/ec233ec9cadd6f17a72dafa5e79b7eeee5a821eb) - add C `ndarray` API and refactor `blas/ext/base/dnannsumpw` [(#2994)](https://github.com/stdlib-js/stdlib/pull/2994)
14+
15+
</section>
16+
17+
<!-- /.features -->
818

919
<section class="bug-fixes">
1020

@@ -22,6 +32,7 @@
2232

2333
<details>
2434

35+
- [`ec233ec`](https://github.com/stdlib-js/stdlib/commit/ec233ec9cadd6f17a72dafa5e79b7eeee5a821eb) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dnannsumpw` [(#2994)](https://github.com/stdlib-js/stdlib/pull/2994) _(by Muhammad Haris, Athan Reines, stdlib-bot)_
2536
- [`e4de24f`](https://github.com/stdlib-js/stdlib/commit/e4de24f1e086063876214e73f1f6b659dc624eb1) - **fix:** resolve bugs in addon.c files _(by Philipp Burckhardt)_
2637
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
2738
- [`2777e4b`](https://github.com/stdlib-js/stdlib/commit/2777e4be161869d09406e3b17947d24c64b47af2) - **bench:** resolve lint errors in benchmarks _(by Athan Reines)_
@@ -36,9 +47,10 @@
3647

3748
### Contributors
3849

39-
A total of 2 people contributed to this release. Thank you to the following contributors:
50+
A total of 3 people contributed to this release. Thank you to the following contributors:
4051

4152
- Athan Reines
53+
- Muhammad Haris
4254
- Philipp Burckhardt
4355

4456
</section>

CONTRIBUTORS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Mohammad Kaif <98884589+Kaif987@users.noreply.github.com>
5959
Momtchil Momtchev <momtchil@momtchev.com>
6060
Muhammad Haris <harriskhan047@outlook.com>
6161
Naresh Jagadeesan <naresh.naresh000@gmail.com>
62+
Neeraj Pathak <neerajrpathak710@gmail.com>
6263
NightKnight <Ahmedatwa866@yahoo.com>
6364
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
6465
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
@@ -69,6 +70,7 @@ Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
6970
Pranav Goswami <goswami.4@iitj.ac.in>
7071
Praneki <97080887+PraneGIT@users.noreply.github.com>
7172
Pratik <97464067+Pratik772846@users.noreply.github.com>
73+
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
7274
Priyansh <88396544+itsspriyansh@users.noreply.github.com>
7375
Pushpendra Chandravanshi <pushpendrachandravanshi4@gmail.com>
7476
RISHAV <115060907+rishav2404@users.noreply.github.com>
@@ -79,9 +81,11 @@ Ridam Garg <67867319+RidamGarg@users.noreply.github.com>
7981
Robert Gislason <gztown2216@yahoo.com>
8082
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
8183
Rutam <138517416+performant23@users.noreply.github.com>
84+
Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com>
8285
Ryan Seal <splrk@users.noreply.github.com>
8386
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
8487
SarthakPaandey <145528240+SarthakPaandey@users.noreply.github.com>
88+
Saurabh Singh <saurabhsraghuvanshi@gmail.com>
8589
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
8690
Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
8791
Shivam <11shivam00@gmail.com>

README.md

Lines changed: 133 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ The function has the following parameters:
8787

8888
- **N**: number of indexed elements.
8989
- **x**: input [`Float64Array`][@stdlib/array/float64].
90-
- **strideX**: index increment for the strided array.
90+
- **strideX**: stride length for `x`.
9191
- **out**: output [`Float64Array`][@stdlib/array/float64] whose first element is the sum and whose second element is the number of non-NaN elements.
92-
- **strideOut**: index increment for `out`.
92+
- **strideOut**: stride length for `out`.
9393

94-
The `N` and `stride` parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element in the strided array,
94+
The `N` and stride parameters determine which elements are accessed at runtime. For example, to compute the sum of every other element in the strided array,
9595

9696
```javascript
9797
var Float64Array = require( '@stdlib/array-float64' );
@@ -136,10 +136,10 @@ var v = dnannsumpw.ndarray( x.length, x, 1, 0, out, 1, 0 );
136136

137137
The function has the following additional parameters:
138138

139-
- **offsetX**: starting index for the strided array.
139+
- **offsetX**: starting index for `x`.
140140
- **offsetOut**: starting index for `out`.
141141

142-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, the `offset` parameter supports indexing semantics based on a starting index. For example, to calculate the sum of every other value in the strided array starting from the second value
142+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, offset parameters support indexing semantics based on starting indices. For example, to calculate the sum of every other element starting from the second element:
143143

144144
```javascript
145145
var Float64Array = require( '@stdlib/array-float64' );
@@ -198,8 +198,136 @@ console.log( out );
198198

199199
<!-- /.examples -->
200200

201+
<!-- C interface documentation. -->
202+
201203
* * *
202204

205+
<section class="c">
206+
207+
## C APIs
208+
209+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
210+
211+
<section class="intro">
212+
213+
</section>
214+
215+
<!-- /.intro -->
216+
217+
<!-- C usage documentation. -->
218+
219+
<section class="usage">
220+
221+
### Usage
222+
223+
```c
224+
#include "stdlib/blas/ext/base/dnannsumpw.h"
225+
```
226+
227+
#### stdlib_strided_dnannsumpw( N, \*X, strideX, \*n )
228+
229+
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation.
230+
231+
```c
232+
#include "stdlib/blas/base/shared.h"
233+
234+
const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
235+
CBLAS_INT n = 0;
236+
237+
double v = stdlib_strided_dnannsumpw( 4, x, 1, &n );
238+
// returns 7.0
239+
```
240+
241+
The function accepts the following arguments:
242+
243+
- **N**: `[in] CBLAS_INT` number of indexed elements.
244+
- **X**: `[in] double*` input array.
245+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
246+
- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
247+
248+
```c
249+
double stdlib_strided_dnannsumpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, CBLAS_INT *n );
250+
```
251+
252+
#### stdlib_strided_dnannsumpw_ndarray( N, \*X, strideX, offsetX, \*n )
253+
254+
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.
255+
256+
```c
257+
#include "stdlib/blas/base/shared.h"
258+
259+
const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
260+
CBLAS_INT n = 0;
261+
262+
double v = stdlib_strided_dnannsumpw_ndarray( 4, x, 1, 0, &n );
263+
// returns 7.0
264+
```
265+
266+
The function accepts the following arguments:
267+
268+
- **N**: `[in] CBLAS_INT` number of indexed elements.
269+
- **X**: `[in] double*` input array.
270+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
271+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
272+
- **n**: `[out] CBLAS_INT*` pointer for storing the number of non-NaN elements.
273+
274+
```c
275+
double stdlib_strided_dnannsumpw_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, CBLAS_INT *n );
276+
```
277+
278+
</section>
279+
280+
<!-- /.usage -->
281+
282+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
283+
284+
<section class="notes">
285+
286+
</section>
287+
288+
<!-- /.notes -->
289+
290+
<!-- C API usage examples. -->
291+
292+
<section class="examples">
293+
294+
### Examples
295+
296+
```c
297+
#include "stdlib/blas/ext/base/dnannsumpw.h"
298+
#include "stdlib/blase/base/shared.h"
299+
#include <stdio.h>
300+
301+
int main( void ) {
302+
// Create a strided array:
303+
const double x[] = { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 0.0/0.0, 0.0/0.0 };
304+
305+
// Specify the number of elements:
306+
const int N = 5;
307+
308+
// Specify the stride length:
309+
const int strideX = 2;
310+
311+
// Initialize a variable for storing the number of non-NaN elements:
312+
CBLAS_INT n = 0;
313+
314+
// Compute the sum:
315+
double v = stdlib_strided_dnannsumpw( N, x, strideX, &n );
316+
317+
// Print the result:
318+
printf( "sum: %lf\n", v );
319+
printf( "n: %"CBLAS_IFMT"\n", n );
320+
}
321+
```
322+
323+
</section>
324+
325+
<!-- /.examples -->
326+
327+
</section>
328+
329+
<!-- /.c -->
330+
203331
<section class="references">
204332
205333
## References

benchmark/benchmark.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ var dnannsumpw = require( './../lib/dnannsumpw.js' );
3333

3434
// FUNCTIONS //
3535

36+
/**
37+
* Returns a random number.
38+
*
39+
* @private
40+
* @returns {number} random number
41+
*/
42+
function rand() {
43+
if ( bernoulli( 0.8 ) > 0 ) {
44+
return uniform( -10.0, 10.0 );
45+
}
46+
return NaN;
47+
}
48+
3649
/**
3750
* Creates a benchmark function.
3851
*
@@ -48,13 +61,6 @@ function createBenchmark( len ) {
4861
out = new Float64Array( 2 );
4962
return benchmark;
5063

51-
function rand() {
52-
if ( bernoulli( 0.8 ) > 0 ) {
53-
return uniform( -10.0, 10.0 );
54-
}
55-
return NaN;
56-
}
57-
5864
function benchmark( b ) {
5965
var i;
6066

0 commit comments

Comments
 (0)