Skip to content

Commit 12d5e2f

Browse files
committed
Use constantFunction, consolidate conditionals, and add empty lines
1 parent 47a6dca commit 12d5e2f

3 files changed

Lines changed: 9 additions & 26 deletions

File tree

lib/node_modules/@stdlib/math/base/dist/laplace/logcdf/lib/factory.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
// MODULES //
44

5+
var constantFunction = require( '@stdlib/utils/constant-function' );
56
var isnan = require( '@stdlib/math/base/assert/is-nan' );
67
var expm1 = require( '@stdlib/math/base/special/expm1' );
78
var log1p = require( '@stdlib/math/base/special/log1p' );
89
var LNHALF = require( '@stdlib/math/constants/float64-ln-half' );
9-
var nan = require( './nan.js' );
1010

1111

1212
// MAIN //
@@ -29,7 +29,7 @@ var nan = require( './nan.js' );
2929
*/
3030
function factory( mu, b ) {
3131
if ( isnan( mu ) || isnan( b ) || b <= 0.0 ) {
32-
return nan;
32+
return constantFunction( NaN );
3333
}
3434
return logcdf;
3535

lib/node_modules/@stdlib/math/base/dist/laplace/logcdf/lib/logcdf.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,23 @@ var LNHALF = require( '@stdlib/math/constants/float64-ln-half' );
2121
* @example
2222
* var y = logcdf( 2.0, 0.0, 1.0 );
2323
* // returns ~-0.07
24+
*
2425
* @example
2526
* var y = logcdf( 5.0, 10.0, 3.0 );
2627
* // returns ~-2.364
28+
*
2729
* @example
2830
* var y = logcdf( NaN, 0.0, 1.0 );
2931
* // returns NaN
32+
*
3033
* @example
3134
* var y = logcdf( 2, NaN, 1.0 );
3235
* // returns NaN
36+
*
3337
* @example
3438
* var y = logcdf( 2.0, 0.0, NaN );
3539
* // returns NaN
40+
*
3641
* @example
3742
* // Negative scale parameter:
3843
* var y = logcdf( 2.0, 0.0, -1.0 );
@@ -43,13 +48,11 @@ function logcdf( x, mu, b ) {
4348
if (
4449
isnan( x ) ||
4550
isnan( mu ) ||
46-
isnan( b )
51+
isnan( b ) ||
52+
b <= 0.0
4753
) {
4854
return NaN;
4955
}
50-
if ( b <= 0.0 ) {
51-
return NaN;
52-
}
5356
z = ( x - mu ) / b;
5457
if ( x < mu ) {
5558
return LNHALF + z;

lib/node_modules/@stdlib/math/base/dist/laplace/logcdf/lib/nan.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)