Skip to content

Commit 7e8b2b7

Browse files
committed
fix: address review issues in planck/cdf C implementation
- fix spacing in C benchmark and example files - fix variable declaration order in examples/index.js - add spaces around operators and function arguments --- 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: na - 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: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - 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 ---
1 parent 93fe50d commit 7e8b2b7

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

lib/node_modules/@stdlib/stats/base/dists/planck/cdf/benchmark/benchmark.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ bench( pkg, function benchmark( b ) {
4242
x = new Float64Array( len );
4343
lambda = new Float64Array( len );
4444
for ( i = 0; i < len; i++ ) {
45-
x[i] = discreteUniform(0, 40);
46-
lambda[i] = uniform(1, 10);
45+
x[i] = discreteUniform( 0, 40 );
46+
lambda[i] = uniform( 1, 10 );
4747
}
4848

4949
b.tic();
@@ -70,7 +70,7 @@ bench( pkg+':factory', function benchmark( b ) {
7070
var i;
7171

7272
len = 100;
73-
lambda = uniform(1, 10);
73+
lambda = uniform( 1, 10 );
7474
mycdf = cdf.factory( lambda );
7575
x = new Float64Array( len );
7676
for ( i = 0; i < len; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/planck/cdf/benchmark/c/benchmark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static double tic( void ) {
8383
*/
8484
static double random_uniform( const double min, const double max ) {
8585
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
86-
return min + ( v*(max-min) );
86+
return min + ( v * ( max - min ) );
8787
}
8888

8989
/**
@@ -134,7 +134,7 @@ int main( void ) {
134134
printf( "# c::%s\n", NAME );
135135
elapsed = benchmark();
136136
print_results( elapsed );
137-
printf( "ok %d benchmark finished\n", i+1 );
137+
printf( "ok %d benchmark finished\n", i + 1 );
138138
}
139139
print_summary( REPEATS, REPEATS );
140140
}

lib/node_modules/@stdlib/stats/base/dists/planck/cdf/examples/c/example.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,21 @@
2121
#include <stdio.h>
2222

2323
static double random_uniform( const double min, const double max ) {
24-
double v = (double)rand() / ((double)RAND_MAX + 1.0);
25-
return min + (v * (max - min));
24+
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
25+
return min + ( v * ( max - min ) );
2626
}
2727

28-
int main(void) {
28+
int main( void ) {
2929
double x;
3030
double lambda;
3131
double y;
3232
int i;
3333

34-
for (i = 0; i < 25; i++) {
35-
x = random_uniform(-10.0, 10.0);
36-
lambda = random_uniform(0.1, 5.0);
37-
y = stdlib_base_dists_planck_cdf(x, lambda);
38-
printf("x: %lf, lambda: %lf, F(x; lambda): %lf\n", x, lambda, y);
34+
for ( i = 0; i < 25; i++ ) {
35+
x = random_uniform( -10.0, 10.0 );
36+
lambda = random_uniform( 0.1, 5.0 );
37+
y = stdlib_base_dists_planck_cdf( x, lambda );
38+
printf( "x: %lf, lambda: %lf, F(x; lambda): %lf\n", x, lambda, y );
3939
}
4040

4141
return 0;

lib/node_modules/@stdlib/stats/base/dists/planck/cdf/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ var cdf = require( './../lib' );
2525
var x = discreteUniform( 10, 0, 5 );
2626
var lambda = uniform( 10, 0.1, 5.0 );
2727

28-
var y;
2928
var i;
29+
var y;
3030
for ( i = 0; i < lambda.length; i++ ) {
3131
y = cdf( x[ i ], lambda[ i ] );
3232
console.log( 'x: %d, λ: %d, F(x;λ): %d', x[ i ].toFixed( 4 ), lambda[ i ].toFixed( 4 ), y.toFixed( 4 ) );

0 commit comments

Comments
 (0)