1- /**
2- * @license Apache-2.0
3- *
4- * Copyright (c) 2025 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-
191'use strict' ;
202
213// MODULES //
@@ -28,29 +10,13 @@ var isError = require( '@stdlib/assert/is-error' );
2810// MAIN //
2911
3012// Attempt to load the native addon:
31- var addon = tryRequire ( join ( __dirname , '..' , 'build' , 'Release' , 'math.base.special.gammaincinv.node' ) ) ; // eslint-disable-line stdlib/no-dynamic-require
32-
33- // If we failed to load the addon, raise an error:
34- if ( isError ( addon ) ) {
35- throw new Error ( 'failed to load native addon. Error: ' + addon . message ) ;
36- }
13+ var gammaincinv = tryRequire (
14+ join ( __dirname , '..' , 'build' , 'Release' , 'math.base.special.gammaincinv.node' )
15+ ) ; // eslint-disable-line stdlib/no-dynamic-require
3716
38- /**
39- * Inverts the lower incomplete gamma function.
40- *
41- * @param {Probability } p - probability value
42- * @param {number } a - scale parameter
43- * @param {boolean } [upper=false] - boolean indicating if the function should invert the upper tail
44- * @returns {number } function value
45- *
46- * @example
47- * var y = gammaincinv( 0.5, 1.0, false );
48- * // returns ~0.693
49- */
50- function gammaincinv ( p , a , upper ) {
51- // Directly call the loaded native addon function
52- // The native function likely expects (double, double, bool)
53- return addon ( p , a , upper === true ) ;
17+ // Fallback to the pure JavaScript implementation if loading the addon fails:
18+ if ( isError ( gammaincinv ) ) {
19+ gammaincinv = require ( './main.js' ) ;
5420}
5521
5622
0 commit comments