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
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element in `x`,
68
+
The `N` and stride parameters determine which elements in the strided arrays are accessed at runtime. For example, to compute the cumulative sum of every other element:
@@ -115,7 +115,7 @@ The function has the following additional parameters:
115
115
-**offsetX**: starting index for `x`.
116
116
-**offsetY**: starting index for `y`.
117
117
118
-
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying `buffer`, offset parameters support indexing semantics based on a starting indices. For example, to calculate the cumulative sum of every other value in `x`starting from the second value and to store in the last `N` elements of `y` starting from the last element
118
+
While [`typed array`][mdn-typed-array] views mandate a view offset based on the underlying buffer, the offset parameters support indexing semantics based on starting indices. For example, to calculate the cumulative sum of every other element starting from the second element and to store in the last `N` elements of `y` starting from the last element:
var discreteUniform =require( '@stdlib/random/base/discrete-uniform' ).factory;
152
-
var filledarrayBy =require( '@stdlib/array/filled-by' );
151
+
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
153
152
var scusumkbn2 =require( '@stdlib/blas/ext/base/scusumkbn2' );
154
153
155
-
var x =filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
156
-
154
+
var x =discreteUniform( 10, -100, 100, {
155
+
'dtype':'float32'
156
+
});
157
157
console.log( x );
158
158
159
-
var y =filledarrayBy( x.length, 'float32', discreteUniform( 0, 10 ) );
160
-
159
+
var y =discreteUniform( 10, -100, 100, {
160
+
'dtype':'float32'
161
+
});
161
162
console.log( y );
162
163
163
164
scusumkbn2( x.length, 0.0, x, 1, y, -1 );
@@ -168,8 +169,138 @@ console.log( y );
168
169
169
170
<!-- /.examples -->
170
171
172
+
<!-- C interface documentation. -->
173
+
171
174
* * *
172
175
176
+
<sectionclass="c">
177
+
178
+
## C APIs
179
+
180
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
181
+
182
+
<sectionclass="intro">
183
+
184
+
</section>
185
+
186
+
<!-- /.intro -->
187
+
188
+
<!-- C usage documentation. -->
189
+
190
+
<sectionclass="usage">
191
+
192
+
### Usage
193
+
194
+
```c
195
+
#include"stdlib/blas/ext/base/scusumkbn2.h"
196
+
```
197
+
198
+
#### stdlib_strided_scusumkbn2( N, sum, \*X, strideX, \*Y, strideY )
199
+
200
+
Computes the cumulative sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm.
201
+
202
+
```c
203
+
constfloat x[] = { 1.0f, 2.0f, 3.0f, 4.0f }
204
+
float y[] = { 0.0f, 0.0f, 0.0f, 0.0f }
205
+
206
+
stdlib_strided_scusumkbn2( 4, 0.0f, x, 1, y, 1 );
207
+
```
208
+
209
+
The function accepts the following arguments:
210
+
211
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
212
+
- **sum**: `[in] float` initial sum.
213
+
- **X**: `[in] float*` input array.
214
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
215
+
- **Y**: `[out] float*` output array.
216
+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
Computes the cumulative sum of single-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
229
+
230
+
```c
231
+
constfloat x[] = { 1.0f, 2.0f, 3.0f, 4.0f }
232
+
float y[] = { 0.0f, 0.0f, 0.0f, 0.0f }
233
+
234
+
stdlib_strided_scusumkbn2_ndarray( 4, 0.0f, x, 1, 0, y, 1, 0 );
235
+
```
236
+
237
+
The function accepts the following arguments:
238
+
239
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
240
+
- **sum**: `[in] float` initial sum.
241
+
- **X**: `[in] float*` input array.
242
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
243
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
244
+
- **Y**: `[out] float*` output array.
245
+
- **strideY**: `[in] CBLAS_INT` stride length for `Y`.
246
+
- **offsetY**: `[in] CBLAS_INT` starting index for `Y`.
0 commit comments