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 [mid-range][mid-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 [mid-range][mid-range] of every other element in `x`,
var x1 =newFloat32Array( x0.buffer, x0.BYTES_PER_ELEMENT*1 ); // start at 2nd element
83
80
84
-
varN=floor( x0.length/2 );
85
-
86
-
var v =smidrange( N, x1, 2 );
81
+
var v =smidrange( 4, x1, 2 );
87
82
// returns 1.0
88
83
```
89
84
90
-
#### smidrange.ndarray( N, x, stride, offset )
85
+
#### smidrange.ndarray( N, x, strideX, offsetX )
91
86
92
87
Computes the [mid-range][mid-range] of a single-precision floating-point strided array using alternative indexing semantics.
93
88
@@ -102,18 +97,16 @@ var v = smidrange.ndarray( x.length, x, 1, 0 );
102
97
103
98
The function has the following additional parameters:
104
99
105
-
-**offset**: starting index for `x`.
100
+
-**offsetX**: starting index for `x`.
106
101
107
-
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 [mid-range][mid-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 [mid-range][mid-range] for every other element in `x` starting from the second element
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
144
135
var smidrange =require( '@stdlib/stats/base/smidrange' );
145
136
146
-
var x;
147
-
var i;
148
-
149
-
x =newFloat32Array( 10 );
150
-
for ( i =0; i <x.length; i++ ) {
151
-
x[ i ] =round( (randu()*100.0) -50.0 );
152
-
}
137
+
var x =discreteUniform( 10, -50, 50, {
138
+
'dtype':'float32'
139
+
});
153
140
console.log( x );
154
141
155
142
var v =smidrange( x.length, x, 1 );
@@ -160,6 +147,123 @@ console.log( v );
160
147
161
148
<!-- /.examples -->
162
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/smidrange.h"
174
+
```
175
+
176
+
#### stdlib_strided_smidrange( N, \*X, strideX )
177
+
178
+
Computes the [mid-range][mid-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_smidrange( 4, x, 1 );
184
+
// returns 2.5f
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