Skip to content

Commit 57dd3dc

Browse files
committed
chore: reapply suggestions from PR review
--- 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: missing_dependencies - task: lint_c_examples status: missing_dependencies - task: lint_c_benchmarks status: missing_dependencies - 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: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - 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 988bcd8 commit 57dd3dc

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

lib/node_modules/@stdlib/stats/base/dists/degenerate/quantile/benchmark/c/benchmark.c

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,29 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/degenerate/quantile.h"
20-
#include <math.h>
21-
#include <stdio.h>
2220
#include <stdlib.h>
21+
#include <stdio.h>
22+
#include <math.h>
2323
#include <time.h>
2424
#include <sys/time.h>
2525

2626
#define NAME "degenerate-quantile"
2727
#define ITERATIONS 1000000
2828
#define REPEATS 3
2929

30+
/**
31+
* Prints the TAP version.
32+
*/
3033
static void print_version( void ) {
3134
printf( "TAP version 13\n" );
3235
}
3336

37+
/**
38+
* Prints the TAP summary.
39+
*
40+
* @param total total number of tests
41+
* @param passing total number of passing tests
42+
*/
3443
static void print_summary( int total, int passing ) {
3544
printf( "#\n" );
3645
printf( "1..%d\n", total ); // TAP plan
@@ -40,6 +49,11 @@ static void print_summary( int total, int passing ) {
4049
printf( "# ok\n" );
4150
}
4251

52+
/**
53+
* Prints benchmarks results.
54+
*
55+
* @param elapsed elapsed time in seconds
56+
*/
4357
static void print_results( double elapsed ) {
4458
double rate = (double)ITERATIONS / elapsed;
4559
printf( " ---\n" );
@@ -49,17 +63,34 @@ static void print_results( double elapsed ) {
4963
printf( " ...\n" );
5064
}
5165

66+
/**
67+
* Returns a clock time.
68+
*
69+
* @return clock time
70+
*/
5271
static double tic( void ) {
5372
struct timeval now;
5473
gettimeofday( &now, NULL );
55-
return (double)now.tv_sec + (double)now.tv_usec / 1.0e6;
74+
return (double)now.tv_sec + (double)now.tv_usec/1.0e6;
5675
}
5776

77+
/**
78+
* Generates a random number on the interval [min,max).
79+
*
80+
* @param min minimum value (inclusive)
81+
* @param max maximum value (exclusive)
82+
* @return random number
83+
*/
5884
static double random_uniform( const double min, const double max ) {
5985
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
60-
return min + ( v * ( max - min ) );
86+
return min + ( v*(max-min) );
6187
}
6288

89+
/**
90+
* Runs a benchmark.
91+
*
92+
* @return elapsed time in seconds
93+
*/
6394
static double benchmark( void ) {
6495
double mu[ 100 ];
6596
double p[ 100 ];
@@ -70,13 +101,13 @@ static double benchmark( void ) {
70101

71102
for ( i = 0; i < 100; i++ ) {
72103
p[ i ] = random_uniform( 0.0, 1.0 );
73-
mu[ i ] = random_uniform( -20.0, 20.0 );
104+
mu[ i ] = random_uniform( -50.0, 50.0 );
74105
}
75106

76107
start = tic();
77108
for ( i = 0; i < ITERATIONS; i++ ) {
78109
y = stdlib_base_dists_degenerate_quantile( p[ i % 100 ], mu[ i % 100 ] );
79-
if ( isnan( y ) ) { // Check for NaN
110+
if ( isnan( y ) ) {
80111
printf( "should not return NaN\n" );
81112
break;
82113
}
@@ -89,11 +120,14 @@ static double benchmark( void ) {
89120
return elapsed;
90121
}
91122

123+
/**
124+
* Main execution sequence.
125+
*/
92126
int main( void ) {
93127
double elapsed;
94128
int i;
95129

96-
// Seed the random number generator:
130+
// Use the current time to seed the random number generator:
97131
srand( time( NULL ) );
98132

99133
print_version();

lib/node_modules/@stdlib/stats/base/dists/degenerate/quantile/examples/c/example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
*/
1818

1919
#include "stdlib/stats/base/dists/degenerate/quantile.h"
20-
#include <stdio.h>
2120
#include <stdlib.h>
21+
#include <stdio.h>
2222

2323
static double random_uniform( const double min, const double max ) {
2424
double v = (double)rand() / ( (double)RAND_MAX + 1.0 );
@@ -27,8 +27,8 @@ static double random_uniform( const double min, const double max ) {
2727

2828
int main( void ) {
2929
double result;
30-
double p;
3130
double mu;
31+
double p;
3232
int i;
3333

3434
for ( i = 0; i < 10; i++ ) {

lib/node_modules/@stdlib/stats/base/dists/degenerate/quantile/src/addon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/napi/binary.h"
2019
#include "stdlib/stats/base/dists/degenerate/quantile.h"
20+
#include "stdlib/math/base/napi/binary.h"
2121

2222
// cppcheck-suppress shadowFunction
2323
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_degenerate_quantile )

lib/node_modules/@stdlib/stats/base/dists/degenerate/quantile/src/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "stdlib/math/base/assert/is_nan.h"
2019
#include "stdlib/stats/base/dists/degenerate/quantile.h"
20+
#include "stdlib/math/base/assert/is_nan.h"
2121

2222
/**
2323
* Evaluates the quantile function for a degenerate distribution centered at `mu`.
2424
*
25-
* @param p input value (probability)
25+
* @param p input value
2626
* @param mu constant value of the distribution
2727
* @return evaluated quantile function
2828
*

0 commit comments

Comments
 (0)