Skip to content

feat: add C implementation for math/base/special/gamma-lanczos-sum-expg-scaled #1836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 148 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
8fca2ea
feat: add C implementation for math/base/special/gamma-lanczos-sum-ex…
gunjjoshi Mar 11, 2024
3d4f2fd
Update README.md
gunjjoshi Mar 11, 2024
2e58ac8
Update benchmark.native.js
gunjjoshi Mar 11, 2024
fea9971
Update main.c
gunjjoshi Mar 11, 2024
dbfeea7
Update test.native.js
gunjjoshi Mar 11, 2024
d313372
feat: add C implementation for `math/base/special/acsch`
Snehil-Shah Mar 11, 2024
5496499
feat: add `math/base/assert/is-nonnegative-finite`
kawaho2 Mar 11, 2024
650a442
feat: add `math/base/special/asecd`
saisrikardumpeti Mar 11, 2024
e3e0f7d
build: run C benchmarks in CI workflow
Planeshifter Mar 11, 2024
89e11db
docs: improve README examples for `stats/base/dists/rayleigh` namespace
Jai0401 Mar 12, 2024
6abdf8c
feat: add C implementation for `math/base/special/log2`
aman-095 Mar 12, 2024
51679a6
docs: improve README examples of `stats/base/dists/negative-binomial`
kawaho2 Mar 12, 2024
88d6e8c
docs: update list of contributors
stdlib-bot Mar 12, 2024
7666cf5
docs: update related packages sections
stdlib-bot Mar 12, 2024
66318f9
feat: add C implementation for `math/base/special/gammasgn`
gunjjoshi Mar 12, 2024
2608c5e
feat: add C implementation for `math/base/special/ahaversin`
kawaho2 Mar 12, 2024
02ac085
feat: add C implementation for `math/base/special/xlogy`
performant23 Mar 12, 2024
9d7d30f
feat: add `math/base/special/cscd`
saisrikardumpeti Mar 12, 2024
ca1dacb
feat: add `math/base/special/acotd`
saisrikardumpeti Mar 12, 2024
65f9f74
feat: add `math/base/special/acscd`
saisrikardumpeti Mar 12, 2024
37fbcec
feat: add `math/base/special/secd`
saisrikardumpeti Mar 12, 2024
1462ad1
docs: update REPL namespace documentation
stdlib-bot Mar 12, 2024
e31053e
feat: add `math/base/special/acosd`
saisrikardumpeti Mar 12, 2024
a862aae
feat: add `math/base/special/atand`
saisrikardumpeti Mar 12, 2024
e5183d0
feat: add `math/base/special/asind`
saisrikardumpeti Mar 12, 2024
839699d
build: delete gypfile field when files are not present
Planeshifter Mar 12, 2024
ed4ed79
chore: update package meta data
stdlib-bot Mar 12, 2024
00161cd
docs: fix JSDoc description in `math/base/special/acoversin`
kawaho2 Mar 13, 2024
55448c0
feat: add `string/base/last-code-point`
adityacodes30 Mar 13, 2024
70fe50c
docs: update related packages sections
stdlib-bot Mar 13, 2024
f92750c
docs: update contributors
kgryte Mar 13, 2024
254833e
fix: update dependencies
kgryte Mar 13, 2024
d93cc78
fix: use correct package names
kgryte Mar 13, 2024
b20e62e
fix: update include path
kgryte Mar 13, 2024
2833d39
fix: update build configurations
kgryte Mar 13, 2024
12d421f
fix: update build configurations
kgryte Mar 13, 2024
7b2c8fb
fix: update build configurations
kgryte Mar 13, 2024
8404ab8
fix: update build configurations
kgryte Mar 13, 2024
bd33af6
fix: update build configurations and fix argument extraction
kgryte Mar 13, 2024
ffcde36
refactor: update `blas/ext/base/drev` to follow current project conve…
performant23 Mar 13, 2024
774318d
fix: update build configurations
kgryte Mar 13, 2024
93d6370
docs: update REPL namespace documentation
stdlib-bot Mar 13, 2024
f8d1e7c
feat: add C implementation for `math/base/special/bernoulli`
gunjjoshi Mar 14, 2024
3b0954c
refactor: update `blas/ext/base/dssum` to follow current projects con…
AuenKr Mar 14, 2024
ef8142e
feat: add C implementation for `math/base/assert/int32-is-odd`
kawaho2 Mar 14, 2024
4aaf3bb
feat: add C implementation for `math/base/assert/is-safe-integer`
aman-095 Mar 14, 2024
10bc5ae
feat: add C implementation for `math/base/assert/is-nonpositive-finite`
performant23 Mar 14, 2024
001c5e6
docs: update REPL namespace documentation
stdlib-bot Mar 14, 2024
e6ecd9d
feat: add C implementation for `math/base/special/xlog1py`
kawaho2 Mar 14, 2024
f6c02e0
feat: add C implementation for `math/base/special/boxcox`
gunjjoshi Mar 14, 2024
1a61ba7
feat: add C implementation for `math/base/special/boxcoxinv`
kawaho2 Mar 14, 2024
fc925f0
feat: add C implementation for `math/base/special/boxcox1p`
gunjjoshi Mar 14, 2024
f829ba5
feat: add C implementation for `math/base/special/boxcox1pinv`
kawaho2 Mar 14, 2024
704b91f
feat: add C implementation for `math/base/assert/uint32-is-pow2`
performant23 Mar 14, 2024
68f5580
chore: remove indentation
Planeshifter Mar 15, 2024
cc5685c
build: add workflow to auto-assign labels to PRs
Planeshifter Mar 15, 2024
16cbc3d
build: rename labeler config file
Planeshifter Mar 15, 2024
dc07a96
docs: improve README examples of `stats/base/dists/truncated-normal`
kawaho2 Mar 15, 2024
594e8c4
feat: add `math/base/special/tand`
saisrikardumpeti Mar 15, 2024
d5b7fdd
build: explicitly set token used in action
Planeshifter Mar 15, 2024
85c681d
feat: add `math/base/special/cotd`
saisrikardumpeti Mar 15, 2024
19d67d3
fix: remove labels
kgryte Mar 15, 2024
d05f9fd
docs: clean-up examples and descriptions
kgryte Mar 16, 2024
64ffe0e
feat: add C implementation for `math/base/assert/is-prime`
aman-095 Mar 15, 2024
f588998
feat: add C implementation for `math/base/special/acotd`
gunjjoshi Mar 15, 2024
b2a1819
feat: add C implementation for `math/base/special/asecd`
gunjjoshi Mar 15, 2024
35e7855
feat: add C implementation for `math/base/special/acsc`
kawaho2 Mar 15, 2024
e49dd66
feat: add C implementation for `math/base/special/atand`
kawaho2 Mar 15, 2024
df014f9
feat: add C implementation for `math/base/special/acosd`
gunjjoshi Mar 15, 2024
6ff0a8d
feat: add C implementation for `math/base/special/factorial2`
performant23 Mar 15, 2024
46fd37e
feat: add `countSameValue` to namespace
kgryte Mar 16, 2024
ba4aaf9
test: add test case to ensure full test coverage
kgryte Mar 16, 2024
c0d4b34
docs: add notes concerning algorithm
kgryte Mar 16, 2024
7f4ecc1
docs: add same value example
kgryte Mar 16, 2024
aebd22f
docs: clean-up documentation and examples and rename folder
kgryte Mar 16, 2024
8ea169d
feat: add `countSameValueZero` to namespace
kgryte Mar 16, 2024
6ff39bc
docs: fix copy
kgryte Mar 16, 2024
f9d56f8
docs: update test messages, comments, and benchmarks
kgryte Mar 16, 2024
498b779
docs: update related packages sections
stdlib-bot Mar 16, 2024
babdb98
feat: add `isNonNegativeFinite` to namespace
kgryte Mar 16, 2024
bbc52f4
feat: add `isNonNegativeFinite` to namespace
kgryte Mar 16, 2024
e4b0bd7
feat: add C implementation for `math/base/special/fast/hypot`
gunjjoshi Mar 16, 2024
eaee5fb
feat: add C implementation for `math/base/special/fast/acosh`
gunjjoshi Mar 16, 2024
25663f2
feat: add C implementation for `math/base/special/fast/abs`
gunjjoshi Mar 16, 2024
6c53e28
docs: update namespace table of contents
stdlib-bot Mar 16, 2024
1418fad
feat: add C implementation for `math/base/special/asind`
kawaho2 Mar 16, 2024
24452e0
docs: update namespace table of contents
stdlib-bot Mar 16, 2024
a49125b
feat: add C implementation for `math/base/special/fast/asinh`
kawaho2 Mar 16, 2024
d2dd197
fix: move addition by one into the sqrt invocation
Planeshifter Mar 16, 2024
cf3c635
build: update check given leading stdlib prefix is already included
Planeshifter Mar 16, 2024
db5bd15
docs: clean-up C function parameter and return annotations
Planeshifter Mar 17, 2024
f0d37d6
docs: fix function names in C example code
Planeshifter Mar 17, 2024
235df3f
chore: update package meta data
stdlib-bot Mar 17, 2024
a61dc8f
refactor: update `blas/ext/base/dnansum` to follow current project co…
AuenKr Mar 17, 2024
d05834c
docs: update REPL namespace documentation
stdlib-bot Mar 17, 2024
bd53ca9
feat: add C implementation for `math/base/special/fast/max`
kawaho2 Mar 17, 2024
2589293
feat: add C implementation for `math/base/special/fast/min`
kawaho2 Mar 17, 2024
e819c21
docs: update related packages sections
stdlib-bot Mar 17, 2024
5ee4692
fix: update variable type declarations in `math/base/assert/int32-is-…
performant23 Mar 17, 2024
68973fb
feat: add `utils/any-own-by`
Rec0iL99 Mar 17, 2024
b6b28fc
feat: update namespace TypeScript declarations
stdlib-bot Mar 17, 2024
8d34f4c
feat: add C implementation for `math/base/special/modf`
gunjjoshi Mar 17, 2024
e3a60c6
feat: add C implementation for `math/base/special/fast/pow-int`
gunjjoshi Mar 17, 2024
dbad34a
feat: add `math/base/special/cosd`
saisrikardumpeti Mar 17, 2024
8f77373
feat: add C implementation for `math/base/special/fast/atanh`
kawaho2 Mar 17, 2024
c630de5
feat: add C implementation for `math/base/assert/is-composite`
performant23 Mar 17, 2024
b6c9ff1
build: update installed R version
Planeshifter Mar 18, 2024
2ce89a6
build: skip labeler for auto PRs and only assign when all files match
Planeshifter Mar 18, 2024
d5d3083
build: update R lint configuration
Planeshifter Mar 18, 2024
7096bdd
docs: update list of contributors
stdlib-bot Mar 18, 2024
2ebe7ab
docs: update related packages sections
stdlib-bot Mar 18, 2024
fc11adf
refactor: update `blas/ext/base/dcusum` to follow current project con…
AuenKr Mar 19, 2024
fc9ce7d
docs: update REPL namespace documentation
stdlib-bot Mar 19, 2024
532aa3c
fix: missing headers in C examples
performant23 Mar 19, 2024
049a38a
feat: add `constants/float32/half-pi`
gunjjoshi Mar 19, 2024
65df942
fix: update documentation to reflect correct seed range
kgryte Mar 20, 2024
859b9b1
docs: update contributing guide to explicitly require running `make i…
kgryte Mar 20, 2024
1c7891d
docs: add note regarding spaces in directory path
kgryte Mar 20, 2024
d428bf0
docs: add note concerning native add-ons
kgryte Mar 20, 2024
1baed21
docs: add link
kgryte Mar 20, 2024
8aa2316
refactor: add support for ratios evaluating as infinity in `math/base…
gunjjoshi Mar 20, 2024
2517e7e
build: disable workflow
kgryte Mar 20, 2024
4522cd8
fix: address lint error
kgryte Mar 20, 2024
94ab2a2
feat: add C implementation for `math/base/special/gamma-lanczos-sum`
gunjjoshi Mar 21, 2024
8470eb0
refactor: update `blas/ext/base/scusum` to follow current project con…
AuenKr Mar 21, 2024
82ddff4
docs: update REPL namespace documentation
stdlib-bot Mar 21, 2024
7ca4c4c
refactor: update `blas/ext/base/scusumors`
rxbryan Mar 21, 2024
20d65af
refactor: update `blas/ext/base/scusumpw` to follow current project c…
rxbryan Mar 21, 2024
04e26c9
docs: update list of contributors
stdlib-bot Mar 21, 2024
376e743
fix: update build configuration
kgryte Mar 21, 2024
efea3bf
fix: update build configuration
kgryte Mar 21, 2024
403d820
fix: update build configuration and remove unnecessary cast
kgryte Mar 21, 2024
b5ae04a
refactor: update `blas/ext/base/dapx` to follow current project conve…
naveen1m Mar 21, 2024
9b4e669
refactor: update `blas/ext/base/sapxsum` to follow current project co…
gunjjoshi Mar 21, 2024
52ab774
docs: update namespace TypeScript declarations
stdlib-bot Mar 21, 2024
b0c96c9
docs: update REPL namespace documentation
stdlib-bot Mar 21, 2024
407b4d0
style: fix indentation
kgryte Mar 21, 2024
c21a718
fix: remove trailing commas
kgryte Mar 21, 2024
f4e9f11
fix: use correct variable names and fix configuration file
kgryte Mar 21, 2024
4623e89
refactor: remove explicit cast
kgryte Mar 21, 2024
ccab848
refactor: remove explicit cast
kgryte Mar 21, 2024
cda3983
refactor: remove explicit cast
kgryte Mar 21, 2024
920d8db
refactor: update `blas/ext/base/sapx` to follow current project conve…
rxbryan Mar 21, 2024
6e9fae3
fix: rename include directory for `constants/float32/half-pi`
gunjjoshi Mar 21, 2024
78242e1
docs: update REPL namespace documentation
stdlib-bot Mar 21, 2024
3fc4974
feat: add C implementation for gamma-lanczos-sum-expg-scaled
gunjjoshi Mar 21, 2024
e49bb9d
feat: add C implementation for gamma-lanczos-sum-expg-scaled
gunjjoshi Mar 21, 2024
d537af9
Revert "Update test.native.js"
gunjjoshi Mar 21, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,95 @@ for ( i = 0; i < x.length; i++ ) {

<!-- /.examples -->

<!-- C interface documentation. -->

* * *

<section class="c">

## C APIs

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- C usage documentation. -->

<section class="usage">

### Usage

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

#### gamma_lanczos_sum_expg_scaled( x )

Calculates the Lanczos sum for the approximation of the [gamma function][gamma-function] (scaled by `exp(-g)`, where `g = 10.900511`).

```c
double out = gamma_lanczos_sum_expg_scaled( 4.0 );
// returns ~0.018

