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

-- | Integral of a real-valued function over a spherical simplex.
integrateOnSphericalSimplex
    :: ([Double] -> Double)   -- ^ integrand
    -> SphericalSimplex       -- ^ integration 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 (forall (t :: * -> *) a. Foldable t => t a -> Int
length SphericalSimplex
ssimplex forall a. Num a => a -> a -> a
- Int
1)