001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.numbers.gamma;
018
019/**
020 * <a href="https://mathworld.wolfram.com/GammaFunction.html">Gamma
021 * function</a> \( \Gamma(x) \).
022 *
023 * <p>The <a href="https://mathworld.wolfram.com/GammaFunction.html">gamma
024 * function</a> can be seen to extend the factorial function to cover real and
025 * complex numbers, but with its argument shifted by {@code -1}. This
026 * implementation supports real numbers.
027 *
028 * <p>This code has been adapted from:
029 * <ul>
030 *  <li>The <a href="https://www.boost.org/">Boost</a>
031 *      {@code c++} implementation {@code <boost/math/special_functions/gamma.hpp>}.
032 *  <li>The <em>NSWC Library of Mathematics Subroutines</em> double
033 *      precision implementation, {@code DGAMMA}.
034 * </ul>
035 *
036 * @see
037 * <a href="https://www.boost.org/doc/libs/1_77_0/libs/math/doc/html/math_toolkit/sf_gamma/tgamma.html">
038 * Boost C++ Gamma functions</a>
039 */
040public final class Gamma {
041    /** Private constructor. */
042    private Gamma() {
043        // intentionally empty.
044    }
045
046    /**
047     * Computes the value of \( \Gamma(x) \).
048     *
049     * @param x Argument.
050     * @return \( \Gamma(x) \)
051     */
052    public static double value(final double x) {
053        return BoostGamma.tgamma(x);
054    }
055}