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 `x`are accessed at runtime. For example, to compute the sum of every other element in `x`,
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:
Computes the sum of double-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
86
86
@@ -89,19 +89,18 @@ var Float64Array = require( '@stdlib/array/float64' );
89
89
90
90
var x =newFloat64Array( [ 1.0, -2.0, 2.0 ] );
91
91
92
-
var v =dsumkbn2.ndarray( 3, x, 1, 0 );
92
+
var v =dsumkbn2.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:
var floor =require( '@stdlib/math/base/special/floor' );
105
104
106
105
var x =newFloat64Array( [ 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 ] );
107
106
@@ -130,11 +129,12 @@ var v = dsumkbn2.ndarray( 4, x, 2, 1 );
130
129
<!-- eslint no-undef: "error" -->
131
130
132
131
```javascript
133
-
var discreteUniform =require( '@stdlib/random/base/discrete-uniform' ).factory;
134
-
var filledarrayBy =require( '@stdlib/array/filled-by' );
132
+
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
135
133
var dsumkbn2 =require( '@stdlib/blas/ext/base/dsumkbn2' );
136
134
137
-
var x =filledarrayBy( 10, 'float64', discreteUniform( -100, 100 ) );
135
+
var x =discreteUniform( 10, -100, 100, {
136
+
'dtype':'float64'
137
+
});
138
138
console.log( x );
139
139
140
140
var v =dsumkbn2( x.length, x, 1 );
@@ -145,8 +145,123 @@ console.log( v );
145
145
146
146
<!-- /.examples -->
147
147
148
+
<!-- C interface documentation. -->
149
+
148
150
* * *
149
151
152
+
<sectionclass="c">
153
+
154
+
## C APIs
155
+
156
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
157
+
158
+
<sectionclass="intro">
159
+
160
+
</section>
161
+
162
+
<!-- /.intro -->
163
+
164
+
<!-- C usage documentation. -->
165
+
166
+
<sectionclass="usage">
167
+
168
+
### Usage
169
+
170
+
```c
171
+
#include"stdlib/blas/ext/base/dsumkbn2.h"
172
+
```
173
+
174
+
#### stdlib_strided_dsumkbn2( N, \*X, strideX )
175
+
176
+
Computes the sum of double-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm.
177
+
178
+
```c
179
+
constdouble x[] = { 1.0, 2.0, 3.0, 4.0 };
180
+
181
+
double v = stdlib_strided_dsumkbn2( 4, x, 1 );
182
+
// returns 10.0
183
+
```
184
+
185
+
The function accepts the following arguments:
186
+
187
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
188
+
- **X**: `[in] double*` input array.
189
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dsumkbn2_ndarray( N, \*X, strideX, offsetX )
196
+
197
+
Computes the sum of double-precision floating-point strided array elements using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
198
+
199
+
```c
200
+
constdouble x[] = { 1.0, 2.0, 3.0, 4.0 };
201
+
202
+
double v = stdlib_strided_dsumkbn2_ndarray( 4, x, 1, 0 );
203
+
// returns 10.0
204
+
```
205
+
206
+
The function accepts the following arguments:
207
+
208
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
209
+
- **X**: `[in] double*` input array.
210
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
211
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments