module Numeric.Integration.SphericalSimplexCubature
  (integrateOnSphericalSimplex, SphericalSimplex, orthants, Result (..))
  where
import Numeric.Integration.Simplex.Simplex
import Numeric.Integration.SimplexCubature
import Numeric.Integration.SphericalSimplexCubature.Internal

-- | Integral of a real-valued function over a spherical simplex.

integrateOnSphericalSimplex
    :: ([Double] -> Double)   -- integrand

    -> SphericalSimplex       -- domain

    -> Int                    -- maximum number of evaluations

    -> Double                 -- desired absolute error

    -> Double                 -- desired relative error

    -> Int                    -- integration rule: 1, 2, 3 or 4

    -> IO Result              -- integral, error, evaluations, success

integrateOnSphericalSimplex :: ([Double] -> Double)
-> SphericalSimplex -> Int -> Double -> Double -> Int -> IO Result
integrateOnSphericalSimplex [Double] -> Double
f SphericalSimplex
ssimplex = (VectorD -> Double)
-> Simplices -> Int -> Double -> Double -> Int -> IO Result
integrateOnSimplex' VectorD -> Double
f' [SphericalSimplex
simplex]
  where
    f' :: VectorD -> Double
f' = SphericalSimplex -> ([Double] -> Double) -> VectorD -> Double
transformedIntegrand SphericalSimplex
ssimplex [Double] -> Double
f
    simplex :: SphericalSimplex
simplex = Int -> SphericalSimplex
canonicalSimplex (SphericalSimplex -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length SphericalSimplex
ssimplex Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
1)