You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[`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)
@@ -1992,6 +2014,7 @@ A total of 8 people contributed to this release. Thank you to the following cont
1992
2014
1993
2015
<details>
1994
2016
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)_
1995
2018
-[`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)_
1996
2019
-[`fdd3963`](https://github.com/stdlib-js/stdlib/commit/fdd3963096904e999191e354dede1ca59461adc2) - **chore:** minor clean-up _(by Philipp Burckhardt)_
1997
2020
-[`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)_
Copy file name to clipboardExpand all lines: ext/base/dnansumkbn2/README.md
+132-9Lines changed: 132 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,7 +36,7 @@ limitations under the License.
36
36
var dnansumkbn2 =require( '@stdlib/blas/ext/base/dnansumkbn2' );
37
37
```
38
38
39
-
#### dnansumkbn2( N, x, stride )
39
+
#### dnansumkbn2( N, x, strideX )
40
40
41
41
Computes the sum of double-precision floating-point strided array elements, ignoring `NaN` values and using a second-order iterative Kahan–Babuška algorithm.
42
42
@@ -45,15 +45,15 @@ var Float64Array = require( '@stdlib/array/float64' );
45
45
46
46
var x =newFloat64Array( [ 1.0, -2.0, NaN, 2.0 ] );
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`,
59
59
@@ -80,7 +80,7 @@ var v = dnansumkbn2( 4, x1, 2 );
80
80
// returns 5.0
81
81
```
82
82
83
-
#### dnansumkbn2.ndarray( N, x, stride, offset )
83
+
#### dnansumkbn2.ndarray( N, x, strideX, offsetX )
84
84
85
85
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.
86
86
@@ -89,15 +89,15 @@ var Float64Array = require( '@stdlib/array/float64' );
89
89
90
90
var x =newFloat64Array( [ 1.0, -2.0, NaN, 2.0 ] );
91
91
92
-
var v =dnansumkbn2.ndarray( 4, x, 1, 0 );
92
+
var v =dnansumkbn2.ndarray( x.length, x, 1, 0 );
93
93
// returns 1.0
94
94
```
95
95
96
96
The function has the following additional parameters:
97
97
98
-
-**offset**: starting index for `x`.
98
+
-**offsetX**: starting index for `x`.
99
99
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:
@@ -129,11 +129,19 @@ var v = dnansumkbn2.ndarray( 4, x, 2, 1 );
129
129
<!-- eslint no-undef: "error" -->
130
130
131
131
```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' );
133
134
var filledarrayBy =require( '@stdlib/array/filled-by' );
134
135
var dnansumkbn2 =require( '@stdlib/blas/ext/base/dnansumkbn2' );
135
136
136
-
var x =filledarrayBy( 10, 'float64', discreteUniform( 0, 100 ) );
137
+
functionclbk() {
138
+
if ( bernoulli( 0.7 ) >0 ) {
139
+
returndiscreteUniform( 0, 100 );
140
+
}
141
+
returnNaN;
142
+
}
143
+
144
+
var x =filledarrayBy( 10, 'float64', clbk );
137
145
console.log( x );
138
146
139
147
var v =dnansumkbn2( x.length, x, 1 );
@@ -144,8 +152,123 @@ console.log( v );
144
152
145
153
<!-- /.examples -->
146
154
155
+
<!-- C interface documentation. -->
156
+
147
157
* * *
148
158
159
+
<sectionclass="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
+
<sectionclass="intro">
166
+
167
+
</section>
168
+
169
+
<!-- /.intro -->
170
+
171
+
<!-- C usage documentation. -->
172
+
173
+
<sectionclass="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
+
constdouble 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`.
#### 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
+
constdouble 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`.
0 commit comments