Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/migration-guides/jstat/data/jstat_1_9_x.csv
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ betacf,(planned)
ibetainv,@stdlib/math/base/special/betaincinv
ibeta,@stdlib/math/base/special/betainc
gammafn,@stdlib/math/base/special/gamma
gammaln,@stdlib/math/base/special/gammaln
absgammaln,@stdlib/math/base/special/absgammaln
gammap,@stdlib/math/base/special/gammainc
lowRegGamma,@stdlib/math/base/special/gammainc
gammapinv,@stdlib/math/base/special/gammaincinv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ chiSquaredGoodnessOfFit,@stdlib/stats/chi2gof
epsilon,@stdlib/constants/math/float64-eps
factorial,@stdlib/math/base/special/factorial
gamma,@stdlib/math/base/special/gamma
gammaln,@stdlib/math/base/special/gammaln
absgammaln,@stdlib/math/base/special/absgammaln
uniqueCountSorted,N/A
extent,@stdlib/stats/base/range
extentSorted,(planned)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,42 +18,42 @@ limitations under the License.

-->

# gammaln
# absgammaln

> [Natural logarithm][@stdlib/math/base/special/ln] of the [gamma][@stdlib/math/base/special/gamma] function.
> [Natural logarithm][@stdlib/math/base/special/ln] of the [absolute][@stdlib/math/base/special/abs] value of the [gamma][@stdlib/math/base/special/gamma] function.

<section class="usage">

## Usage

```javascript
var gammaln = require( '@stdlib/math/base/special/gammaln' );
var absgammaln = require( '@stdlib/math/base/special/absgammaln' );
```

#### gammaln( x )
#### absgammaln( x )

Evaluates the [natural logarithm][@stdlib/math/base/special/ln] of the [gamma function][@stdlib/math/base/special/gamma].
Evaluates the [natural logarithm][@stdlib/math/base/special/ln] of the [absolute][@stdlib/math/base/special/abs] value of the [gamma][@stdlib/math/base/special/gamma] function.

```javascript
var v = gammaln( 2.0 );
var v = absgammaln( 2.0 );
// returns 0.0

v = gammaln( 1.0 );
v = absgammaln( 1.0 );
// returns 0.0

v = gammaln( 4.0 );
v = absgammaln( 4.0 );
// returns ~1.792

v = gammaln( -0.5 );
v = absgammaln( -0.5 );
// returns ~1.266

v = gammaln( 0.5 );
v = absgammaln( 0.5 );
// returns ~0.572

v = gammaln( 0.0 );
v = absgammaln( 0.0 );
// returns Infinity

v = gammaln( NaN );
v = absgammaln( NaN );
// returns NaN
```

Expand All @@ -70,14 +70,14 @@ v = gammaln( NaN );
```javascript
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var gammaln = require( '@stdlib/math/base/special/gammaln' );
var absgammaln = require( '@stdlib/math/base/special/absgammaln' );

var opts = {
'dtype': 'float64'
};
var x = uniform( 100, -10.0, 10.0, opts );

logEachMap( 'x: %0.4f, f(x): %0.4f', x, gammaln );
logEachMap( 'x: %0.4f, f(x): %0.4f', x, absgammaln );
```

</section>
Expand Down Expand Up @@ -107,18 +107,18 @@ logEachMap( 'x: %0.4f, f(x): %0.4f', x, gammaln );
### Usage

```c
#include "stdlib/math/base/special/gammaln.h"
#include "stdlib/math/base/special/absgammaln.h"
```

#### stdlib_base_gammaln( x )
#### stdlib_base_absgammaln( x )

Evaluates the [natural logarithm][@stdlib/math/base/special/ln] of the [gamma function][@stdlib/math/base/special/gamma].
Evaluates the [natural logarithm][@stdlib/math/base/special/ln] of the [absolute][@stdlib/math/base/special/abs] value of the [gamma][@stdlib/math/base/special/gamma] function.

```c
double out = stdlib_base_gammaln( 2.0 );
double out = stdlib_base_absgammaln( 2.0 );
// returns 0.0

out = stdlib_base_gammaln( 4.0 );
out = stdlib_base_absgammaln( 4.0 );
// returns ~1.792
```

Expand All @@ -127,7 +127,7 @@ The function accepts the following arguments:
- **x**: `[in] double` input value.

```c
double stdlib_base_gammaln( const double x );
double stdlib_base_absgammaln( const double x );
```

</section>
Expand All @@ -149,7 +149,7 @@ double stdlib_base_gammaln( const double x );
### Examples

