Skip to content

🔢 Gamma function (Γ) from mathematics in Swift.

License

Notifications You must be signed in to change notification settings

ythecombinator/GammaFn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logo



🔢 gamma function (Γ) from mathematics in Swift 🔢

Swift 3.1 Platforms Package Managers Build Status codebeat badge MIT License



đź“š Table of Contents

📦 Installation

You just need to add this package as a dependency in your Package.swift:

let package = Package(
    name: "MyProject",
    dependencies: [
        .Package(url: "https://github.com/ythecombinator/GammaFn.git", majorVersion: 1),
        // ...
    ]
    // ...
)

🚀 Getting Started

gamma(for: Double) -> Double

It returns the gamma function over z.

Note: Complex ( ℂ ) numbers aren't supported–only Reals ( ℝ ).

import GammaFn

// Creating a simple `Double` value which we intend to pass to our Γ function–which is a static method from `Double`:

let simpleValue1: Double = 6.0
let resultValue1 = Double.gamma(for value: simpleValue1)
// => 120.0000000000002

// Another valid approach is accessing the property `gammaValue` from any `Double` value:

let simpleValue2: Double = 12.0
let resultValue2 = simpleValue2.gammaValue
// => 39916800.00000004

logForGamma(of: Double) -> Double

It returns the natural log of the gamma function for z.

Note: This function is used internally by the spouge approximation to compute large values.

import GammaFn

// Creating a simple `Double` value which we intend to pass to our Γ function–which is a static method from `Double`:

let simpleValue3: Double = 9.0
let resultValue3 = Double.gamma(for value: simpleValue3)
// => 10.64917311666183

// Accessing the property `logValueForGamma` from any `Double` value is valid as well:

let simpleValue4: Double = 112.0
let resultValue4 = simpleValue4.logValueForGamma
// => 415.0403783916892

⚖️ License

GammaFn is distributed under the MIT License, available in this repository.

All contributions are assumed to be also licensed under the same.

About

🔢 Gamma function (Γ) from mathematics in Swift.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages