Skip to content

Commit a93ccc0

Browse files
committed
refactor: precompute constant
--- 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: 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 --- --- 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: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - 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 177f0a0 commit a93ccc0

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

lib/node_modules/@stdlib/stats/base/dists/rayleigh/median/lib/main.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
// MODULES //
2222

2323
var isnan = require( '@stdlib/math/base/assert/is-nan' );
24-
var sqrt = require( '@stdlib/math/base/special/sqrt' );
25-
var LN2 = require( '@stdlib/constants/float64/ln-two' );
2624

2725

2826
// VARIABLES //
2927

30-
var SQRT2LN2 = sqrt( 2.0 * LN2 );
28+
var SQRT2LN2 = 1.1774100225154747; // sqrt(2*ln(2))
3129

3230

3331
// MAIN //

lib/node_modules/@stdlib/stats/base/dists/rayleigh/median/manifest.json

+3-9
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@
3939
"libpath": [],
4040
"dependencies": [
4141
"@stdlib/math/base/napi/unary",
42-
"@stdlib/math/base/assert/is-nan",
43-
"@stdlib/constants/float64/ln-two",
44-
"@stdlib/math/base/special/sqrt"
42+
"@stdlib/math/base/assert/is-nan"
4543
]
4644
},
4745
{
@@ -57,9 +55,7 @@
5755
"libpath": [],
5856
"dependencies": [
5957
"@stdlib/math/base/assert/is-nan",
60-
"@stdlib/constants/float64/ln-two",
61-
"@stdlib/constants/float64/eps",
62-
"@stdlib/math/base/special/sqrt"
58+
"@stdlib/constants/float64/eps"
6359
]
6460
},
6561
{
@@ -74,9 +70,7 @@
7470
"libraries": [],
7571
"libpath": [],
7672
"dependencies": [
77-
"@stdlib/math/base/assert/is-nan",
78-
"@stdlib/constants/float64/ln-two",
79-
"@stdlib/math/base/special/sqrt"
73+
"@stdlib/math/base/assert/is-nan"
8074
]
8175
}
8276
]

lib/node_modules/@stdlib/stats/base/dists/rayleigh/median/src/main.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919
#include "stdlib/stats/base/dists/rayleigh/median.h"
2020
#include "stdlib/math/base/assert/is_nan.h"
21-
#include "stdlib/math/base/special/sqrt.h"
22-
#include "stdlib/constants/float64/ln_two.h"
21+
22+
static const double SQRT2LN2 = 1.1774100225154747; // sqrt(2*ln(2))
2323

2424
/**
2525
* Returns the median of a Rayleigh distribution.
@@ -35,5 +35,5 @@ double stdlib_base_dists_rayleigh_median( const double sigma ) {
3535
if ( stdlib_base_is_nan( sigma ) || sigma < 0 ) {
3636
return 0.0 / 0.0; // NaN
3737
}
38-
return sigma * stdlib_base_sqrt( 2.0 * STDLIB_CONSTANT_FLOAT64_LN2 );
38+
return sigma * SQRT2LN2;
3939
}

0 commit comments

Comments
 (0)