Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Statistics/Sample.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE BangPatterns #-}
-- |
-- Module : Statistics.Sample
-- Copyright : (c) 2008 Don Stewart, 2009 Bryan O'Sullivan
Expand Down Expand Up @@ -453,7 +454,14 @@ pair va vb
-- (^) operator from Prelude is just slow.
(^) :: Double -> Int -> Double
x ^ 1 = x
x ^ n = x * (x ^ (n-1))
x ^ 2 = x * x
x ^ 3 = x * x * x
x ^ 4 = (x * x) * (x * x)
x ^ 5 = (x * x) * x * (x * x)
-- x ^ n = x * (x ^ (n-1))
x0 ^ n0 = go (n0-1) x0 where
go 0 !acc = acc
go n acc = go (n-1) (acc*x0)
{-# INLINE (^) #-}

-- don't support polymorphism, as we can't get unboxed returns if we use it.
Expand Down
Loading