Skip to content
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

feat: add C implementation for math/base/special/gamma-lanczos-sum #1834

Merged
merged 133 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
d8edd1a
feat: add C implementation for math/base/special/gamma-lanczos-sum
gunjjoshi Mar 11, 2024
283eab5
feat: add C implementation for math/base/special/gamma-lanczos-sum
gunjjoshi Mar 11, 2024
a21eded
feat: add C implementation for math/base/special/gamma-lanczos-sum
gunjjoshi Mar 11, 2024
d31d300
Apply suggestions from code review
kgryte Mar 11, 2024
8442b94
Apply suggestions from code review
kgryte Mar 11, 2024
ab3d495
fix: updated script to inject evalrational function
gunjjoshi Mar 12, 2024
1cc9a05
fix: updated script to inject evalrational function
gunjjoshi Mar 12, 2024
a69b3ef
Update main.c
gunjjoshi Mar 14, 2024
3daaa89
refactor: used evalrational-compile-c
gunjjoshi Mar 14, 2024
e43b002
refactor: used evalrational-compile-c
gunjjoshi Mar 14, 2024
93b6bdc
refactor: used evalrational-compile-c
gunjjoshi Mar 14, 2024
b232fed
Update test.native.js
gunjjoshi Mar 19, 2024
928b887
feat: add `iter/do-until-each`
raunak-dev-edu Mar 11, 2024
349cebe
fix: resolve failing addon build in `math/base/special/maxabs`
Pranavchiku Mar 11, 2024
f4c11a9
feat: add C implementation for `math/base/special/acsch`
Snehil-Shah Mar 11, 2024
f039c3e
feat: add `math/base/assert/is-nonnegative-finite`
Rejoan-Sardar Mar 11, 2024
58f2825
feat: add `math/base/special/asecd`
the-r3aper7 Mar 11, 2024
40d5cf2
build: run C benchmarks in CI workflow
Planeshifter Mar 11, 2024
d817ccd
docs: improve README examples for `stats/base/dists/rayleigh` namespace
Jai0401 Mar 12, 2024
72e6336
feat: add C implementation for `math/base/special/log2`
aman-095 Mar 12, 2024
3bfa4d2
docs: improve README examples of `stats/base/dists/negative-binomial`
Rejoan-Sardar Mar 12, 2024
4f08243
docs: update list of contributors
stdlib-bot Mar 12, 2024
9b5ebfd
docs: update related packages sections
stdlib-bot Mar 12, 2024
86de490
feat: add C implementation for `math/base/special/gammasgn`
gunjjoshi Mar 12, 2024
58c8017
feat: add C implementation for `math/base/special/ahaversin`
Rejoan-Sardar Mar 12, 2024
3ae4086
feat: add C implementation for `math/base/special/xlogy`
performant23 Mar 12, 2024
78e5cbd
feat: add `math/base/special/cscd`
the-r3aper7 Mar 12, 2024
ce93558
feat: add `math/base/special/acotd`
the-r3aper7 Mar 12, 2024
951455e
feat: add `math/base/special/acscd`
the-r3aper7 Mar 12, 2024
e7c84cb
feat: add `math/base/special/secd`
the-r3aper7 Mar 12, 2024
8adf7cf
docs: update REPL namespace documentation
stdlib-bot Mar 12, 2024
106aa02
feat: add `math/base/special/acosd`
the-r3aper7 Mar 12, 2024
8b3608f
feat: add `math/base/special/atand`
the-r3aper7 Mar 12, 2024
d687f3a
feat: add `math/base/special/asind`
the-r3aper7 Mar 12, 2024
65bee16
build: delete gypfile field when files are not present
Planeshifter Mar 12, 2024
eecaad4
chore: update package meta data
stdlib-bot Mar 12, 2024
16a34e8
docs: fix JSDoc description in `math/base/special/acoversin`
Rejoan-Sardar Mar 13, 2024
f371977
feat: add `string/base/last-code-point`
adityacodes30 Mar 13, 2024
be1f6dc
docs: update related packages sections
stdlib-bot Mar 13, 2024
0fd68fb
docs: update contributors
kgryte Mar 13, 2024
6f85ae0
fix: update dependencies
kgryte Mar 13, 2024
a20323e
fix: use correct package names
kgryte Mar 13, 2024
3645355
fix: update include path
kgryte Mar 13, 2024
76fcdff
fix: update build configurations
kgryte Mar 13, 2024
953f217
fix: update build configurations
kgryte Mar 13, 2024
2ece3de
fix: update build configurations
kgryte Mar 13, 2024
e524500
fix: update build configurations
kgryte Mar 13, 2024
7763d80
fix: update build configurations and fix argument extraction
kgryte Mar 13, 2024
62798f2
refactor: update `blas/ext/base/drev` to follow current project conve…
performant23 Mar 13, 2024
e0182c0
fix: update build configurations
kgryte Mar 13, 2024
8e11e59
docs: update REPL namespace documentation
stdlib-bot Mar 13, 2024
81538b3
feat: add C implementation for `math/base/special/bernoulli`
gunjjoshi Mar 14, 2024
88ca536
refactor: update `blas/ext/base/dssum` to follow current projects con…
AuenKr Mar 14, 2024
46c47a4
feat: add C implementation for `math/base/assert/int32-is-odd`
Rejoan-Sardar Mar 14, 2024
4c90605
feat: add C implementation for `math/base/assert/is-safe-integer`
aman-095 Mar 14, 2024
af9fe56
feat: add C implementation for `math/base/assert/is-nonpositive-finite`
performant23 Mar 14, 2024
c2ef5c5
docs: update REPL namespace documentation
stdlib-bot Mar 14, 2024
8d8adb7
feat: add C implementation for `math/base/special/xlog1py`
Rejoan-Sardar Mar 14, 2024
e6df6cc
feat: add C implementation for `math/base/special/boxcox`
gunjjoshi Mar 14, 2024
facf870
feat: add C implementation for `math/base/special/boxcoxinv`
Rejoan-Sardar Mar 14, 2024
9ee8270
feat: add C implementation for `math/base/special/boxcox1p`
gunjjoshi Mar 14, 2024
34e446d
feat: add C implementation for `math/base/special/boxcox1pinv`
Rejoan-Sardar Mar 14, 2024
5cd0f54
feat: add C implementation for `math/base/assert/uint32-is-pow2`
performant23 Mar 14, 2024
423e2da
chore: remove indentation
Planeshifter Mar 15, 2024
ae65ff4
build: add workflow to auto-assign labels to PRs
Planeshifter Mar 15, 2024
85c86a3
build: rename labeler config file
Planeshifter Mar 15, 2024
24a483f
docs: improve README examples of `stats/base/dists/truncated-normal`
Rejoan-Sardar Mar 15, 2024
fcdd541
feat: add `math/base/special/tand`
the-r3aper7 Mar 15, 2024
9254283
build: explicitly set token used in action
Planeshifter Mar 15, 2024
3b75725
feat: add `math/base/special/cotd`
the-r3aper7 Mar 15, 2024
65ae37d
fix: remove labels
kgryte Mar 15, 2024
db7c2de
docs: clean-up examples and descriptions
kgryte Mar 16, 2024
86eeb39
feat: add C implementation for `math/base/assert/is-prime`
aman-095 Mar 15, 2024
3b2c240
feat: add C implementation for `math/base/special/acotd`
gunjjoshi Mar 15, 2024
04a8cf1
feat: add C implementation for `math/base/special/asecd`
gunjjoshi Mar 15, 2024
3af23f1
feat: add C implementation for `math/base/special/acsc`
Rejoan-Sardar Mar 15, 2024
5c4b80a
feat: add C implementation for `math/base/special/atand`
Rejoan-Sardar Mar 15, 2024
de97ad0
feat: add C implementation for `math/base/special/acosd`
gunjjoshi Mar 15, 2024
5b7e4e8
feat: add C implementation for `math/base/special/factorial2`
performant23 Mar 15, 2024
9fc198c
feat: add `countSameValue` to namespace
kgryte Mar 16, 2024
5b41469
test: add test case to ensure full test coverage
kgryte Mar 16, 2024
46162b1
docs: add notes concerning algorithm
kgryte Mar 16, 2024
c9997d3
docs: add same value example
kgryte Mar 16, 2024
0ed97ff
docs: clean-up documentation and examples and rename folder
kgryte Mar 16, 2024
637033f
feat: add `countSameValueZero` to namespace
kgryte Mar 16, 2024
9230d13
docs: fix copy
kgryte Mar 16, 2024
35ed45f
docs: update test messages, comments, and benchmarks
kgryte Mar 16, 2024
8d677d6
docs: update related packages sections
stdlib-bot Mar 16, 2024
bf5a700
feat: add `isNonNegativeFinite` to namespace
kgryte Mar 16, 2024
64e21d8
feat: add `isNonNegativeFinite` to namespace
kgryte Mar 16, 2024
acd4359
feat: add C implementation for `math/base/special/fast/hypot`
gunjjoshi Mar 16, 2024
1c536ce
feat: add C implementation for `math/base/special/fast/acosh`
gunjjoshi Mar 16, 2024
fd5ccaa
feat: add C implementation for `math/base/special/fast/abs`
gunjjoshi Mar 16, 2024
936d66b
docs: update namespace table of contents
stdlib-bot Mar 16, 2024
2955d27
feat: add C implementation for `math/base/special/asind`
Rejoan-Sardar Mar 16, 2024
fa08e93
docs: update namespace table of contents
stdlib-bot Mar 16, 2024
6af9d62
feat: add C implementation for `math/base/special/fast/asinh`
Rejoan-Sardar Mar 16, 2024
fc593b2
fix: move addition by one into the sqrt invocation
Planeshifter Mar 16, 2024
1206c46
build: update check given leading stdlib prefix is already included
Planeshifter Mar 16, 2024
988c976
docs: clean-up C function parameter and return annotations
Planeshifter Mar 17, 2024
1b36a97
docs: fix function names in C example code
Planeshifter Mar 17, 2024
79d9be3
chore: update package meta data
stdlib-bot Mar 17, 2024
afae1fe
refactor: update `blas/ext/base/dnansum` to follow current project co…
AuenKr Mar 17, 2024
083636e
docs: update REPL namespace documentation
stdlib-bot Mar 17, 2024
50d3115
feat: add C implementation for `math/base/special/fast/max`
Rejoan-Sardar Mar 17, 2024
f0eb5ae
feat: add C implementation for `math/base/special/fast/min`
Rejoan-Sardar Mar 17, 2024
e17afda
docs: update related packages sections
stdlib-bot Mar 17, 2024
0bfd397
fix: update variable type declarations in `math/base/assert/int32-is-…
performant23 Mar 17, 2024
ea9122f
feat: add `utils/any-own-by`
Rec0iL99 Mar 17, 2024
6223b54
feat: update namespace TypeScript declarations
stdlib-bot Mar 17, 2024
3409be0
feat: add C implementation for `math/base/special/modf`
gunjjoshi Mar 17, 2024
c645b9b
feat: add C implementation for `math/base/special/fast/pow-int`
gunjjoshi Mar 17, 2024
1a5646b
feat: add `math/base/special/cosd`
the-r3aper7 Mar 17, 2024
089faed
feat: add C implementation for `math/base/special/fast/atanh`
Rejoan-Sardar Mar 17, 2024
2f69194
feat: add C implementation for `math/base/assert/is-composite`
performant23 Mar 17, 2024
8ce2773
build: update installed R version
Planeshifter Mar 18, 2024
9c7e880
build: skip labeler for auto PRs and only assign when all files match
Planeshifter Mar 18, 2024
a436bc7
build: update R lint configuration
Planeshifter Mar 18, 2024
79de323
docs: update list of contributors
stdlib-bot Mar 18, 2024
783d342
docs: update related packages sections
stdlib-bot Mar 18, 2024
21197b6
refactor: update `blas/ext/base/dcusum` to follow current project con…
AuenKr Mar 19, 2024
c41deb6
docs: update REPL namespace documentation
stdlib-bot Mar 19, 2024
2adc8ed
fix: missing headers in C examples
performant23 Mar 19, 2024
6903fd3
feat: add `constants/float32/half-pi`
gunjjoshi Mar 19, 2024
6e80a18
fix: update documentation to reflect correct seed range
kgryte Mar 20, 2024
acb496f
docs: update contributing guide to explicitly require running `make i…
kgryte Mar 20, 2024
5ddca98
docs: add note regarding spaces in directory path
kgryte Mar 20, 2024
86f1521
docs: add note concerning native add-ons
kgryte Mar 20, 2024
888480a
docs: add link
kgryte Mar 20, 2024
31d84a4
Merge branch 'develop' into gamma-lanczos-sum
gunjjoshi Mar 20, 2024
7a79a1c
Merge branch 'develop' into gamma-lanczos-sum
gunjjoshi Mar 20, 2024
817ee8e
feat: add C implementation for math/base/special/gamma-lanczos-sum
gunjjoshi Mar 20, 2024
70fdafb
Merge branch 'develop' into gamma-lanczos-sum
gunjjoshi Mar 20, 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 @@ -103,6 +103,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.h"
```

#### gamma_lanczos_sum( x )

Calculates the Lanczos sum for the approximation of the [gamma function][gamma-function].

```c
double out = gamma_lanczos_sum( 4.0 );
// returns ~950.366

out = gamma_lanczos_sum( -1.5 );
// returns ~1373366.245
```

The function accepts the following arguments:

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

```c
double gamma_lanczos_sum( 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.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( x[ i ] );
printf( "gamm_lanczos_sum(%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 gammaLanczosSum = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( gammaLanczosSum 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 = gammaLanczosSum( 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
Loading