Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: add math/base/special/gamma-lanczos-sumf #6094

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

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
Loading
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
chore: update auto-generated functions
  • Loading branch information
Neerajpathak07 committed Mar 18, 2025
commit 7eab011095c6b575bfd1a7a0328882fa1b773018
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.

-->

# Gamma Lanczos Sum
# Gamma Lanczos Sumf

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

Expand Down Expand Up @@ -200,7 +200,7 @@ int main( void ) {

## See Also

- <span class="package-name">[`@stdlib/math/base/special/gamma-lanczos-sum`][@stdlib/math/base/special/gamma-lanczos-sum]</span><span class="delimiter">: </span><span class="description">gamma function.</span>
- <span class="package-name">[`@stdlib/math/base/special/gamma-lanczos-sum`][@stdlib/math/base/special/gamma-lanczos-sum]</span><span class="delimiter">: </span><span class="description">Calculate the Lanczos sum for the approximation of the gamma function.</span>
- <span class="package-name">[`@stdlib/math/base/special/gamma`][@stdlib/math/base/special/gamma]</span><span class="delimiter">: </span><span class="description">gamma function.</span>
- <span class="package-name">[`@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled`][@stdlib/math/base/special/gamma-lanczos-sum-expg-scaled]</span><span class="delimiter">: </span><span class="description">calculate a scaled Lanczos sum for the approximation of the gamma function.</span>

Expand All @@ -212,7 +212,7 @@ int main( void ) {

<section class="links">

[@stdlib/constants/float64/gamma-lanczos-g]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float64/gamma-lanczos-g
[@stdlib/constants/float32/gamma-lanczos-g]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/constants/float32/gamma-lanczos-g

[gamma-function]: https://en.wikipedia.org/wiki/Gamma_function

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ function evalrational( x ) {
ax = x;
}
if ( ax <= 1.0 ) {
s1 = 58.52061462402344 + (x * (182.52490234375 + (x * (211.09710693359375 + (x * (112.25265502929688 + (x * (27.519201278686523 + (x * 2.5066285133361816))))))))); // eslint-disable-line max-len
s1 = 58.52061844 + (x * (182.52490234 + (x * (211.09710693 + (x * (112.25265503 + (x * (27.51920128 + (x * 2.50662851))))))))); // eslint-disable-line max-len
s2 = 0.0 + (x * (24.0 + (x * (50.0 + (x * (35.0 + (x * (10.0 + (x * 1.0))))))))); // eslint-disable-line max-len
} else {
x = 1.0 / x;
s1 = 2.5066285133361816 + (x * (27.519201278686523 + (x * (112.25265502929688 + (x * (211.09710693359375 + (x * (182.52490234375 + (x * 58.52061462402344))))))))); // eslint-disable-line max-len
s1 = 2.50662851 + (x * (27.51920128 + (x * (112.25265503 + (x * (211.09710693 + (x * (182.52490234 + (x * 58.52061844))))))))); // eslint-disable-line max-len
s2 = 1.0 + (x * (10.0 + (x * (35.0 + (x * (50.0 + (x * (24.0 + (x * 0.0))))))))); // eslint-disable-line max-len
}
return s1 / s2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ var format = require( '@stdlib/string/format' );

// Polynomial coefficients ordered in ascending degree...
var P = [
58.52061462402344,
182.52490234375,
211.09710693359375,
112.25265502929688,
27.519201278686523,
2.5066285133361816
58.52061844,
182.52490234,
211.09710693,
112.25265503,
27.51920128,
2.50662851
];
var Q = [
0.0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ static float rational_pq( const float x ) {
float ix;
float s1;
float s2;
if ( x == 0.0 ) {
return 1.0 / 0.0;
if ( x == 0.0f ) {
return 1.0f / 0.0f;
}
if ( x < 0.0 ) {
if ( x < 0.0f ) {
ax = -x;
} else {
ax = x;
}
if ( ax <= 1.0 ) {
s1 = 58.52061462402344 + (x * (182.52490234375 + (x * (211.09710693359375 + (x * (112.25265502929688 + (x * (27.519201278686523 + (x * 2.5066285133361816)))))))));
s2 = 0.0 + (x * (24.0 + (x * (50.0 + (x * (35.0 + (x * (10.0 + (x * 1.0)))))))));
if ( ax <= 1.0f ) {
s1 = 58.52061844f + (x * (182.52490234f + (x * (211.09710693f + (x * (112.25265503f + (x * (27.51920128f + (x * 2.50662851f)))))))));
s2 = 0.0f + (x * (24.0f + (x * (50.0f + (x * (35.0f + (x * (10.0f + (x * 1.0f)))))))));
} else {
ix = 1.0 / x;
s1 = 2.5066285133361816 + (ix * (27.519201278686523 + (ix * (112.25265502929688 + (ix * (211.09710693359375 + (ix * (182.52490234375 + (ix * 58.52061462402344)))))))));
s2 = 1.0 + (ix * (10.0 + (ix * (35.0 + (ix * (50.0 + (ix * (24.0 + (ix * 0.0)))))))));
ix = 1.0f / x;
s1 = 2.50662851f + (ix * (27.51920128f + (ix * (112.25265503f + (ix * (211.09710693f + (ix * (182.52490234f + (ix * 58.52061844f)))))))));
s2 = 1.0f + (ix * (10.0f + (ix * (35.0f + (ix * (50.0f + (ix * (24.0f + (ix * 0.0f)))))))));
}
return s1 / s2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ tape( 'the function evaluates the Lanczos sum', function test( t ) {
for ( i = 0; i < x.length; i++ ) {
y = gammaLanczosSumf( x[i] );
expected = float64ToFloat32( gamma( x[i] ) );
expected /= float64ToFloat32( float64ToFloat32( pow( x[i]+G-0.5, x[i]-0.5 ) ) / float64ToFloat32( exp( x[i]+G-0.5 ) ) ); // eslint-disable-line max-len
expected /= float64ToFloat32( pow( x[i]+G-0.5, x[i]-0.5 ) ) / float64ToFloat32( ( exp( x[i]+G-0.5 ) ) ); // eslint-disable-line max-len
if ( y === expected ) {
t.equal( y, expected, 'x: '+x[i]+', y: '+y+', expected: '+expected );
} else {
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.