Skip to content

Commit 1c48f23

Browse files
Merge branch 'stdlib-js:develop' into develop
2 parents 78b5654 + b8259d3 commit 1c48f23

File tree

242 files changed

+11358
-1035
lines changed

Some content is hidden

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

242 files changed

+11358
-1035
lines changed

.mailmap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ Praneki <[email protected]> PraneGIT
106106

107107
Pratik <[email protected]> Pratik772846
108108

109+
Pratyush Kumar Chouhan <[email protected]> <[email protected]>
110+
Pratyush Kumar Chouhan <[email protected]> Pratyush
111+
109112
Priyansh <[email protected]> itsspriyansh
110113

111114
Pushpendra Chandravanshi <[email protected]> <[email protected]>

CONTRIBUTORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Prajwal Kulkarni <[email protected]>
6969
Pranav Goswami <[email protected]>
7070
7171
72+
Pratyush Kumar Chouhan <[email protected]>
7273
7374
Pushpendra Chandravanshi <[email protected]>
7475
@@ -79,6 +80,7 @@ Ridam Garg <[email protected]>
7980
Robert Gislason <[email protected]>
8081
Roman Stetsyk <[email protected]>
8182
83+
Ruthwik Chikoti <[email protected]>
8284
Ryan Seal <[email protected]>
8385
Sai Srikar Dumpeti <[email protected]>
8486
SarthakPaandey <[email protected]>

lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/README.md

Lines changed: 127 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ The function has the following parameters:
5454

5555
- **N**: number of indexed elements.
5656
- **x**: input [`Float64Array`][@stdlib/array/float64].
57-
- **strideX**: index increment for `x`.
57+
- **strideX**: stride length for `x`.
5858
- **out**: output [`Float64Array`][@stdlib/array/float64] whose first element is the sum and whose second element is the number of non-NaN elements.
59-
- **strideOut**: index increment for `out`.
59+
- **strideOut**: stride length for `out`.
6060

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

@@ -106,7 +106,7 @@ The function has the following additional parameters:
106106
- **offsetX**: starting index for `x`.
107107
- **offsetOut**: starting index for `out`.
108108

109-
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
109+
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:
110110

111111
```javascript
112112
var Float64Array = require( '@stdlib/array/float64' );
@@ -164,8 +164,132 @@ console.log( out );
164164

165165
<!-- /.examples -->
166166

167+
<!-- C interface documentation. -->
168+
167169
* * *
168170

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

lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/benchmark/benchmark.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ var dnannsumkbn2 = require( './../lib/dnannsumkbn2.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.7 ) > 0 ) {
44+
return discreteUniform( -10.0, 10.0 );
45+
}
46+
return NaN;
47+
}
48+
3649
/**
3750
* Creates a benchmark function.
3851
*
@@ -44,14 +57,7 @@ function createBenchmark( len ) {
4457
var out;
4558
var x;
4659

47-
function clbk() {
48-
if ( bernoulli( 0.7 ) > 0 ) {
49-
return discreteUniform( -10, 10 );
50-
}
51-
return NaN;
52-
}
53-
54-
x = filledarrayBy( len, 'float64', clbk );
60+
x = filledarrayBy( len, 'float64', rand );
5561
out = new Float64Array( 2 );
5662
return benchmark;
5763

lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/benchmark/benchmark.native.js

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

4343
// FUNCTIONS //
4444

45+
/**
46+
* Returns a random number.
47+
*
48+
* @private
49+
* @returns {number} random number
50+
*/
51+
function rand() {
52+
if ( bernoulli( 0.8 ) > 0 ) {
53+
return discreteUniform( -10.0, 10.0 );
54+
}
55+
return NaN;
56+
}
57+
4558
/**
4659
* Creates a benchmark function.
4760
*
@@ -53,14 +66,7 @@ function createBenchmark( len ) {
5366
var out;
5467
var x;
5568

56-
function clbk() {
57-
if ( bernoulli( 0.7 ) > 0 ) {
58-
return discreteUniform( -10, 10 );
59-
}
60-
return NaN;
61-
}
62-
63-
x = filledarrayBy( len, 'float64', clbk );
69+
x = filledarrayBy( len, 'float64', rand );
6470
out = new Float64Array( 2 );
6571
return benchmark;
6672

lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/benchmark/benchmark.ndarray.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ var dnannsumkbn2 = require( './../lib/ndarray.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 discreteUniform( -10.0, 10.0 );
45+
}
46+
return NaN;
47+
}
48+
3649
/**
3750
* Creates a benchmark function.
3851
*
@@ -44,14 +57,7 @@ function createBenchmark( len ) {
4457
var out;
4558
var x;
4659

47-
function clbk() {
48-
if ( bernoulli( 0.7 ) > 0 ) {
49-
return discreteUniform( -10, 10 );
50-
}
51-
return NaN;
52-
}
53-
54-
x = filledarrayBy( len, 'float64', clbk );
60+
x = filledarrayBy( len, 'float64', rand );
5561
out = new Float64Array( 2 );
5662
return benchmark;
5763

lib/node_modules/@stdlib/blas/ext/base/dnannsumkbn2/benchmark/benchmark.ndarray.native.js

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

4343
// FUNCTIONS //
4444

45+
/**
46+
* Returns a random number.
47+
*
48+
* @private
49+
* @returns {number} random number
50+
*/
51+
function rand() {
52+
if ( bernoulli( 0.8 ) > 0 ) {
53+
return discreteUniform( -10.0, 10.0 );
54+
}
55+
return NaN;
56+
}
57+
4558
/**
4659
* Creates a benchmark function.
4760
*
@@ -53,14 +66,7 @@ function createBenchmark( len ) {
5366
var out;
5467
var x;
5568

56-
function clbk() {
57-
if ( bernoulli( 0.7 ) > 0 ) {
58-
return discreteUniform( -10, 10 );
59-
}
60-
return NaN;
61-
}
62-
63-
x = filledarrayBy( len, 'float64', clbk );
69+
x = filledarrayBy( len, 'float64', rand );
6470
out = new Float64Array( 2 );
6571
return benchmark;
6672

0 commit comments

Comments
 (0)