Skip to content

Commit ce4380d

Browse files
feat: add math/base/special/gammasgnf
--- 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: passed - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: passed - task: lint_python status: passed - task: lint_r status: na - task: lint_c_src status: missing_dependencies - task: lint_c_examples status: na - task: lint_c_benchmarks status: missing_dependencies - 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 ---
1 parent f9cfa42 commit ce4380d

File tree

9 files changed

+22
-24
lines changed

9 files changed

+22
-24
lines changed

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ The sign of the [gamma-function][@stdlib/math/base/special/gamma] is defined as
3939

4040
<!-- </equation> -->
4141

42-
The [gamma function][@stdlib/math/base/special/gamma] can be computed as the product of `gammasgnf(x)` and `exp(gammaln(x))`.
42+
The [gamma function][@stdlib/math/base/special/gamma] can be computed as the product of `gammasgn(x)` and `exp(gammaln(x))`.
4343

4444
</section>
4545

@@ -79,7 +79,7 @@ v = gammasgnf( NaN );
7979

8080
## Notes
8181

82-
- The [gamma function][@stdlib/math/base/special/gamma] is not defined for negative integer values (i.e., `gamma(x) === NaN` when `x` is a negative integer). The [natural logarithm of the gamma function][@stdlib/math/base/special/gammaln] is defined for negative integer values (i.e., `gammaln(x) === Infinity` when `x` is a negative integer). Accordingly, in order for the equality `gamma(x) === gammasgnf(x) * exp(gammaln(x))` to hold (i.e., return `NaN`), `gammasgnf` needs to either return `NaN` or `0`. By convention, this function returns `0`.
82+
- The [gamma function][@stdlib/math/base/special/gamma] is not defined for negative integer values (i.e., `gamma(x) === NaN` when `x` is a negative integer). The [natural logarithm of the gamma function][@stdlib/math/base/special/gammaln] is defined for negative integer values (i.e., `gammaln(x) === Infinity` when `x` is a negative integer). Accordingly, in order for the equality `gamma(x) === gammasgn(x) * exp(gammaln(x))` to hold (i.e., return `NaN`), `gammasgn` needs to either return `NaN` or `0`. By convention, this function returns `0`.
8383

8484
</section>
8585

@@ -95,7 +95,9 @@ v = gammasgnf( NaN );
9595
var linspace = require( '@stdlib/array/base/linspace' );
9696
var gammasgnf = require( '@stdlib/math/base/special/gammasgnf' );
9797

98-
var x = linspace( -10.0, 10.0, 100 );
98+
var x = linspace( -10.0, 10.0, 100, {
99+
'dtype': 'float32'
100+
});
99101

100102
var i;
101103
for ( i = 0; i < x.length; i++ ) {
@@ -139,10 +141,10 @@ Returns the sign of the [gamma-function][@stdlib/math/base/special/gamma].
139141

140142
```c
141143
float out = stdlib_base_gammasgnf( 1.0 );
142-
// returns 1.0
144+
// returns 1.0f
143145

144146
out = stdlib_base_gammasgnf( -2.5 );
145-
// returns -1.0
147+
// returns -1.0f
146148
```
147149

148150
The function accepts the following arguments:

lib/node_modules/@stdlib/math/base/special/gammasgnf/benchmark/benchmark.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,15 @@ var gammasgnf = require( './../lib' );
3030
// MAIN //
3131

3232
bench( pkg, function benchmark( b ) {
33-
var opts;
3433
var len;
3534
var x;
3635
var y;
3736
var i;
3837

39-
opts = {
40-
'dtype': 'float32'
41-
};
42-
4338
len = 100;
44-
x = uniform( len, 0, 171, opts );
39+
x = uniform( len, 0, 171, {
40+
'dtype': 'float32'
41+
});
4542

4643
b.tic();
4744
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/math/base/special/gammasgnf/benchmark/benchmark.native.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,15 @@ var opts = {
3939
// MAIN //
4040

4141
bench( pkg+'::native', opts, function benchmark( b ) {
42-
var opts;
4342
var len;
4443
var x;
4544
var y;
4645
var i;
4746

48-
opts = {
49-
'dtype': 'float32'
50-
};
51-
5247
len = 100;
53-
x = uniform( len, 0, 171, opts );
48+
x = uniform( len, 0, 171, {
49+
'dtype': 'float32'
50+
});
5451

5552
b.tic();
5653
for ( i = 0; i < b.iterations; i++ ) {

lib/node_modules/@stdlib/math/base/special/gammasgnf/benchmark/c/native/benchmark.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ static float rand_float( void ) {
9292
static double benchmark( void ) {
9393
double elapsed;
9494
float x[ 100 ];
95-
float y;
9695
double t;
96+
float y;
9797
int i;
9898

9999
for ( i = 0; i < 100; i++ ) {
100-
x[ i ] = ( 171.0 * rand_float() ) - 0.0f;
100+
x[ i ] = ( 171.0f * rand_float() ) - 0.0f;
101101
}
102102

103103
t = tic();

lib/node_modules/@stdlib/math/base/special/gammasgnf/examples/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
var linspace = require( '@stdlib/array/base/linspace' );
2222
var gammasgnf = require( './../lib' );
2323

24-
var x = linspace( -10.0, 10.0, 100 );
24+
var x = linspace( -10.0, 10.0, 100, {
25+
'dtype': 'float32'
26+
});
2527

2628
var i;
2729
for ( i = 0; i < x.length; i++ ) {

lib/node_modules/@stdlib/math/base/special/gammasgnf/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@stdlib/math/base/special/gammasgnf",
33
"version": "0.0.0",
4-
"description": "Sign of the gamma function for a single precision-floating point number.",
4+
"description": "Computes the sign of the gamma function for a single precision-floating point number.",
55
"license": "Apache-2.0",
66
"author": {
77
"name": "The Stdlib Authors",

lib/node_modules/@stdlib/math/base/special/gammasgnf/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*
2929
* @example
3030
* var v = gammasgnf( 1.0f );
31-
* // returns 1.0
31+
* // returns 1.0f
3232
*/
3333
float stdlib_base_gammasgnf( const float x ) {
3434
float fx;

lib/node_modules/@stdlib/math/base/special/gammasgnf/test/fixtures/python/random.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

lib/node_modules/@stdlib/math/base/special/gammasgnf/test/fixtures/python/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def gen(x, name):
4242
python> gen(x, './data.json')
4343
```
4444
"""
45-
y = gammasgn(x.astype(np.float32)) # Ensure `gammasgn` input is float32
45+
y = gammasgn(x).astype(np.float32) # Ensure `gammasgn` input is float32
4646
data = {
4747
"x": x.tolist(),
4848
"expected": y.tolist()

0 commit comments

Comments
 (0)