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
-**stride**: index increment for the strided array.
56
+
-**strideX**: stride length.
57
57
58
-
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 the strided array,
58
+
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:
@@ -80,25 +80,24 @@ var v = sdsnansum( 4, x1, 2 );
80
80
// returns 5.0
81
81
```
82
82
83
-
#### sdsnansum.ndarray( N, x, stride, offset )
83
+
#### sdsnansum.ndarray( N, x, strideX, offsetX )
84
84
85
85
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using extended accumulation and alternative indexing semantics.
var x =newFloat32Array( [ 1.0, -2.0, NaN, 2.0 ] );
91
-
varN=x.length;
92
91
93
-
var v =sdsnansum.ndarray( N, x, 1, 0 );
92
+
var v =sdsnansum.ndarray( x.length, x, 1, 0 );
94
93
// returns 1.0
95
94
```
96
95
97
96
The function has the following additional parameters:
98
97
99
-
-**offset**: starting index for the strided array.
98
+
-**offsetX**: starting index.
100
99
101
-
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
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:
@@ -136,14 +135,14 @@ var bernoulli = require( '@stdlib/random/base/bernoulli' );
136
135
var filledarrayBy =require( '@stdlib/array/filled-by' );
137
136
var sdsnansum =require( '@stdlib/blas/ext/base/sdsnansum' );
138
137
139
-
functionrandOrNan() {
140
-
if ( bernoulli() <0.2 ) {
138
+
functionrand() {
139
+
if ( bernoulli(0.5) <1 ) {
141
140
returnNaN;
142
141
}
143
142
returndiscreteUniform( 0, 100 );
144
143
}
145
144
146
-
var x =filledarrayBy( 10, 'float32', randOrNan );
145
+
var x =filledarrayBy( 10, 'float32', rand );
147
146
console.log( x );
148
147
149
148
var v =sdsnansum( x.length, x, 1 );
@@ -154,6 +153,123 @@ console.log( v );
154
153
155
154
<!-- /.examples -->
156
155
156
+
<!-- C interface documentation. -->
157
+
158
+
* * *
159
+
160
+
<sectionclass="c">
161
+
162
+
## C APIs
163
+
164
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
165
+
166
+
<sectionclass="intro">
167
+
168
+
</section>
169
+
170
+
<!-- /.intro -->
171
+
172
+
<!-- C usage documentation. -->
173
+
174
+
<sectionclass="usage">
175
+
176
+
### Usage
177
+
178
+
```c
179
+
#include"stdlib/blas/ext/base/sdsnansum.h"
180
+
```
181
+
182
+
#### stdlib_strided_sdsnansum( N, \*X, strideX )
183
+
184
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using extended accumulation.
#### stdlib_strided_sdsnansum_ndarray( N, \*X, strideX, offsetX )
204
+
205
+
Computes the sum of single-precision floating-point strided array elements, ignoring `NaN` values and using extended accumulation and alternative indexing semantics.
0 commit comments