```c
#include "stdlib/math/base/special/gammaln.h"
#include "stdlib/math/base/special/absgammaln.h"
#include <stdlib.h>
#include <stdio.h>

Expand All @@ -159,8 +159,8 @@ int main( void ) {
double y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_gammaln( x[ i ] );
printf( "gammaln(%lf) = %lf\n", x[ i ], y );
y = stdlib_base_absgammaln( x[ i ] );
printf( "absgammaln(%lf) = %lf\n", x[ i ], y );
}
}
```
Expand Down Expand Up @@ -195,6 +195,9 @@ int main( void ) {

[@stdlib/math/base/special/ln]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/ln

[@stdlib/math/base/special/abs]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/abs


<!-- <related-links> -->

[@stdlib/math/base/special/gamma]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/gamma
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var pkg = require( './../package.json' ).name;
var gammaln = require( './../lib' );
var absgammaln = require( './../lib' );


// MAIN //
Expand All @@ -38,7 +38,7 @@ bench( pkg, function benchmark( b ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = gammaln( x[ i%x.length ] );
y = absgammaln( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ var pkg = require( './../package.json' ).name;

// VARIABLES //

var gammaln = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var absgammaln = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( gammaln instanceof Error )
'skip': ( absgammaln instanceof Error )
};


Expand All @@ -47,7 +47,7 @@ bench( pkg+'::native', opts, function benchmark( b ) {

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = gammaln( x[ i%x.length ] );
y = absgammaln( x[ i%x.length ] );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <time.h>
#include <sys/time.h>

#define NAME "gammaln"
#define NAME "absgammaln"
#define ITERATIONS 1000000
#define REPEATS 3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <time.h>
#include <sys/time.h>

#define NAME "gammaln"
#define NAME "absgammaln"
#define ITERATIONS 1000000
#define REPEATS 3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* limitations under the License.
*/

#include "stdlib/math/base/special/gammaln.h"
#include "stdlib/math/base/special/absgammaln.h"
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>

#define NAME "gammaln"
#define NAME "absgammaln"
#define ITERATIONS 1000000
#define REPEATS 3

Expand Down Expand Up @@ -102,7 +102,7 @@ static double benchmark( void ) {

t = tic();
for ( i = 0; i < ITERATIONS; i++ ) {
y = stdlib_base_gammaln( x[ i%100 ] );
y = stdlib_base_absgammaln( x[ i%100 ] );
if ( y != y ) {
printf( "should not return NaN\n" );
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
using boost::random::uniform_real_distribution;
using boost::random::mt19937;

#define NAME "gammaln"
#define NAME "absgammaln"
#define ITERATIONS 1000000
#define REPEATS 3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import BenchmarkTools
using Printf

# Benchmark variables:
name = "gammaln";
name = "absgammaln";
repeats = 3;

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from __future__ import print_function
import timeit

NAME = "gammaln"
NAME = "absgammaln"
REPEATS = 3
ITERATIONS = 1000000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

"""Benchmark scipy.special.gammaln."""
"""Benchmark scipy.special.absgammaln."""

from __future__ import print_function
import timeit

NAME = "gammaln"
NAME = "absgammaln"
REPEATS = 3
ITERATIONS = 1000000

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ options( digits = 16L );
#' main();
main <- function() {
# Define benchmark parameters:
name <- "gammaln";
name <- 'absgammaln';
iterations <- 1000000L;
repeats <- 3L;

Expand All @@ -34,7 +34,7 @@ main <- function() {
#' @examples
#' print_version();
print_version <- function() {
cat( "TAP version 13\n" );
cat( 'TAP version 13\n' );
}

#' Print the TAP summary.
Expand All @@ -45,12 +45,12 @@ main <- function() {
#' @examples
#' print_summary( 3, 3 );
print_summary <- function( total, passing ) {
cat( "#\n" );
cat( paste0( "1..", total, "\n" ) ); # TAP plan
cat( paste0( "# total ", total, "\n" ) );
cat( paste0( "# pass ", passing, "\n" ) );
cat( "#\n" );
cat( "# ok\n" );
cat( '#\n' );
cat( paste0( '1..', total, '\n' ) ); # TAP plan
cat( paste0( '# total ', total, '\n' ) );
cat( paste0( '# pass ', passing, '\n' ) );
cat( '#\n' );
cat( '# ok\n' );
}

#' Print benchmark results.
Expand All @@ -62,11 +62,11 @@ main <- function() {
#' print_results( 10000L, 0.131009101868 );
print_results <- function( iterations, elapsed ) {
rate <- iterations / elapsed;
cat( " ---\n" );
cat( paste0( " iterations: ", iterations, "\n" ) );
cat( paste0( " elapsed: ", elapsed, "\n" ) );
cat( paste0( " rate: ", rate, "\n" ) );
cat( " ...\n" );
cat( ' ---\n' );
cat( paste0( ' iterations: ', iterations, '\n' ) );
cat( paste0( ' elapsed: ', elapsed, '\n' ) );
cat( paste0( ' rate: ', rate, '\n' ) );
cat( ' ...\n' );
}

#' Run a benchmark.
Expand All @@ -85,10 +85,10 @@ main <- function() {
#' elapsed <- benchmark( 10000L );
benchmark <- function( iterations ) {
# Run the benchmarks:
results <- microbenchmark::microbenchmark( lgamma( (1000.0*runif(1)) - 500.0 ), times = iterations );
results <- microbenchmark::microbenchmark( lgamma( (1000.0*runif(1.0)) - 500.0 ), times = iterations );

# Sum all the raw timing results to get a total "elapsed" time:
elapsed <- sum( results$time );
elapsed <- sum( results[['time']] );

# Convert the elapsed time from nanoseconds to seconds:
elapsed <- elapsed / 1.0e9;
Expand All @@ -97,11 +97,11 @@ main <- function() {
}

print_version();
for ( i in 1:repeats ) {
cat( paste0( "# r::", name, "\n" ) );
for ( i in 1L:repeats ) {
cat( paste0( '# r::', name, '\n' ) );
elapsed <- benchmark( iterations );
print_results( iterations, elapsed );
cat( paste0( "ok ", i, " benchmark finished", "\n" ) );
cat( paste0( 'ok ', i, ' benchmark finished', '\n' ) );
}
print_summary( repeats, repeats );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

{{alias}}( x )
Evaluates the natural logarithm of the gamma function.
Evaluates the natural logarithm of the absolute value of the gamma function
for a double-precision floating-point number.

Parameters
----------
Expand All @@ -10,7 +11,7 @@
Returns
-------
y: number
Natural logarithm of the gamma function.
Natural logarithm of the absolute value of the gamma function.

Examples
--------
Expand Down
Loading
Loading