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 [range][range] of every other element in `x`,
60
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [range][range] of every other element in `x`,
The function has the following additional parameters:
106
99
107
-
-**offset**: starting index for `x`.
100
+
-**offsetX**: starting index for `x`.
108
101
109
-
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 [range][range] for every other value in `x` starting from the second value
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 calculate the [range][range] for every other element in `x` starting from the second element
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
146
135
var srange =require( '@stdlib/stats/base/srange' );
147
136
148
-
var x;
149
-
var i;
150
-
151
-
x =newFloat32Array( 10 );
152
-
for ( i =0; i <x.length; i++ ) {
153
-
x[ i ] =round( (randu()*100.0) -50.0 );
154
-
}
137
+
var x =discreteUniform( 10, -50, 50, {
138
+
'dtype':'float32'
139
+
});
155
140
console.log( x );
156
141
157
142
var v =srange( x.length, x, 1 );
@@ -162,6 +147,123 @@ console.log( v );
162
147
163
148
<!-- /.examples -->
164
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/stats/base/srange.h"
174
+
```
175
+
176
+
#### stdlib_strided_srange( N, \*X, strideX )
177
+
178
+
Computes the [range][range] of a single-precision floating-point strided array `x`.
179
+
180
+
```c
181
+
constfloat x[] = { 1.0f, -2.0f, 3.0f, -4.0f };
182
+
183
+
float v = stdlib_strided_srange( 4, x, 1 );
184
+
// returns 7.0f
185
+
```
186
+
187
+
The function accepts the following arguments:
188
+
189
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
190
+
- **X**: `[in] float*` input array.
191
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
0 commit comments