Skip to content

Commit b6ab880

Browse files
fix: updated readme.md and benchmark.length.c
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- 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: passed - task: run_c_benchmarks status: passed - 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 ---
1 parent d5fe50e commit b6ab880

File tree

2 files changed

+111
-6
lines changed

2 files changed

+111
-6
lines changed

lib/node_modules/@stdlib/stats/base/dmeanvarpn/README.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,115 @@ console.log( out );
239239

240240
<!-- /.examples -->
241241

242+
<!-- C usage documentation. -->
243+
244+
<section class="usage">
245+
246+
### Usage
247+
248+
```c
249+
#include "stdlib/stats/base/dmeanvarpn.h"
250+
```
251+
252+
#### stdlib_strided_dmeanvarpn( N, correction, \*X, strideX, \*Out, strideOut )
253+
254+
Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm.
255+
256+
```c
257+
double x[] ={ 1.0, -2.0, 2.0 };
258+
double out[2];
259+
stdlib_strided_dmeanvarpn( x.length, 1, x, 1, out, 1 );
260+
// Out = [ ~0.3333, ~4.3333 ]
261+
```
262+
263+
The function accepts the following arguments:
264+
265+
- **N**: `[in] CBLAS_INT` number of indexed elements.
266+
- **correction**: `[in] double` degrees of freedom adjustment.
267+
- **X**: `[in] double*` input array.
268+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
269+
- **Out**: `[in] double*` Output array.
270+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
271+
272+
```c
273+
double stdlib_strided_dmeanvarpn( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, double *Out, const CBLAS_INT strideOut );
274+
```
275+
276+
#### stdlib_strided_dmeanvarpn_ndarray( N, correction, \*X, strideX, offsetX, \*Out, strideOut, offsetOut )
277+
278+
Computes the [mean][arithmetic-mean] and [variance][variance] of a double-precision floating-point strided array using a two-pass algorithm and alternative indexing semantics.
279+
280+
```c
281+
const double x[] = { 1.0, -2.0, 2.0 };
282+
283+
stdlib_strided_dmeanvarpn_ndarray( x.length, 1, x, 1, 0, out, 1, 0 );
284+
// Out = [ ~0.3333, ~4.3333 ]
285+
```
286+
287+
The function accepts the following arguments:
288+
289+
- **N**: `[in] CBLAS_INT` number of indexed elements.
290+
- **correction**: `[in] double` degrees of freedom adjustment.
291+
- **X**: `[in] double*` input array.
292+
- **strideX**: `[in] CBLAS_INT` stride length for `X`.
293+
- **offsetX**: `[in] CBLAS_INT` `X` starting index.
294+
- **Out**: `[in] double*` Output array.
295+
- **strideOut**: `[in] CBLAS_INT` stride length for `Out`.
296+
- **offsetOut**: `[in] CBLAS_INT` `Out` starting index.
297+
298+
```c
299+
double stdlib_strided_dmeankbn2_ndarray( const CBLAS_INT N, const double correction, const double *X, const CBLAS_INT strideX, const CBLAS_INT offsetX, double *Out, const CBLAS_INT strideOut, const CBLAS_INT offsetOut );
300+
```
301+
302+
</section>
303+
304+
<!-- /.usage -->
305+
306+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
307+
308+
<section class="notes">
309+
310+
</section>
311+
312+
<!-- /.notes -->
313+
314+
<!-- C API usage examples. -->
315+
316+
<section class="examples">
317+
318+
### Examples
319+
320+
```c
321+
#include "stdlib/stats/base/dmeanvarpn.h"
322+
#include <stdio.h>
323+
324+
int main( void ) {
325+
// Create a strided array:
326+
const double x[] = { 2.0, 1.0, 2.0, -2.0, -2.0, 2.0, 3.0, 4.0 };
327+
328+
// Specify the number of elements:
329+
const CBLAS_INT N = 4;
330+
331+
// Specify the stride length:
332+
const CBLAS_INT strideX = 2;
333+
334+
// Compute the arithmetic mean:
335+
stdlib_strided_dmeanvarpn_ndarray( N, 1, x, 2, 1, out, 1, 0 );
336+
337+
// Print the result:
338+
printf( "sample mean: %lf\n", out[ 0 ] );
339+
printf( "sample variance: %lf\n", out[ 1 ] );
340+
}
341+
```
342+
343+
</section>
344+
345+
<!-- /.examples -->
346+
347+
</section>
348+
349+
<!-- /.c -->
350+
242351
* * *
243352
244353
<section class="references">

lib/node_modules/@stdlib/stats/base/dmeanvarpn/benchmark/c/benchmark.length.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,6 @@ static double rand_double( void ) {
9797
static double benchmark1( int iterations, int len ) {
9898
double elapsed;
9999
double out[ 2 ];
100-
if(len <= 0){
101-
return 0.0;
102-
}
103100
double x[ len ];
104101
double t;
105102
int i;
@@ -112,6 +109,7 @@ static double benchmark1( int iterations, int len ) {
112109

113110
t = tic();
114111
for ( i = 0; i < iterations; i++ ) {
112+
// cppcheck-suppress uninitvar
115113
stdlib_strided_dmeanvarpn( len, 1, x, 1, out, 1 );
116114
if ( out[ i%2 ] != out[ i%2 ] ) {
117115
printf( "should not return NaN\n" );
@@ -135,9 +133,6 @@ static double benchmark1( int iterations, int len ) {
135133
static double benchmark2( int iterations, int len ) {
136134
double elapsed;
137135
double out[ 2 ];
138-
if(len <= 0){
139-
return 0.0;
140-
}
141136
double x[ len ];
142137
double t;
143138
int i;
@@ -150,6 +145,7 @@ static double benchmark2( int iterations, int len ) {
150145

151146
t = tic();
152147
for ( i = 0; i < iterations; i++ ) {
148+
// cppcheck-suppress uninitvar
153149
stdlib_strided_dmeanvarpn_ndarray( len, 1, x, 1, 0, out, 1, 0 );
154150
if ( out[ i%2 ] != out[ i%2 ] ) {
155151
printf( "should not return NaN\n" );

0 commit comments

Comments
 (0)