Skip to content

Commit ac85575

Browse files
refactor: add int32_t logic around k parameter
1 parent b34faf8 commit ac85575

File tree

8 files changed

+20
-13
lines changed

8 files changed

+20
-13
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ double y = stdlib_base_dists_erlang_entropy( 1.0, 1.0 );
182182

183183
The function accepts the following arguments:
184184

185-
- **k**: `[in] double` shape parameter.
185+
- **k**: `[in] int32_t` shape parameter.
186186
- **lambda**: `[in] double` rate parameter.
187187

188188
```c
189-
double stdlib_base_dists_erlang_entropy( const double k, const double lambda );
189+
double stdlib_base_dists_erlang_entropy( const int32_t k, const double lambda );
190190
```
191191
192192
</section>
@@ -212,6 +212,7 @@ element and another before the `/section` close. -->
212212
#include "stdlib/stats/base/dists/erlang/entropy.h"
213213
#include "stdlib/constants/float64/eps.h"
214214
#include "stdlib/math/base/special/round.h"
215+
#include <stdint.h>
215216
#include <stdlib.h>
216217
#include <stdio.h>
217218
@@ -222,15 +223,15 @@ static double random_uniform( const double min, const double max ) {
222223
223224
int main( void ) {
224225
double lambda;
225-
double k;
226+
int32_t k;
226227
double y;
227228
int i;
228229
229230
for ( i = 0; i < 10; i++ ) {
230231
k = stdlib_base_round( random_uniform( 0.0, 10.0 ) );
231232
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
232233
y = stdlib_base_dists_erlang_entropy( k, lambda );
233-
printf( "k: %lf, λ: %lf, h(X;k,λ): %lf\n", k, lambda, y );
234+
printf( "k: %d, λ: %lf, h(X;k,λ): %lf\n", k, lambda, y );
234235
}
235236
}
236237
```

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

Lines changed: 2 additions & 1 deletion
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;
@@ -40,7 +41,7 @@ bench( pkg, function benchmark( b ) {
4041
var i;
4142

4243
len = 100;
43-
k = new Float64Array( len );
44+
k = new Int32Array( len );
4445
lambda = new Float64Array( len );
4546
for ( i = 0; i < len; i++ ) {
4647
k[ i ] = discreteUniform( 0.0, 10.0 );

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

Lines changed: 2 additions & 1 deletion
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' );
@@ -49,7 +50,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {
4950
var i;
5051

5152
len = 100;
52-
k = new Float64Array( len );
53+
k = new Int32Array( len );
5354
lambda = new Float64Array( len );
5455
for ( i = 0; i < len; i++ ) {
5556
k[ i ] = discreteUniform( 0.0, 10.0 );

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stdlib/stats/base/dists/erlang/entropy.h"
2020
#include "stdlib/constants/float64/eps.h"
2121
#include "stdlib/math/base/special/ceil.h"
22+
#include <stdint.h>
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425
#include <math.h>
@@ -95,7 +96,7 @@ static double random_uniform( const double min, const double max ) {
9596
*/
9697
static double benchmark( void ) {
9798
double elapsed;
98-
double k[ 100 ];
99+
int32_t k[ 100 ];
99100
double lambda[ 100 ];
100101
double y;
101102
double t;

lib/node_modules/@stdlib/stats/base/dists/erlang/entropy/examples/c/example.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/entropy.h"
2020
#include "stdlib/constants/float64/eps.h"
2121
#include "stdlib/math/base/special/round.h"
22+
#include <stdint.h>
2223
#include <stdlib.h>
2324
#include <stdio.h>
2425

@@ -29,14 +30,14 @@ static double random_uniform( const double min, const double max ) {
2930

3031
int main( void ) {
3132
double lambda;
32-
double k;
33+
int32_t k;
3334
double y;
3435
int i;
3536

3637
for ( i = 0; i < 10; i++ ) {
3738
k = stdlib_base_round( random_uniform( 0.0, 10.0 ) );
3839
lambda = random_uniform( STDLIB_CONSTANT_FLOAT64_EPS, 10.0 );
3940
y = stdlib_base_dists_erlang_entropy( k, lambda );
40-
printf( "k: %lf, λ: %lf, h(X;k,λ): %lf\n", k, lambda, y );
41+
printf( "k: %d, λ: %lf, h(X;k,λ): %lf\n", k, lambda, y );
4142
}
4243
}

lib/node_modules/@stdlib/stats/base/dists/erlang/entropy/include/stdlib/stats/base/dists/erlang/entropy.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_ENTROPY_H
2020
#define STDLIB_STATS_BASE_DISTS_ERLANG_ENTROPY_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
* Returns the differential entropy for a Erlang distribution with shape parameter `k` and rate parameter `lambda`.
3133
*/
32-
double stdlib_base_dists_erlang_entropy( const double k, const double lambda );
34+
double stdlib_base_dists_erlang_entropy( const int32_t k, const double lambda );
3335

3436
#ifdef __cplusplus
3537
}

lib/node_modules/@stdlib/stats/base/dists/erlang/entropy/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/binary.h"
2121

2222
// cppcheck-suppress shadowFunction
23-
STDLIB_MATH_BASE_NAPI_MODULE_DD_D( stdlib_base_dists_erlang_entropy )
23+
STDLIB_MATH_BASE_NAPI_MODULE_ID_D( stdlib_base_dists_erlang_entropy )

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "stdlib/math/base/special/gamma.h"
2323
#include "stdlib/math/base/special/ln.h"
2424
#include "stdlib/math/base/assert/is_nan.h"
25-
25+
#include <stdint.h>
2626

2727
/**
2828
* Returns the differential entropy for a Erlang distribution with shape parameter `k` and rate parameter `lambda`.
@@ -35,7 +35,7 @@
3535
* double y = stdlib_base_dists_erlang_entropy( 1.0, 1.0 );
3636
* // returns 1.0
3737
*/
38-
double stdlib_base_dists_erlang_entropy( const double k, const double lambda ) {
38+
double stdlib_base_dists_erlang_entropy( const int32_t k, const double lambda ) {
3939
if (
4040
!stdlib_base_is_positive_integer( k ) ||
4141
stdlib_base_is_nan( lambda ) ||

0 commit comments

Comments
 (0)