time-to-botec

Benchmark sampling in different programming languages
Log | Files | Refs | README

gamma_lanczos_sum.js (1805B)


      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 * ## Notice
     20 *
     21 * The original C++ code and copyright notice are from the [Boost library]{@link http://www.boost.org/doc/libs/1_64_0/boost/math/special_functions/lanczos.hpp}. The implementation has been modified for JavaScript.
     22 *
     23 * ```text
     24 * Copyright John Maddock 2006.
     25 *
     26 * Use, modification and distribution are subject to the
     27 * Boost Software License, Version 1.0. (See accompanying file
     28 * LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
     29 * ```
     30 */
     31 
     32 'use strict';
     33 
     34 // MAIN //
     35 
     36 /**
     37 * Calculates the Lanczos sum approximation.
     38 *
     39 * @name gammaLanczosSum
     40 * @type {Function}
     41 * @param {number} x - input value
     42 * @returns {number} Lanczos sum approximation
     43 *
     44 * @example
     45 * var v = gammaLanczosSum( 4.0 );
     46 * // returns ~950.366
     47 *
     48 * @example
     49 * var v = gammaLanczosSum( -1.5 );
     50 * // returns ~1373366.245
     51 *
     52 * @example
     53 * var v = gammaLanczosSum( -0.5 );
     54 * // returns ~-699841.735
     55 *
     56 * @example
     57 * var v = gammaLanczosSum( 0.5 );
     58 * // returns ~96074.186
     59 *
     60 * @example
     61 * var v = gammaLanczosSum( 0.0 );
     62 * // returns Infinity
     63 *
     64 * @example
     65 * var v = gammaLanczosSum( NaN );
     66 * // returns NaN
     67 */
     68 var gammaLanczosSum = require( './rational_pq.js' );
     69 
     70 
     71 // EXPORTS //
     72 
     73 module.exports = gammaLanczosSum;