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
> Add a constant to each single-precision floating-point strided array element and compute the sum using a second-order iterative Kahan–Babuška algorithm.
23
+
> Add a scalar constant to each single-precision floating-point strided array element and compute the sum using a second-order iterative Kahan–Babuška algorithm.
24
24
25
25
<sectionclass="intro">
26
26
@@ -36,27 +36,26 @@ limitations under the License.
36
36
var sapxsumkbn2 =require( '@stdlib/blas/ext/base/sapxsumkbn2' );
37
37
```
38
38
39
-
#### sapxsumkbn2( N, alpha, x, stride )
39
+
#### sapxsumkbn2( N, alpha, x, strideX )
40
40
41
-
Adds a constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm.
41
+
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm.
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access 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 access every other element:
@@ -81,25 +80,24 @@ var v = sapxsumkbn2( 4, 5.0, x1, 2 );
81
80
// returns 25.0
82
81
```
83
82
84
-
#### sapxsumkbn2.ndarray( N, alpha, x, stride, offset )
83
+
#### sapxsumkbn2.ndarray( N, alpha, x, strideX, offsetX )
85
84
86
-
Adds a constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
85
+
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
var v =sapxsumkbn2.ndarray( x.length, 5.0, x, 1, 0 );
95
93
// returns 16.0
96
94
```
97
95
98
96
The function has the following additional parameters:
99
97
100
-
-**offset**: starting index for `x`.
98
+
-**offsetX**: starting index.
101
99
102
-
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 access 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 access every other element starting from the second element:
@@ -131,11 +129,12 @@ var v = sapxsumkbn2.ndarray( 4, 5.0, x, 2, 1 );
131
129
<!-- eslint no-undef: "error" -->
132
130
133
131
```javascript
134
-
var discreteUniform =require( '@stdlib/random/base/discrete-uniform' ).factory;
135
-
var filledarrayBy =require( '@stdlib/array/filled-by' );
132
+
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
136
133
var sapxsumkbn2 =require( '@stdlib/blas/ext/base/sapxsumkbn2' );
137
134
138
-
var x =filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
135
+
var x =discreteUniform( 10, -100, 100, {
136
+
'dtype':'float32'
137
+
});
139
138
console.log( x );
140
139
141
140
var v =sapxsumkbn2( x.length, 5.0, x, 1 );
@@ -146,8 +145,125 @@ console.log( v );
146
145
147
146
<!-- /.examples -->
148
147
148
+
<!-- C interface documentation. -->
149
+
149
150
* * *
150
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/sapxsumkbn2.h"
172
+
```
173
+
174
+
#### stdlib_strided_sapxsumkbn2( N, alpha, \*X, strideX )
175
+
176
+
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm.
177
+
178
+
```c
179
+
constfloat x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
180
+
181
+
float v = stdlib_strided_sapxsumkbn2( 4, 5.0f, x, 1 );
182
+
// returns 30.0f
183
+
```
184
+
185
+
The function accepts the following arguments:
186
+
187
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
#### stdlib_strided_sapxsumkbn2_ndarray( N, alpha, \*X, strideX, offsetX )
197
+
198
+
Adds a scalar constant to each single-precision floating-point strided array element and computes the sum using a second-order iterative Kahan–Babuška algorithm and alternative indexing semantics.
199
+
200
+
```c
201
+
constfloat x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
202
+
203
+
float v = stdlib_strided_sapxsumkbn2_ndarray( 4, 5.0f, x, 1, 0 );
204
+
// returns 30.0f
205
+
```
206
+
207
+
The function accepts the following arguments:
208
+
209
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
0 commit comments