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/sapx
This PR renames `c_sapx` to `stdlib_strided_sapx`. The original naming convention stemmed from early construction of the `blas/ext/base` namespace in which it was not known whether to follow BLAS conventions (e.g., `c_*`) or stdlib's strided naming conventions (e.g., `stdlib_strided_`). Ultimately, we've opted to only use BLAS and LAPACK conventions for the known symbols in those respective libraries in order to avoid future naming collisions and explicitly distinguish stdlib's extensions from that of symbols whose origins are found elsewhere.
BREAKING CHANGE: rename `c_sapx` to `stdlib_strided_sapx`
To migrate, users should replace all instances of `c_sapx` with `stdlib_strided_sapx`.
PR-URL: stdlib-js#4696
Co-authored-by: Athan Reines <[email protected]>
Reviewed-by: Athan Reines <[email protected]>
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element
53
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to add a constant to every other element:
The function has the following additional parameters:
94
94
95
-
-**offset**: starting index.
95
+
-**offsetX**: starting index.
96
96
97
-
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 only the last three elements of the strided array
97
+
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 only the last three elements of the strided array:
var uniform =require( '@stdlib/random/base/uniform' ).factory;
130
-
var filledarrayBy =require( '@stdlib/array/filled-by' );
129
+
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
131
130
var sapx =require( '@stdlib/blas/ext/base/sapx' );
132
131
133
-
var x =filledarrayBy( 10, 'float32', uniform( -100.0, 100.0 ) );
132
+
var x =discreteUniform( 10, -100, 100, {
133
+
'dtype':'float32'
134
+
});
134
135
console.log( x );
135
136
136
137
sapx( x.length, 5.0, x, 1 );
@@ -141,6 +142,125 @@ console.log( x );
141
142
142
143
<!-- /.examples -->
143
144
145
+
<!-- C interface documentation. -->
146
+
147
+
* * *
148
+
149
+
<sectionclass="c">
150
+
151
+
## C APIs
152
+
153
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
154
+
155
+
<sectionclass="intro">
156
+
157
+
</section>
158
+
159
+
<!-- /.intro -->
160
+
161
+
<!-- C usage documentation. -->
162
+
163
+
<sectionclass="usage">
164
+
165
+
### Usage
166
+
167
+
```c
168
+
#include"stdlib/blas/ext/base/sapx.h"
169
+
```
170
+
171
+
#### stdlib_strided_sapx( N, alpha, \*X, strideX )
172
+
173
+
Adds a scalar constant to each element in a single-precision floating-point strided array.
174
+
175
+
```c
176
+
float x[] = { 1.0f, 2.0f, 3.0f, 4.0f };
177
+
178
+
stdlib_strided_sapx( 4, 5.0f, x, 1 );
179
+
```
180
+
181
+
The function accepts the following arguments:
182
+
183
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
0 commit comments