out = gamma_lanczos_sum_expg_scaled( -1.5 );
// returns ~25.337
```

The function accepts the following arguments:

- **x**: `[in] double` input value.

```c
double gamma_lanczos_sum_expg_scaled( const double x );
```

</section>

<!-- /.usage -->

<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- C API usage examples. -->

<section class="examples">

### Examples

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

int main( void ) {
const double x[] = { 4.0, -1.5, -0.5, 0.5 };

double y;
int i;
for ( i = 0; i < 4; i++ ) {
y = stdlib_base_gamm_lanczos_sum_expg_scaled( x[ i ] );
printf( "gamm_lanczos_sum_expg_scaled(%lf) = %lf\n", x[ i ], y );
}
}
```

</section>

<!-- /.examples -->

</section>

<!-- /.c -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var randu = require( '@stdlib/random/base/randu' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var tryRequire = require( '@stdlib/utils/try-require' );
var pkg = require( './../package.json' ).name;


// VARIABLES //

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


// MAIN //

bench( pkg+'::native', opts, function benchmark( b ) {
var x;
var y;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
x = ( randu() * 100.0 ) - 50.0;
y = gammaLanczosSumExpGScaled( x );
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( y ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#/
# @license Apache-2.0
#
# Copyright (c) 2024 The Stdlib Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#/

# VARIABLES #

ifndef VERBOSE
QUIET := @
else
QUIET :=
endif

# Determine the OS ([1][1], [2][2]).
#
# [1]: https://en.wikipedia.org/wiki/Uname#Examples
# [2]: http://stackoverflow.com/a/27776822/2225624
OS ?= $(shell uname)
ifneq (, $(findstring MINGW,$(OS)))
OS := WINNT
else
ifneq (, $(findstring MSYS,$(OS)))
OS := WINNT
else
ifneq (, $(findstring CYGWIN,$(OS)))
OS := WINNT
else
ifneq (, $(findstring Windows_NT,$(OS)))
OS := WINNT
endif
endif
endif
endif

# Define the program used for compiling C source files:
ifdef C_COMPILER
CC := $(C_COMPILER)
else
CC := gcc
endif

# Define the command-line options when compiling C files:
CFLAGS ?= \
-std=c99 \
-O3 \
-Wall \
-pedantic

# Determine whether to generate position independent code ([1][1], [2][2]).
#
# [1]: https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#Code-Gen-Options
# [2]: http://stackoverflow.com/questions/5311515/gcc-fpic-option
ifeq ($(OS), WINNT)
fPIC ?=
else
fPIC ?= -fPIC
endif

# List of includes (e.g., `-I /foo/bar -I /beep/boop/include`):
INCLUDE ?=

# List of source files:
SOURCE_FILES ?=

# List of libraries (e.g., `-lopenblas -lpthread`):
LIBRARIES ?=

# List of library paths (e.g., `-L /foo/bar -L /beep/boop`):
LIBPATH ?=

# List of C targets:
c_targets := benchmark.out


# RULES #

#/
# Compiles source files.
#
# @param {string} [C_COMPILER] - C compiler (e.g., `gcc`)
# @param {string} [CFLAGS] - C compiler options
# @param {(string|void)} [fPIC] - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} [INCLUDE] - list of includes (e.g., `-I /foo/bar -I /beep/boop/include`)
# @param {string} [SOURCE_FILES] - list of source files
# @param {string} [LIBPATH] - list of library paths (e.g., `-L /foo/bar -L /beep/boop`)
# @param {string} [LIBRARIES] - list of libraries (e.g., `-lopenblas -lpthread`)
#
# @example
# make
#
# @example
# make all
#/
all: $(c_targets)

.PHONY: all

#/
# Compiles C source files.
#
# @private
# @param {string} CC - C compiler (e.g., `gcc`)
# @param {string} CFLAGS - C compiler options
# @param {(string|void)} fPIC - compiler flag determining whether to generate position independent code (e.g., `-fPIC`)
# @param {string} INCLUDE - list of includes (e.g., `-I /foo/bar`)
# @param {string} SOURCE_FILES - list of source files
# @param {string} LIBPATH - list of library paths (e.g., `-L /foo/bar`)
# @param {string} LIBRARIES - list of libraries (e.g., `-lopenblas`)
#/
$(c_targets): %.out: %.c
$(QUIET) $(CC) $(CFLAGS) $(fPIC) $(INCLUDE) -o $@ $(SOURCE_FILES) $< $(LIBPATH) -lm $(LIBRARIES)

#/
# Runs compiled benchmarks.
#
# @example
# make run
#/
run: $(c_targets)
$(QUIET) ./$<

.PHONY: run

#/
# Removes generated files.
#
# @example
# make clean
#/
clean:
$(QUIET) -rm -f *.o *.out

.PHONY: clean
Loading