Skip to content

Commit 046574d

Browse files
chore: clean up
1 parent ef4f313 commit 046574d

File tree

10 files changed

+24
-31
lines changed

10 files changed

+24
-31
lines changed

lib/node_modules/@stdlib/stats/base/dists/erlang/mgf/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ double y = stdlib_base_dists_erlang_mgf( 0.3, 1, 1.0 );
199199
The function accepts the following arguments:
200200

201201
- **t**: `[in] double` input value.
202-
- **k**: `[in] double` shape parameter.
202+
- **k**: `[in] int32_t` shape parameter.
203203
- **lambda**: `[in] double` rate parameter.
204204

205205
```c
206-
double stdlib_base_dists_erlang_mgf( const double t, const double k, const double lambda );
206+
double stdlib_base_dists_erlang_mgf( const double t, const int32_t k, const double lambda );
207207
```
208208
209209
</section>
@@ -227,6 +227,7 @@ double stdlib_base_dists_erlang_mgf( const double t, const double k, const doubl
227227
```c
228228
#include "stdlib/stats/base/dists/erlang/mgf.h"
229229
#include "stdlib/math/base/special/round.h"
230+
#include <stdint.h>
230231
#include <stdlib.h>
231232
#include <stdio.h>
232233
@@ -237,7 +238,7 @@ static double random_uniform( const double min, const double max ) {
237238
238239
int main( void ) {
239240
double lambda;
240-
double k;
241+
int32_t k;
241242
double t;
242243
double y;
243244
int i;
@@ -247,7 +248,7 @@ int main( void ) {
247248
lambda = random_uniform( 0.0, 10.0 ) ;
248249
t = random_uniform( 0.0, lambda );
249250
y = stdlib_base_dists_erlang_mgf( t, k, lambda );
250-
printf( "t: %lf, k: %lf, λ: %lf, M_X(t;k,λ): %lf\n", t, k, lambda, y );
251+
printf( "t: %lf, k: %d, λ: %lf, M_X(t;k,λ): %lf\n", t, k, lambda, y );
251252
}
252253
}
253254
```

lib/node_modules/@stdlib/stats/base/dists/erlang/mgf/benchmark/benchmark.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ var bench = require( '@stdlib/bench' );
2424
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
2525
var uniform = require( '@stdlib/random/base/uniform' );
2626
var Float64Array = require( '@stdlib/array/float64' );
27+
var Int32Array = require( '@stdlib/array/int32' );
2728
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2829
var EPS = require( '@stdlib/constants/float64/eps' );
2930
var pkg = require( './../package.json' ).name;
@@ -41,11 +42,11 @@ bench( pkg, function benchmark( b ) {
4142
var i;
4243

4344
len = 100;
44-
k = new Float64Array( len );
45+
k = new Int32Array( len );
4546
lambda = new Float64Array( len );
4647
t = new Float64Array( len );
4748
for ( i = 0; i < len; i++ ) {
48-
k[ i ] = discreteUniform( 0.0, 100.0 );
49+
k[ i ] = discreteUniform( 1.0, 100.0 );
4950
lambda[ i ] = uniform( EPS, 20.0 );
5051
t[ i ] = uniform( 0.0, lambda[ i ] );
5152
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ var bench = require( '@stdlib/bench' );
2525
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
2626
var uniform = require( '@stdlib/random/base/uniform' );
2727
var Float64Array = require( '@stdlib/array/float64' );
28+
var Int32Array = require( '@stdlib/array/int32' );
2829
var isnan = require( '@stdlib/math/base/assert/is-nan' );
2930
var tryRequire = require( '@stdlib/utils/try-require' );
3031
var EPS = require( '@stdlib/constants/float64/eps' );
@@ -50,11 +51,11 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5051
var i;
5152

5253
len = 100;
53-
k = new Float64Array( len );
54+
k = new Int32Array( len );
5455
lambda = new Float64Array( len );
5556
t = new Float64Array( len );
5657
for ( i = 0; i < len; i++ ) {
57-
k[ i ] = discreteUniform( 0.0, 100.0 );
58+
k[ i ] = discreteUniform( 1.0, 100.0 );
5859
lambda[ i ] = uniform( EPS, 20.0 );
5960
t[ i ] = uniform( 0.0, lambda[ i ] );
6061
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stdlib/stats/base/dists/erlang/mgf.h"
2020
#include "stdlib/math/base/special/ceil.h"
2121
#include "stdlib/constants/float64/eps.h"
22+
#include <stdint.h>
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425
#include <math.h>
@@ -96,14 +97,14 @@ static double random_uniform( const double min, const double max ) {
9697
static double benchmark( void ) {
9798
double elapsed;
9899
double lambda[ 100 ];
99-
double k[ 100 ];
100+
int32_t k[ 100 ];
100101
double t[ 100 ];
101102
double x;
102103
double y;
103104
int i;
104105

105106
for ( i = 0; i < 100; i++ ) {
106-
k[ i ] = stdlib_base_ceil( random_uniform( 0.0, 100.0 ) );
107+
k[ i ] = stdlib_base_ceil( random_uniform( 1.0, 100.0 ) );
107108
lambda[ i ] = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 20.0 );
108109
t[ i ] = random_uniform( 0.0, lambda[ i ] );
109110
}

lib/node_modules/@stdlib/stats/base/dists/erlang/mgf/examples/c/example.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include "stdlib/stats/base/dists/erlang/mgf.h"
2020
#include "stdlib/math/base/special/round.h"
21+
#include <stdint.h>
2122
#include <stdlib.h>
2223
#include <stdio.h>
2324

@@ -28,7 +29,7 @@ static double random_uniform( const double min, const double max ) {
2829

2930
int main( void ) {
3031
double lambda;
31-
double k;
32+
int32_t k;
3233
double t;
3334
double y;
3435
int i;
@@ -38,6 +39,6 @@ int main( void ) {
3839
lambda = random_uniform( 0.0, 10.0 ) ;
3940
t = random_uniform( 0.0, lambda );
4041
y = stdlib_base_dists_erlang_mgf( t, k, lambda );
41-
printf( "t: %lf, k: %lf, λ: %1f, M_X(t;k,λ): %lf\n", t, k, lambda, y );
42+
printf( "t: %lf, k: %d, λ: %1f, M_X(t;k,λ): %lf\n", t, k, lambda, y );
4243
}
4344
}

lib/node_modules/@stdlib/stats/base/dists/erlang/mgf/include/stdlib/stats/base/dists/erlang/mgf.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef STDLIB_STATS_BASE_DISTS_ERLANG_MGF_H
2020
#define STDLIB_STATS_BASE_DISTS_ERLANG_MGF_H
2121

22+
#include <stdint.h>
23+
2224
/*
2325
* If C++, prevent name mangling so that the compiler emits a binary file having undecorated names, thus mirroring the behavior of a C compiler.
2426
*/
@@ -29,7 +31,7 @@ extern "C" {
2931
/**
3032
* Evaluates the moment-generating function (mgf) for a Erlang distribution with parameters shape parameter `k` and rate parameter `lambda`.
3133
*/
32-
double stdlib_base_dists_erlang_mgf( const double t, const double k, const double lambda );
34+
double stdlib_base_dists_erlang_mgf( const double t, const int32_t k, const double lambda );
3335

3436
#ifdef __cplusplus
3537
}

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,12 @@ var addon = require( './../src/addon.node' );
5959
* // returns NaN
6060
*
6161
* @example
62-
* var y = mgf( 0.2, -2, 0.5 );
63-
* // returns NaN
64-
*
65-
* @example
6662
* var y = mgf( 0.2, 0.5, 0.5 );
6763
* // returns NaN
6864
*
6965
* @example
7066
* var y = mgf( 0.2, 1, 0.0 );
7167
* // returns NaN
72-
*
73-
* @example
74-
* var y = mgf( 0.2, 1, -5.0 );
75-
* // returns NaN
7668
*/
7769
function mgf( t, k, lambda ) {
7870
return addon( t, k, lambda );

lib/node_modules/@stdlib/stats/base/dists/erlang/mgf/src/addon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
#include "stdlib/math/base/napi/ternary.h"
2121

2222
// cppcheck-suppress shadowFunction
23-
STDLIB_MATH_BASE_NAPI_MODULE_DDD_D( stdlib_base_dists_erlang_mgf )
23+
STDLIB_MATH_BASE_NAPI_MODULE_DID_D( stdlib_base_dists_erlang_mgf )

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@
3333
* double y = stdlib_base_dists_erlang_mgf( 0.3, 1, 1.0 );
3434
* // returns ~1.429
3535
*/
36-
double stdlib_base_dists_erlang_mgf( const double t, const double k, const double lambda ) {
36+
double stdlib_base_dists_erlang_mgf( const double t, const int32_t k, const double lambda ) {
3737
if (
3838
stdlib_base_is_nan( t ) ||
39-
!stdlib_base_is_nonnegative_integer( k ) ||
40-
isnan( lambda )||
39+
k <= 0.0 ||
40+
stdlib_base_is_nan( lambda )||
4141
lambda < 0.0 ||
4242
t >= lambda
4343
) {

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,6 @@ tape( 'if provided `NaN` for any parameter, the function returns `NaN`', opts, f
6666
tape( 'if provided a negative `k`, the function returns `NaN`', opts, function test( t ) {
6767
var y;
6868

69-
y = mgf( 2.0, -1.0, 2.0 );
70-
t.equal( isnan( y ), true, 'returns NaN' );
71-
72-
y = mgf( 0.0, -1.0, 2.0 );
73-
t.equal( isnan( y ), true, 'returns NaN' );
74-
7569
y = mgf( 2.0, NINF, 1.0 );
7670
t.equal( isnan( y ), true, 'returns NaN' );
7771

0 commit comments

Comments
 (0)