Skip to content

Commit 9c24a71

Browse files
chore: updated main.c
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: passed - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: passed - task: lint_c_examples status: passed - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 989e656 commit 9c24a71

File tree

9 files changed

+349
-25
lines changed

9 files changed

+349
-25
lines changed

lib/node_modules/@stdlib/math/base/special/gammainc/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,97 @@ for ( i = 0; i < 100; i++ ) {
174174

175175
<!-- /.examples -->
176176

177+
<!-- C interface documentation. -->
178+
179+
* * *
180+
181+
<section class="c">
182+
183+
## C APIs
184+
185+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
186+
187+
<section class="intro">
188+
189+
</section>
190+
191+
<!-- /.intro -->
192+
193+
<!-- C usage documentation. -->
194+
195+
<section class="usage">
196+
197+
### Usage
198+
199+
```c
200+
#include "stdlib/math/base/special/gammainc.h"
201+
```
202+
203+
#### stdlib_base_gammainc( x, a, regularized, upper )
204+
205+
Computes the regularized lower [incomplete gamma function][incomplete-gamma-function] for inputs `x` and `s`. .
206+
207+
```c
208+
double out = stdlib_base_gammainc( 1.0, 2.0, 1, 1 );
209+
// returns ~0.7358
210+
```
211+
212+
The function accepts the following arguments:
213+
214+
- **x**: `[in] double` input value.
215+
- **a**: `[in] double` input value.
216+
- **regularized**: `[in] CBLAS_INT` indicating if the function should evaluate the regularized or non-regularized incomplete gamma functions.
217+
- **upper**: `[in] CBLAS_INT` indicating if the function should return the upper tail of the incomplete gamma function
218+
219+
```c
220+
double stdlib_base_gammainc( double x, double a, CBLAS_INT regularized, CBLAS_INT upper );
221+
```
222+
223+
</section>
224+
225+
<!-- /.usage -->
226+
227+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
228+
229+
<section class="notes">
230+
231+
</section>
232+
233+
<!-- /.notes -->
234+
235+
<!-- C API usage examples. -->
236+
237+
<section class="examples">
238+
239+
### Examples
240+
241+
```c
242+
#include "stdlib/math/base/special/gammainc.h"
243+
#include <stdio.h>
244+
245+
int main( void ) {
246+
const double x[] = { 6.0, 1.0, 7.0, 7.0, 0.0/0.0, 6.0 };
247+
const double a[] = { 2.0, 2.0, 5.0, 5.0, 2.0, 0.0/0.0 };
248+
const int regularized[] = { 1, 1, 1, 0, 1, 1 };
249+
const int upper[] = { 0, 1, 0, 0, 0, 0 };
250+
251+
double y;
252+
int i;
253+
for ( i = 0; i <6; i++ ) {
254+
y = stdlib_base_gammainc( x[ i ], a[ i ], regularized[ i ], upper[ i ] );
255+
printf( "gammainc( %lf, %lf, %lf, %lf ) = %lf\n", x[ i ], a[ i ], regularized[ i ], upper[ i ], y );
256+
}
257+
}
258+
```
259+
260+
</section>
261+
262+
<!-- /.examples -->
263+
264+
</section>
265+
266+
<!-- /.c -->
267+
177268
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
178269

179270
<section class="related">
Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2018 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var randu = require( '@stdlib/random/base/randu' );
26+
var isnan = require( '@stdlib/math/base/assert/is-nan' );
27+
var EPS = require( '@stdlib/constants/float64/eps' );
28+
var tryRequire = require( '@stdlib/utils/try-require' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var gammainc = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( gammainc instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var x;
44+
var y;
45+
var z;
46+
var i;
47+
48+
b.tic();
49+
for ( i = 0; i < b.iterations; i++ ) {
50+
x = ( randu()*1000.0 ) - 0.0;
51+
y = ( randu()*1000.0 ) + EPS;
52+
z = gammainc( x, y, 1, 0 );
53+
if ( isnan( z ) ) {
54+
b.fail( 'should not return NaN' );
55+
}
56+
}
57+
b.toc();
58+
if ( isnan( z ) ) {
59+
b.fail( 'should not return NaN' );
60+
}
61+
b.pass( 'benchmark finished' );
62+
b.end();
63+
});
64+
65+
bench( pkg+'::native:regularized=true', opts, function benchmark( b ) {
66+
var x;
67+
var y;
68+
var z;
69+
var i;
70+
71+
b.tic();
72+
for ( i = 0; i < b.iterations; i++ ) {
73+
x = ( randu()*1000.0 ) - 0.0;
74+
y = ( randu()*1000.0 ) + EPS;
75+
z = gammainc( x, y, 1, 0 );
76+
if ( isnan( z ) ) {
77+
b.fail( 'should not return NaN' );
78+
}
79+
}
80+
b.toc();
81+
if ( isnan( z ) ) {
82+
b.fail( 'should not return NaN' );
83+
}
84+
b.pass( 'benchmark finished' );
85+
b.end();
86+
});
87+
88+
bench( pkg+'::native:regularized=false', opts, function benchmark( b ) {
89+
var x;
90+
var y;
91+
var z;
92+
var i;
93+
94+
b.tic();
95+
for ( i = 0; i < b.iterations; i++ ) {
96+
x = ( randu()*1000.0 ) - 0.0;
97+
y = ( randu()*1000.0 ) + EPS;
98+
z = gammainc( x, y, 0, 0 );
99+
if ( isnan( z ) ) {
100+
b.fail( 'should not return NaN' );
101+
}
102+
}
103+
b.toc();
104+
if ( isnan( z ) ) {
105+
b.fail( 'should not return NaN' );
106+
}
107+
b.pass( 'benchmark finished' );
108+
b.end();
109+
});
110+
111+
bench( pkg+'::native:regularized=true,upper=true', opts, function benchmark( b ) {
112+
var x;
113+
var y;
114+
var z;
115+
var i;
116+
117+
b.tic();
118+
for ( i = 0; i < b.iterations; i++ ) {
119+
x = ( randu()*1000.0 ) - 0.0;
120+
y = ( randu()*1000.0 ) + EPS;
121+
z = gammainc( x, y, 1, 1 );
122+
if ( isnan( z ) ) {
123+
b.fail( 'should not return NaN' );
124+
}
125+
}
126+
b.toc();
127+
if ( isnan( z ) ) {
128+
b.fail( 'should not return NaN' );
129+
}
130+
b.pass( 'benchmark finished' );
131+
b.end();
132+
});
133+
134+
bench( pkg+'::native:regularized=true,upper=false', opts, function benchmark( b ) {
135+
var x;
136+
var y;
137+
var z;
138+
var i;
139+
140+
b.tic();
141+
for ( i = 0; i < b.iterations; i++ ) {
142+
x = ( randu()*1000.0 ) - 0.0;
143+
y = ( randu()*1000.0 ) + EPS;
144+
z = gammainc( x, y, 1, 0 );
145+
if ( isnan( z ) ) {
146+
b.fail( 'should not return NaN' );
147+
}
148+
}
149+
b.toc();
150+
if ( isnan( z ) ) {
151+
b.fail( 'should not return NaN' );
152+
}
153+
b.pass( 'benchmark finished' );
154+
b.end();
155+
});
156+
157+
bench( pkg+'::native:regularized=false,upper=true', opts, function benchmark( b ) {
158+
var x;
159+
var y;
160+
var z;
161+
var i;
162+
163+
b.tic();
164+
for ( i = 0; i < b.iterations; i++ ) {
165+
x = ( randu()*1000.0 ) - 0.0;
166+
y = ( randu()*1000.0 ) + EPS;
167+
z = gammainc( x, y, 0, 1 );
168+
if ( isnan( z ) ) {
169+
b.fail( 'should not return NaN' );
170+
}
171+
}
172+
b.toc();
173+
if ( isnan( z ) ) {
174+
b.fail( 'should not return NaN' );
175+
}
176+
b.pass( 'benchmark finished' );
177+
b.end();
178+
});
179+
180+
bench( pkg+'::native:regularized=false,upper=false', opts, function benchmark( b ) {
181+
var x;
182+
var y;
183+
var z;
184+
var i;
185+
186+
b.tic();
187+
for ( i = 0; i < b.iterations; i++ ) {
188+
x = ( randu()*1000.0 ) - 0.0;
189+
y = ( randu()*1000.0 ) + EPS;
190+
z = gammainc( x, y, 0, 0 );
191+
if ( isnan( z ) ) {
192+
b.fail( 'should not return NaN' );
193+
}
194+
}
195+
b.toc();
196+
if ( isnan( z ) ) {
197+
b.fail( 'should not return NaN' );
198+
}
199+
b.pass( 'benchmark finished' );
200+
b.end();
201+
});

lib/node_modules/@stdlib/math/base/special/gammainc/examples/c/example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
int main( void ) {
2323
const double x[] = { 6.0, 1.0, 7.0, 7.0, 0.0/0.0, 6.0 };
2424
const double a[] = { 2.0, 2.0, 5.0, 5.0, 2.0, 0.0/0.0 };
25-
const double regularized[] = { 1.0, 1.0, 1.0, 0.0, 1.0, 1.0 };
26-
const double upper[] = { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 };
25+
const double regularized[] = { 1, 1, 1, 0, 1, 1 };
26+
const double upper[] = { 0, 1, 0, 0, 0, 0 };
2727

2828
double y;
2929
int i;

lib/node_modules/@stdlib/math/base/special/gammainc/include/stdlib/math/base/special/gammainc.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef STDLIB_MATH_BASE_SPECIAL_GAMMAINC_H
2020
#define STDLIB_MATH_BASE_SPECIAL_GAMMAINC_H
2121

22+
#include "stdlib/blas/base/shared.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
* Computes the regularized incomplete gamma function. The upper tail is calculated via the modified Lentz's method for computing continued fractions, the lower tail using a power expansion.
3133
*/
32-
double stdlib_base_gammainc( double x, double a, double regularized, double upper );
34+
double stdlib_base_gammainc( double x, double a, CBLAS_INT regularized, CBLAS_INT upper );
3335

3436
#ifdef __cplusplus
3537
}

lib/node_modules/@stdlib/math/base/special/gammainc/lib/native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ var addon = require( './../src/addon.node' );
4040
*/
4141
function gammainc( x, a, regularized, upper ) {
4242
if (regularized) {
43-
regularized = 1.0;
43+
regularized = 1;
4444
} else {
45-
regularized = 0.0;
45+
regularized = 0;
4646
}
4747
if (upper) {
48-
upper = 1.0;
48+
upper = 1;
4949
} else {
50-
upper = 0.0;
50+
upper = 0;
5151
}
5252
return addon( x, a, regularized, upper );
5353
}

lib/node_modules/@stdlib/math/base/special/gammainc/manifest.json

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@
3636
"libraries": [],
3737
"libpath": [],
3838
"dependencies": [
39+
"@stdlib/napi/argv",
40+
"@stdlib/blas/base/shared",
41+
"@stdlib/napi/argv-double",
42+
"@stdlib/napi/argv-int32",
43+
"@stdlib/napi/create-double",
44+
"@stdlib/napi/export",
3945
"@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled",
4046
"@stdlib/math/base/special/gammaln",
4147
"@stdlib/math/base/special/gamma",
@@ -63,8 +69,7 @@
6369
"@stdlib/constants/float64/max-ln",
6470
"@stdlib/constants/float64/min-ln",
6571
"@stdlib/constants/float64/gamma-lanczos-g",
66-
"@stdlib/constants/float64/e",
67-
"@stdlib/math/base/napi/quaternary"
72+
"@stdlib/constants/float64/e"
6873
]
6974
},
7075
{
@@ -78,6 +83,7 @@
7883
"libraries": [],
7984
"libpath": [],
8085
"dependencies": [
86+
"@stdlib/blas/base/shared",
8187
"@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled",
8288
"@stdlib/math/base/special/gammaln",
8389
"@stdlib/math/base/special/gamma",
@@ -119,6 +125,7 @@
119125
"libraries": [],
120126
"libpath": [],
121127
"dependencies": [
128+
"@stdlib/blas/base/shared",
122129
"@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled",
123130
"@stdlib/math/base/special/gammaln",
124131
"@stdlib/math/base/special/gamma",

0 commit comments

Comments
 (0)