Skip to content

Commit

Permalink
docs: use constants/float64/max-ln
Browse files Browse the repository at this point in the history
  • Loading branch information
gunjjoshi committed Dec 3, 2024
1 parent e5d32c5 commit ac6c283
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern "C" {
/**
* Evaluates the Riemann zeta function.
*/
double stdlib_base_zeta( const double x );
double stdlib_base_zeta( const double s );

#ifdef __cplusplus
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ var TWO_PI = require( '@stdlib/constants/float64/two-pi' );
var SQRT_EPSILON = require( '@stdlib/constants/float64/sqrt-eps' );
var LN_SQRT_TWO_PI = require( '@stdlib/constants/float64/ln-sqrt-two-pi' );
var MAX_SAFE_NTH_FACTORIAL = require( '@stdlib/constants/float64/max-safe-nth-factorial' );
var FLOAT64_MAX_LN = require( '@stdlib/constants/float64/max-ln' );
var ODD_POSITIVE_INTEGERS = require( './odd_positive_integers.json' );
var EVEN_NONNEGATIVE_INTEGERS = require( './even_nonnegative_integers.json' );
var BERNOULLI = require( './bernoulli.json' );
Expand All @@ -63,7 +64,6 @@ var rateval6 = require( './rational_p6q6.js' );
// VARIABLES //

var MAX_BERNOULLI_2N = 129;
var MAX_LN = 709; // TODO: consider making external constant
var Y1 = 1.2433929443359375;
var Y3 = 0.6986598968505859375;

Expand Down Expand Up @@ -265,7 +265,7 @@ function zeta( s ) {
tmp = sinpi( 0.5*sc ) * 2.0 * zeta( s );
r = gammaln( s );
r -= s * ln( TWO_PI );
if ( r > MAX_LN ) {
if ( r > floor( FLOAT64_MAX_LN ) ) {
return ( tmp < 0.0 ) ? NINF : PINF;
}
return tmp * exp( r );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"@stdlib/constants/float64/two-pi",
"@stdlib/constants/float64/sqrt-eps",
"@stdlib/constants/float64/ln-sqrt-two-pi",
"@stdlib/constants/float64/max-safe-nth-factorial"
"@stdlib/constants/float64/max-safe-nth-factorial",
"@stdlib/constants/float64/max-ln"
]
},
{
Expand Down Expand Up @@ -81,7 +82,8 @@
"@stdlib/constants/float64/two-pi",
"@stdlib/constants/float64/sqrt-eps",
"@stdlib/constants/float64/ln-sqrt-two-pi",
"@stdlib/constants/float64/max-safe-nth-factorial"
"@stdlib/constants/float64/max-safe-nth-factorial",
"@stdlib/constants/float64/max-ln"
]
},
{
Expand Down Expand Up @@ -110,7 +112,8 @@
"@stdlib/constants/float64/two-pi",
"@stdlib/constants/float64/sqrt-eps",
"@stdlib/constants/float64/ln-sqrt-two-pi",
"@stdlib/constants/float64/max-safe-nth-factorial"
"@stdlib/constants/float64/max-safe-nth-factorial",
"@stdlib/constants/float64/max-ln"
]
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
#include "stdlib/constants/float64/sqrt_eps.h"
#include "stdlib/constants/float64/ln_sqrt_two_pi.h"
#include "stdlib/constants/float64/max_safe_nth_factorial.h"
#include "stdlib/constants/float64/max_ln.h"
#include <stdint.h>

static const int32_t MAX_BERNOULLI_2N = 129;
static const double MAX_LN = 709.0;
static const double Y1 = 1.2433929443359375;
static const double Y3 = 0.6986598968505859375;

Expand Down Expand Up @@ -772,7 +772,7 @@ double stdlib_base_zeta( const double s ) {
tmp = stdlib_base_sinpi( 0.5 * sc ) * 2.0 * stdlib_base_zeta( scc );
r = stdlib_base_gammaln( scc );
r -= scc * stdlib_base_ln( STDLIB_CONSTANT_FLOAT64_TWO_PI );
if ( r > MAX_LN ) {
if ( r > stdlib_base_floor( STDLIB_CONSTANT_FLOAT64_MAX_LN ) ) {
return ( tmp < 0.0 ) ? STDLIB_CONSTANT_FLOAT64_NINF : STDLIB_CONSTANT_FLOAT64_PINF;
}
return tmp * stdlib_base_exp( r );
Expand Down

0 comments on commit ac6c283

Please sign in to comment.