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
feat: add C ndarray API and refactor blas/ext/base/dsapxsum
PR-URL: #3225
Reviewed-by: Philipp Burckhardt <pburckhardt@outlook.com>
Signed-off-by: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ext/base/dsapxsum/README.md
+135-14
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ limitations under the License.
20
20
21
21
# dsapxsum
22
22
23
-
> Add a constant to each single-precision floating-point strided array element and compute the sum using extended accumulation and returning an extended precision result.
23
+
> Add a scalar constant to each single-precision floating-point strided array element, and compute the sum using extended accumulation and returning an extended precision result.
24
24
25
25
<sectionclass="intro">
26
26
@@ -36,26 +36,27 @@ limitations under the License.
36
36
var dsapxsum =require( '@stdlib/blas/ext/base/dsapxsum' );
37
37
```
38
38
39
-
#### dsapxsum( N, alpha, x, stride )
39
+
#### dsapxsum( N, alpha, x, strideX )
40
40
41
-
Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and returning an extended precision result.
41
+
Adds a scalar constant to each single-precision floating-point strided array element, and computes the sum using extended accumulation and returning an extended precision result.
The `N` and `stride` parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element in the strided array,
59
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to access every other element:
@@ -80,24 +81,24 @@ var v = dsapxsum( 4, 5.0, x1, 2 );
80
81
// returns 25.0
81
82
```
82
83
83
-
#### dsapxsum.ndarray( N, alpha, x, stride, offset )
84
+
#### dsapxsum.ndarray( N, alpha, x, strideX, offsetX )
84
85
85
-
Adds a constant to each single-precision floating-point strided array element and computes the sum using extended accumulation and alternative indexing semantics and returning an extended precision result.
86
+
Adds a scalar constant to each single-precision floating-point strided array element, and computes the sum using extended accumulation and alternative indexing semantics and returning an extended precision result.
var v =dsapxsum.ndarray( x.length, 5.0, x, 1, 0 );
93
94
// returns 16.0
94
95
```
95
96
96
97
The function has the following additional parameters:
97
98
98
-
-**offset**: starting index for `x`.
99
+
-**offsetX**: starting index for `x`.
99
100
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 value in the strided array starting from the second value
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 access every other element starting from the second element:
@@ -130,11 +131,12 @@ var v = dsapxsum.ndarray( 4, 5.0, x, 2, 1 );
130
131
<!-- eslint no-undef: "error" -->
131
132
132
133
```javascript
133
-
var discreteUniform =require( '@stdlib/random/base/discrete-uniform' ).factory;
134
-
var filledarrayBy =require( '@stdlib/array/filled-by' );
134
+
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
135
135
var dsapxsum =require( '@stdlib/blas/ext/base/dsapxsum' );
136
136
137
-
var x =filledarrayBy( 10, 'float32', discreteUniform( 0, 100 ) );
137
+
var x =discreteUniform( 10.0, -100, 100, {
138
+
'dtype':'float32'
139
+
});
138
140
console.log( x );
139
141
140
142
var v =dsapxsum( x.length, 5.0, x, 1 );
@@ -145,6 +147,125 @@ console.log( v );
145
147
146
148
<!-- /.examples -->
147
149
150
+
<!-- C interface documentation. -->
151
+
152
+
* * *
153
+
154
+
<sectionclass="c">
155
+
156
+
## C APIs
157
+
158
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
159
+
160
+
<sectionclass="intro">
161
+
162
+
</section>
163
+
164
+
<!-- /.intro -->
165
+
166
+
<!-- C usage documentation. -->
167
+
168
+
<sectionclass="usage">
169
+
170
+
### Usage
171
+
172
+
```c
173
+
#include"stdlib/blas/ext/base/dsapxsum.h"
174
+
```
175
+
176
+
#### stdlib_strided_dsapxsum( N, alpha, \*X, strideX )
177
+
178
+
Adds a scalar constant to each single-precision floating-point strided array element, and computes the sum using extended accumulation and returning an extended precision result.
179
+
180
+
```c
181
+
constfloat x[] = { 1.0f, -2.0f, 2.0f };
182
+
183
+
double v = stdlib_strided_dsapxsum( 3, 5.0f, x, 1 );
184
+
// returns 16.0
185
+
```
186
+
187
+
The function accepts the following arguments:
188
+
189
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
190
+
- **alpha**: `[in] float` scalar constant.
191
+
- **X**: `[in] float*` input array.
192
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
#### stdlib_strided_dsapxsum_ndarray( N, alpha, \*X, strideX, offsetX )
199
+
200
+
Adds a scalar constant to each single-precision floating-point strided array element, and computes the sum using extended accumulation and alternative indexing semantics and returning an extended precision result.
201
+
202
+
```c
203
+
constfloat x[] = { 1.0f, -2.0f, 2.0f };
204
+
205
+
double v = stdlib_strided_dsapxsum_ndarray( 3, 5.0f, x, 1, 0 );
206
+
// returns 16.0
207
+
```
208
+
209
+
The function accepts the following arguments:
210
+
211
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
212
+
- **alpha**: `[in] float` scalar constant.
213
+
- **X**: `[in] float*` input array.
214
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
215
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments