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 minimum absolute value of 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 compute the minimum absolute value of every other element in `x`,
The function has the following additional parameters:
104
97
105
-
-**offset**: starting index for `x`.
98
+
-**offsetX**: starting index for `x`.
106
99
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 minimum absolute value for 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 calculate the minimum absolute value for every other element in `x` starting from the second element
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
144
133
var sminabs =require( '@stdlib/stats/base/sminabs' );
145
134
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
-
}
135
+
var x =discreteUniform( 10, -50, 50, {
136
+
'dtype':'float32'
137
+
});
153
138
console.log( x );
154
139
155
140
var v =sminabs( x.length, x, 1 );
@@ -160,6 +145,123 @@ console.log( v );
160
145
161
146
<!-- /.examples -->
162
147
148
+
<!-- C interface documentation. -->
149
+
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/stats/base/sminabs.h"
172
+
```
173
+
174
+
#### stdlib_strided_sminabs( N, \*X, strideX )
175
+
176
+
Computes the minimum absolute value of a single-precision floating-point strided array.
177
+
178
+
```c
179
+
constfloat x[] = { 1.0f, -2.0f, 3.0f, -4.0f };
180
+
181
+
float v = stdlib_strided_sminabs( 4, x, 1 );
182
+
// returns 1.0f
183
+
```
184
+
185
+
The function accepts the following arguments:
186
+
187
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
188
+
- **X**: `[in] float*` input array.
189
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
float v = stdlib_strided_sminabs( N, x, strideX );
251
+
252
+
// Print the result:
253
+
printf( "minabs: %f\n", v );
254
+
}
255
+
```
256
+
257
+
</section>
258
+
259
+
<!-- /.examples -->
260
+
261
+
</section>
262
+
263
+
<!-- /.c -->
264
+
163
265
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
164
266
165
267
<section class="related">
@@ -170,7 +272,7 @@ console.log( v );
170
272
171
273
- <span class="package-name">[`@stdlib/stats/base/dminabs`][@stdlib/stats/base/dminabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a double-precision floating-point strided array.</span>
172
274
- <span class="package-name">[`@stdlib/stats/base/minabs`][@stdlib/stats/base/minabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a strided array.</span>
173
-
- <spanclass="package-name">[`@stdlib/stats/base/smaxabs`][@stdlib/stats/base/smaxabs]</span><spanclass="delimiter">: </span><spanclass="description">calculate the maximum absolute value of a single-precision floating-point strided array.</span>
275
+
- <span class="package-name">[`@stdlib/stats/base/sminabsabs`][@stdlib/stats/base/sminabsabs]</span><span class="delimiter">: </span><span class="description">calculate the maximum absolute value of a single-precision floating-point strided array.</span>
174
276
- <span class="package-name">[`@stdlib/stats/base/smin`][@stdlib/stats/base/smin]</span><span class="delimiter">: </span><span class="description">calculate the minimum value of a single-precision floating-point strided array.</span>
175
277
- <span class="package-name">[`@stdlib/stats/base/snanminabs`][@stdlib/stats/base/snanminabs]</span><span class="delimiter">: </span><span class="description">calculate the minimum absolute value of a single-precision floating-point strided array, ignoring NaN values.</span>
0 commit comments