Skip to content

Commit c4bdf1c

Browse files
committed
chore: minor clean-up
--- 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: passed - 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: 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: passed ---
1 parent ff97e29 commit c4bdf1c

File tree

4 files changed

+43
-9
lines changed

4 files changed

+43
-9
lines changed

lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/benchmark/c/benchmark.c

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

19-
#include <sys/time.h>
2019
#include "stdlib/stats/base/dists/chisquare/mgf.h"
2120
#include <math.h>
2221
#include <stdio.h>
2322
#include <stdlib.h>
2423
#include <time.h>
24+
#include <sys/time.h>
2525

2626
#define NAME "chisquare-mgf"
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 elapsed;
6596
double t[ 100 ];
@@ -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-
// Use the current time to 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/chisquare/mgf/include/stdlib/stats/base/dists/chisquare/mgf.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ extern "C" {
2727
#endif
2828

2929
/**
30-
* Evaluates the moment-generating function (MGF) for a chi-squared distribution
31-
* with degrees of freedom `k` at a value `t`.
30+
* Evaluates the moment-generating function (MGF) for a chi-squared distribution with degrees of freedom `k` at a value `t`.
3231
*/
3332
double stdlib_base_dists_chisquare_mgf( const double t, const double k );
3433

lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/lib/native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ var addon = require( './../src/addon.node' );
3030
*
3131
* @private
3232
* @param {number} t - input value
33-
* @param {PositiveNumber} k - degrees of freedom
33+
* @param {NonNegativeNumber} k - degrees of freedom
3434
* @returns {number} evaluated MGF
3535
*
3636
* @example

lib/node_modules/@stdlib/stats/base/dists/chisquare/mgf/src/main.c

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

19+
#include "stdlib/stats/base/dists/chisquare/mgf.h"
1920
#include "stdlib/math/base/assert/is_nan.h"
2021
#include "stdlib/math/base/special/pow.h"
2122

2223
/**
2324
* Evaluates the moment-generating function (MGF) for a chi-squared distribution with degrees of freedom `k` at a value `t`.
2425
*
2526
* @param t input value
26-
* @param k degrees of freedom (must be nonnegative)
27-
* @return evaluated MGF, or NaN if input is invalid
27+
* @param k degrees of freedom
28+
* @return evaluated MGF
2829
*
2930
* @example
3031
* double y = stdlib_base_dists_chisquare_mgf( 0.0, 10.0 );

0 commit comments

Comments
 (0)