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 Nov 21, 2024
1 parent b5ddd7b commit 3174a07
Show file tree
Hide file tree
Showing 30 changed files with 588 additions and 242 deletions.
1 change: 0 additions & 1 deletion .github/.keepalive

This file was deleted.

105 changes: 105 additions & 0 deletions .github/workflows/test_published_package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2024 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.
#/

# Workflow name:
name: test_published_package

# Workflow triggers:
on:
# Run workflow on a weekly schedule:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '4 4 * * 3'

# Run workflow upon completion of `publish` workflow run:
workflow_run:
workflows: ["publish"]
types: [completed]

# Allow workflow to be manually run:
workflow_dispatch:

# Workflow jobs:
jobs:
test-published:
# Define a display name:
name: 'Test running examples of published package'

# Define the type of virtual host machine:
runs-on: ubuntu-latest

# Define environment variables:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

# Run workflow job if `publish` workflow run is successful or when the workflow is manually run:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}

# Define the job's steps:
steps:
# Checkout the repository:
- name: 'Checkout repository'
uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0

# Install Node.js:
- name: 'Install Node.js'
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version: 20
timeout-minutes: 5

# Create test directory and run examples:
- name: 'Create test directory and run examples'
run: |
cd ..
mkdir test-published
cd test-published
# Copy example file:
cp $GITHUB_WORKSPACE/examples/index.js .
# Create a minimal package.json
echo '{
"name": "test-published",
"version": "1.0.0",
"main": "index.js",
"dependencies": {}
}' > package.json
# Get package name and modify example file:
PACKAGE_NAME=$(jq -r '.name' $GITHUB_WORKSPACE/package.json)
ESCAPED_PACKAGE_NAME=$(echo "$PACKAGE_NAME" | sed 's/[\/&]/\\&/g')
sed -i "s/require( '.\/..\/lib' )/require( '$ESCAPED_PACKAGE_NAME' )/g" index.js
# Extract and install dependencies:
DEPS=$(grep -oP "require\(\s*'([^']+)'\s*\)" index.js | sed "s/require(\s*'//" | sed "s/'\s*)//" | grep -v "^\.")
for dep in $DEPS; do
npm install $dep --save
done
# Run the example:
node index.js
# Send Slack notification if job fails:
- name: 'Send notification to Slack in case of failure'
uses: 8398a7/action-slack@28ba43ae48961b90635b50953d216767a6bea486 # v3.16.2
with:
status: ${{ job.status }}
channel: '#npm-ci'
if: failure()
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,25 @@
<section class="release" id="unreleased">

## Unreleased (2024-11-01)
## Unreleased (2024-11-21)

<section class="features">

### Features

