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 interface and refactor implementation
---
type: pre_push_report
description: Results of running various checks prior to pushing changes.
report:
- task: run_javascript_examples
status: na
- task: run_c_examples
status: na
- task: run_cpp_examples
status: na
- task: run_javascript_readme_examples
status: na
- task: run_c_benchmarks
status: na
- task: run_cpp_benchmarks
status: na
- task: run_fortran_benchmarks
status: na
- task: run_javascript_benchmarks
status: na
- task: run_julia_benchmarks
status: na
- task: run_python_benchmarks
status: na
- task: run_r_benchmarks
status: na
- task: run_javascript_tests
status: na
---
@@ -117,19 +115,17 @@ The function has the following parameters:
117
115
-**N**: number of indexed elements.
118
116
-**correction**: degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
The `N` and `stride` parameters determine which elements in `x` are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
120
+
The `N` and stride parameters determine which elements in the strided array are accessed at runtime. For example, to compute the [standard deviation][standard-deviation] of every other element in `x`,
The function has the following additional parameters:
167
159
168
-
-**offset**: starting index for `x`.
160
+
-**offsetX**: starting index for `x`.
169
161
170
-
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 [standard deviation][standard-deviation] for every other value in `x` starting from the second value
162
+
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 [standard deviation][standard-deviation] for every other element in `x` starting from the second element
var discreteUniform =require( '@stdlib/random/array/discrete-uniform' );
208
196
var dstdev =require( '@stdlib/stats/base/dstdev' );
209
197
210
-
var x;
211
-
var i;
212
-
213
-
x =newFloat64Array( 10 );
214
-
for ( i =0; i <x.length; i++ ) {
215
-
x[ i ] =round( (randu()*100.0) -50.0 );
216
-
}
198
+
var x =discreteUniform( 10, -50, 50, {
199
+
'dtype':'float64'
200
+
});
217
201
console.log( x );
218
202
219
203
var v =dstdev( x.length, 1, x, 1 );
@@ -224,6 +208,125 @@ console.log( v );
224
208
225
209
<!-- /.examples -->
226
210
211
+
<!-- C interface documentation. -->
212
+
213
+
* * *
214
+
215
+
<sectionclass="c">
216
+
217
+
## C APIs
218
+
219
+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
220
+
221
+
<sectionclass="intro">
222
+
223
+
</section>
224
+
225
+
<!-- /.intro -->
226
+
227
+
<!-- C usage documentation. -->
228
+
229
+
<sectionclass="usage">
230
+
231
+
### Usage
232
+
233
+
```c
234
+
#include"stdlib/stats/base/dstdev.h"
235
+
```
236
+
237
+
#### stdlib_strided_dstdev( N, correction, \*X, strideX )
238
+
239
+
Computes the [standard deviation][standard-deviation] of a double-precision floating-point strided array `x`.
240
+
241
+
```c
242
+
constdouble x[] = { 1.0, -2.0, 2.0 };
243
+
244
+
double v = stdlib_strided_dstdev( 3, 1.0, x, 1 );
245
+
// returns ~2.0817
246
+
```
247
+
248
+
The function accepts the following arguments:
249
+
250
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
251
+
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
252
+
- **x**: `[in] double*` input array.
253
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
double v = stdlib_strided_dstdev_ndarray( 4, 1.0, x, 2, 1 );
267
+
// returns ~2.0817
268
+
```
269
+
270
+
The function accepts the following arguments:
271
+
272
+
- **N**: `[in] CBLAS_INT` number of indexed elements.
273
+
- **correction**: `[in] double` degrees of freedom adjustment. Setting this parameter to a value other than `0` has the effect of adjusting the divisor during the calculation of the [standard deviation][standard-deviation] according to `N-c` where `c` corresponds to the provided degrees of freedom adjustment. When computing the [standard deviation][standard-deviation] of a population, setting this parameter to `0` is the standard choice (i.e., the provided array contains data constituting an entire population). When computing the corrected sample [standard deviation][standard-deviation], setting this parameter to `1` is the standard choice (i.e., the provided array contains data sampled from a larger population; this is commonly referred to as Bessel's correction).
274
+
- **X**: `[in] double*` input array.
275
+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
276
+
- **offsetX**: `[in] CBLAS_INT` starting index for `X`.
0 commit comments