Skip to content

Commit 82d453c

Browse files
committed
Auto-generated commit
1 parent 09dfeb9 commit 82d453c

22 files changed

+407
-204
lines changed

CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,6 +1491,28 @@ This release closes the following issue:
14911491

14921492
<!-- /.package -->
14931493

1494+
<section class="package" id="blas-ext-base-dnansumkbn2-unreleased">
1495+
1496+
#### [@stdlib/blas/ext/base/dnansumkbn2](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/base/dnansumkbn2)
1497+
1498+
<details>
1499+
1500+
<section class="features">
1501+
1502+
##### Features
1503+
1504+
- [`dc4b7b1`](https://github.com/stdlib-js/stdlib/commit/dc4b7b138a07ebbc5250fd7580ca758db7803875) - add C `ndarray` API and refactor `blas/ext/base/dnansumkbn2` [(#3000)](https://github.com/stdlib-js/stdlib/pull/3000)
1505+
1506+
</section>
1507+
1508+
<!-- /.features -->
1509+
1510+
</details>
1511+
1512+
</section>
1513+
1514+
<!-- /.package -->
1515+
14941516
<section class="package" id="blas-ext-base-dnansumors-unreleased">
14951517

14961518
#### [@stdlib/blas/ext/base/dnansumors](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/blas/ext/base/dnansumors)
@@ -1992,6 +2014,7 @@ A total of 8 people contributed to this release. Thank you to the following cont
19922014

19932015
<details>
19942016

2017+
- [`dc4b7b1`](https://github.com/stdlib-js/stdlib/commit/dc4b7b138a07ebbc5250fd7580ca758db7803875) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dnansumkbn2` [(#3000)](https://github.com/stdlib-js/stdlib/pull/3000) _(by Muhammad Haris, Athan Reines, Philipp Burckhardt)_
19952018
- [`371a494`](https://github.com/stdlib-js/stdlib/commit/371a49427e62050eb23947678b66aa529ee3890b) - **feat:** add C `ndarray` API and refactor `blas/ext/base/dnansumkbn` [(#2996)](https://github.com/stdlib-js/stdlib/pull/2996) _(by Muhammad Haris, Athan Reines)_
19962019
- [`fdd3963`](https://github.com/stdlib-js/stdlib/commit/fdd3963096904e999191e354dede1ca59461adc2) - **chore:** minor clean-up _(by Philipp Burckhardt)_
19972020
- [`78a7b34`](https://github.com/stdlib-js/stdlib/commit/78a7b34ccda3efe8d2613eb2eb27f8ca00adb66e) - **chore:** update package meta data [(#3038)](https://github.com/stdlib-js/stdlib/pull/3038) _(by stdlib-bot, Athan Reines)_

ext/base/dnansumkbn2/README.md

Lines changed: 132 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ limitations under the License.
3636
var dnansumkbn2 = require( '@stdlib/blas/ext/base/dnansumkbn2' );
3737
```
3838

39-
#### dnansumkbn2( N, x, stride )
39+
#### dnansumkbn2( N, x, strideX )
4040

4141
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm.
4242

@@ -45,15 +45,15 @@ var Float64Array = require( '@stdlib/array/float64' );
4545

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

48-
var v = dnansumkbn2( 4, x, 1 );
48+
var v = dnansumkbn2( x.length, x, 1 );
4949
// returns 1.0
5050
```
5151

5252
The function has the following parameters:
5353

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

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

@@ -80,7 +80,7 @@ var v = dnansumkbn2( 4, x1, 2 );
8080
// returns 5.0
8181
```
8282

83-
#### dnansumkbn2.ndarray( N, x, stride, offset )
83+
#### dnansumkbn2.ndarray( N, x, strideX, offsetX )
8484

8585
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
8686

@@ -89,15 +89,15 @@ var Float64Array = require( '@stdlib/array/float64' );
8989

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

92-
var v = dnansumkbn2.ndarray( 4, x, 1, 0 );
92+
var v = dnansumkbn2.ndarray( x.length, x, 1, 0 );
9393
// returns 1.0
9494
```
9595

9696
The function has the following additional parameters:
9797

98-
- **offset**: starting index for `x`.
98+
- **offsetX**: starting index for `x`.
9999

100-
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
100+
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:
101101

102102
```javascript
103103
var Float64Array = require( '@stdlib/array/float64' );
@@ -129,11 +129,19 @@ var v = dnansumkbn2.ndarray( 4, x, 2, 1 );
129129
<!-- eslint no-undef: "error" -->
130130

131131
```javascript
132-
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
132+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
133+
var bernoulli = require( '@stdlib/random/base/bernoulli' );
133134
var filledarrayBy = require( '@stdlib/array/filled-by' );
134135
var dnansumkbn2 = require( '@stdlib/blas/ext/base/dnansumkbn2' );
135136

136-
var x = filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
137+
function clbk() {
138+
if ( bernoulli( 0.7 ) > 0 ) {
139+
return discreteUniform( 0, 100 );
140+
}
141+
return NaN;
142+
}
143+
144+
var x = filledarrayBy( 10, 'float64', clbk );
137145
console.log( x );
138146

139147
var v = dnansumkbn2( x.length, x, 1 );
@@ -144,8 +152,123 @@ console.log( v );
144152

145153
<!-- /.examples -->
146154

155+
<!-- C interface documentation. -->
156+
147157
* * *
148158

159+
<section class="c">
160+
161+
## C APIs
162+
163+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
164+
165+
<section class="intro">
166+
167+
</section>
168+
169+
<!-- /.intro -->
170+
171+
<!-- C usage documentation. -->
172+
173+
<section class="usage">
174+
175+
### Usage
176+
177+
```c
178+
#include "stdlib/blas/ext/base/dnansumkbn2.h"
179+
```
180+
181+
#### stdlib_strided_dnansumkbn2( N, \*X, strideX )
182+
183+
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm.
184+
185+
```c
186+
const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
187+
188+
double v = stdlib_strided_dnansumkbn2( 4, x, 1 );
189+
// returns 7.0
190+
```
191+
192+
The function accepts the following arguments:
193+
194+
- **N**: `[in] CBLAS_INT` number of indexed elements.
195+
- **X**: `[in] double*` input array.
196+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
197+
198+
```c
199+
double stdlib_strided_dnansumkbn2( const CBLAS_INT N, const double *X, const CBLAS_INT strideX );
200+
```
201+
202+
#### stdlib_strided_dnansumkbn2_ndarray( N, \*X, strideX, offsetX )
203+
204+
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
205+
206+
```c
207+
const double x[] = { 1.0, 2.0, 0.0/0.0, 4.0 };
208+
209+
double v = stdlib_strided_dnansumkbn2_ndarray( 4, x, 1, 0 );
210+
// returns 7.0
211+
```
212+
213+
The function accepts the following arguments:
214+
215+
- **N**: `[in] CBLAS_INT` number of indexed elements.
216+
- **X**: `[in] double*` input array.
217+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
218+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
219+
220+
```c
221+
double stdlib_strided_dnansumkbn2_ndarray( const CBLAS_INT N, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX );
222+
```
223+
224+
</section>
225+
226+
<!-- /.usage -->
227+
228+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
229+
230+
<section class="notes">
231+
232+
</section>
233+
234+
<!-- /.notes -->
235+
236+
<!-- C API usage examples. -->
237+
238+
<section class="examples">
239+
240+
### Examples
241+
242+
```c
243+
#include "stdlib/blas/ext/base/dnansumkbn2.h"
244+
#include <stdio.h>
245+
246+
int main( void ) {
247+
// Create a strided array:
248+
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 };
249+
250+
// Specify the number of elements:
251+
const int N = 5;
252+
253+
// Specify the stride length:
254+
const int strideX = 2;
255+
256+
// Compute the sum:
257+
double v = stdlib_strided_dnansumkbn2( N, x, strideX );
258+
259+
// Print the result:
260+
printf( "sum: %lf\n", v );
261+
}
262+
```
263+
264+
</section>
265+
266+
<!-- /.examples -->
267+
268+
</section>
269+
270+
<!-- /.c -->
271+
149272
<section class="references">
150273
151274
## References

ext/base/dnansumkbn2/benchmark/benchmark.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ var dnansumkbn2 = require( './../lib/dnansumkbn2.js' );
3232

3333
// FUNCTIONS //
3434

35+
/**
36+
* Returns a random number.
37+
*
38+
* @private
39+
* @returns {number} random number
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.7 ) > 0 ) {
43+
return uniform( -100.0, 100.0 );
44+
}
45+
return NaN;
46+
}
47+
3548
/**
3649
* Creates a benchmark function.
3750
*
@@ -40,16 +53,9 @@ var dnansumkbn2 = require( './../lib/dnansumkbn2.js' );
4053
* @returns {Function} benchmark function
4154
*/
4255
function createBenchmark( len ) {
43-
var x = filledarrayBy( len, 'float64', clbk );
56+
var x = filledarrayBy( len, 'float64', rand );
4457
return benchmark;
4558

46-
function clbk() {
47-
if ( bernoulli( 0.7 ) > 0 ) {
48-
return uniform( -10.0, 10.0 );
49-
}
50-
return NaN;
51-
}
52-
5359
function benchmark( b ) {
5460
var v;
5561
var i;

ext/base/dnansumkbn2/benchmark/benchmark.native.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ var opts = {
4141

4242
// FUNCTIONS //
4343

44+
/**
45+
* Returns a random number.
46+
*
47+
* @private
48+
* @returns {number} random number
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.7 ) > 0 ) {
52+
return uniform( -100.0, 100.0 );
53+
}
54+
return NaN;
55+
}
56+
4457
/**
4558
* Creates a benchmark function.
4659
*
@@ -49,16 +62,9 @@ var opts = {
4962
* @returns {Function} benchmark function
5063
*/
5164
function createBenchmark( len ) {
52-
var x = filledarrayBy( len, 'float64', clbk );
65+
var x = filledarrayBy( len, 'float64', rand );
5366
return benchmark;
5467

55-
function clbk() {
56-
if ( bernoulli( 0.7 ) > 0 ) {
57-
return uniform( -10.0, 10.0 );
58-
}
59-
return NaN;
60-
}
61-
6268
function benchmark( b ) {
6369
var v;
6470
var i;

ext/base/dnansumkbn2/benchmark/benchmark.ndarray.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ var dnansumkbn2 = require( './../lib/ndarray.js' );
3232

3333
// FUNCTIONS //
3434

35+
/**
36+
* Returns a random number.
37+
*
38+
* @private
39+
* @returns {number} random number
40+
*/
41+
function rand() {
42+
if ( bernoulli( 0.7 ) > 0 ) {
43+
return uniform( -100.0, 100.0 );
44+
}
45+
return NaN;
46+
}
47+
3548
/**
3649
* Creates a benchmark function.
3750
*
@@ -40,16 +53,9 @@ var dnansumkbn2 = require( './../lib/ndarray.js' );
4053
* @returns {Function} benchmark function
4154
*/
4255
function createBenchmark( len ) {
43-
var x = filledarrayBy( len, 'float64', clbk );
56+
var x = filledarrayBy( len, 'float64', rand );
4457
return benchmark;
4558

46-
function clbk() {
47-
if ( bernoulli( 0.7 ) > 0 ) {
48-
return uniform( -10.0, 10.0 );
49-
}
50-
return NaN;
51-
}
52-
5359
function benchmark( b ) {
5460
var v;
5561
var i;

ext/base/dnansumkbn2/benchmark/benchmark.ndarray.native.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ var opts = {
4141

4242
// FUNCTIONS //
4343

44+
/**
45+
* Returns a random number.
46+
*
47+
* @private
48+
* @returns {number} random number
49+
*/
50+
function rand() {
51+
if ( bernoulli( 0.7 ) > 0 ) {
52+
return uniform( -100.0, 100.0 );
53+
}
54+
return NaN;
55+
}
56+
4457
/**
4558
* Creates a benchmark function.
4659
*
@@ -49,16 +62,9 @@ var opts = {
4962
* @returns {Function} benchmark function
5063
*/
5164
function createBenchmark( len ) {
52-
var x = filledarrayBy( len, 'float64', clbk );
65+
var x = filledarrayBy( len, 'float64', rand );
5366
return benchmark;
5467

55-
function clbk() {
56-
if ( bernoulli( 0.7 ) > 0 ) {
57-
return uniform( -10.0, 10.0 );
58-
}
59-
return NaN;
60-
}
61-
6268
function benchmark( b ) {
6369
var v;
6470
var i;

0 commit comments

Comments
 (0)