- [`14021a5`](https://github.com/stdlib-js/stdlib/commit/14021a537b3f627a4ff0b3228b78d0433a6eb562) - add C `ndarray` API and refactor `blas/ext/base/dnansumpw` [(#3202)](https://github.com/stdlib-js/stdlib/pull/3202)

</section>

<!-- /.features -->

<section class="commits">

### Commits

<details>

- [`14021a5`](https://github.com/stdlib-js/stdlib/commit/14021a537b3f627a4ff0b3228b78d0433a6eb562) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dnansumpw` [(#3202)](https://github.com/stdlib-js/stdlib/pull/3202) _(by Muhammad Haris)_
- [`272ae7a`](https://github.com/stdlib-js/stdlib/commit/272ae7ac5c576c68cfab1b6e304c86407faa20cd) - **docs:** remove comment _(by Athan Reines)_
- [`2777e4b`](https://github.com/stdlib-js/stdlib/commit/2777e4be161869d09406e3b17947d24c64b47af2) - **bench:** resolve lint errors in benchmarks _(by Athan Reines)_

Expand All @@ -25,9 +36,10 @@

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:
A total of 2 people contributed to this release. Thank you to the following contributors:

- Athan Reines
- Muhammad Haris

</section>

Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Mohammad Kaif <98884589+Kaif987@users.noreply.github.com>
Momtchil Momtchev <momtchil@momtchev.com>
Muhammad Haris <harriskhan047@outlook.com>
Naresh Jagadeesan <naresh.naresh000@gmail.com>
Neeraj Pathak <neerajrpathak710@gmail.com>
NightKnight <Ahmedatwa866@yahoo.com>
Nithin Katta <88046362+nithinkatta@users.noreply.github.com>
Nourhan Hasan <109472010+TheNourhan@users.noreply.github.com>
Expand All @@ -69,6 +70,7 @@ Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
Pranav Goswami <goswami.4@iitj.ac.in>
Praneki <97080887+PraneGIT@users.noreply.github.com>
Pratik <97464067+Pratik772846@users.noreply.github.com>
Pratyush Kumar Chouhan <pratyushkumar0308@gmail.com>
Priyansh <88396544+itsspriyansh@users.noreply.github.com>
Pushpendra Chandravanshi <pushpendrachandravanshi4@gmail.com>
RISHAV <115060907+rishav2404@users.noreply.github.com>
Expand All @@ -79,9 +81,11 @@ Ridam Garg <67867319+RidamGarg@users.noreply.github.com>
Robert Gislason <gztown2216@yahoo.com>
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
Rutam <138517416+performant23@users.noreply.github.com>
Ruthwik Chikoti <145591715+ruthwikchikoti@users.noreply.github.com>
Ryan Seal <splrk@users.noreply.github.com>
Sai Srikar Dumpeti <80447788+the-r3aper7@users.noreply.github.com>
SarthakPaandey <145528240+SarthakPaandey@users.noreply.github.com>
Saurabh Singh <saurabhsraghuvanshi@gmail.com>
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
Shashank Shekhar Singh <shashankshekharsingh1205@gmail.com>
Shivam <11shivam00@gmail.com>
Expand Down
136 changes: 125 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,27 +69,26 @@ To view installation and usage instructions specific to each branch build, be su
var dnansumpw = require( '@stdlib/blas-ext-base-dnansumpw' );
```

#### dnansumpw( N, x, stride )
#### dnansumpw( N, x, strideX )

Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation.

```javascript
var Float64Array = require( '@stdlib/array-float64' );

var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );
var N = x.length;

var v = dnansumpw( N, x, 1 );
var v = dnansumpw( x.length, x, 1 );
// returns 1.0
```

The function has the following parameters:

- **N**: number of indexed elements.
- **x**: input [`Float64Array`][@stdlib/array/float64].
- **stride**: index increment for `x`.
- **strideX**: stride length for `x`.

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

```javascript
var Float64Array = require( '@stdlib/array-float64' );
Expand All @@ -114,7 +113,7 @@ var v = dnansumpw( 4, x1, 2 );
// returns 5.0
```

#### dnansumpw.ndarray( N, x, stride, offset )
#### dnansumpw.ndarray( N, x, strideX, offsetX )

Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.

Expand All @@ -123,15 +122,15 @@ var Float64Array = require( '@stdlib/array-float64' );

var x = new Float64Array( [ 1.0, -2.0, NaN, 2.0 ] );

var v = dnansumpw.ndarray( 4, x, 1, 0 );
var v = dnansumpw.ndarray( x.length, x, 1, 0 );
// returns 1.0
```

The function has the following additional parameters:

- **offset**: starting index for `x`.
- **offsetX**: starting index for `x`.

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 `x` starting from the second value
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 element starting from the second element:

```javascript
var Float64Array = require( '@stdlib/array-float64' );
Expand Down Expand Up @@ -169,14 +168,14 @@ var bernoulli = require( '@stdlib/random-base-bernoulli' );
var filledarrayBy = require( '@stdlib/array-filled-by' );
var dnansumpw = require( '@stdlib/blas-ext-base-dnansumpw' );

function clbk() {
function rand() {
if ( bernoulli( 0.7 ) > 0 ) {
return discreteUniform( 0, 100 );
}
return NaN;
}

var x = filledarrayBy( 10, 'float64', clbk );
var x = filledarrayBy( 10, 'float64', rand );
console.log( x );

var v = dnansumpw( x.length, x, 1 );
Expand All @@ -187,8 +186,123 @@ console.log( v );

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

```c
#include "stdlib/blas/ext/base/dnansumpw.h"
```

#### stdlib_strided_dnansumpw( N, \*X, strideX )

Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation.

```c
const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };

double v = stdlib_strided_dnansumpw( 4, x, 1 );
// returns 7.0
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
```c
double stdlib_strided_dnansumpw( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
```

#### stdlib_strided_dnansumpw_ndarray( N, \*X, strideX, offsetX )

Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using pairwise summation and alternative indexing semantics.

```c
const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };

double v = stdlib_strided_dnansumpw_ndarray( 4, x, 1, 0 );
// returns 7.0
```
The function accepts the following arguments:
- **N**: `[in] CBLAS_INT` number of indexed elements.
- **X**: `[in] double*` input array.
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
```c
double stdlib_strided_dnansumpw_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

```c
#include "stdlib/blas/ext/base/dnansumpw.h"
#include <stdio.h>

int main( void ) {
// Create a strided array:
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 };

// Specify the number of elements:
const int N = 5;

// Specify the stride length:
const int strideX = 2;

// Compute the sum:
double v = stdlib_strided_dnansumpw( N, x, strideX );

// Print the result:
printf( "sum: %lf\n", v );
}
```
</section>
<!-- /.examples -->
</section>
<!-- /.c -->
<section class="references">
## References
Expand Down
Loading

0 comments on commit 3174a07

Please sign in to comment.