--- | Partition the interval [@a@, @b@] into @n@ subintervals, which we
--- then return as a list of pairs.
-partition :: (RealFrac a, Integral b)
- => b -- ^ The number of subintervals to use, @n@
- -> a -- ^ The \"left\" endpoint of the interval, @a@
- -> a -- ^ The \"right\" endpoint of the interval, @b@
- -> [(a,a)]
- -- Somebody asked for zero subintervals? Ok.
-partition 0 _ _ = []
-partition n a b
- | n < 0 = error "partition: asked for a negative number of subintervals"
- | otherwise =
- [ (xi, xj) | k <- [0..n-1],
- let k' = fromIntegral k,
- let xi = a + k'*h,
- let xj = a + (k'+1)*h ]
- where
- h = fromRational $ (toRational (b-a))/(toRational n)
-
+import NumericPrelude hiding (abs)
+import qualified Algebra.Field as Field
+import qualified Algebra.RealField as RealField
+import qualified Algebra.ToInteger as ToInteger
+import qualified Algebra.ToRational as ToRational