packages feed

exp-pairs 0.1.0.0 → 0.1.1.0

raw patch · 11 files changed

+294/−31 lines, 11 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Math.ExpPairs.Ivic: bestLambda :: Fractional t => Rational -> (Rational, t)
- Math.ExpPairs.Ivic: checkAbscissa :: [(Rational, Rational)] -> Rational -> Bool
- Math.ExpPairs.Ivic: difur :: Rational -> Rational
- Math.ExpPairs.Ivic: f :: Rational -> Rational -> Rational
- Math.ExpPairs.Ivic: heckeZetaByHalf :: Ratio Integer -> Ratio Integer
- Math.ExpPairs.Ivic: lemma82_f :: Rational -> Rational
- Math.ExpPairs.Ivic: mBigOnHalf :: Rational -> OptimizeResult
- Math.ExpPairs.Ivic: reverseMBigOnHalf :: Rational -> OptimizeResult
- Math.ExpPairs.Ivic: reverseMOnS :: RationalInf -> Ratio Integer
- Math.ExpPairs.Ivic: searchMinAbscissa :: [(Rational, Rational)] -> Rational
- Math.ExpPairs.Ivic: solveD :: Ratio Integer -> Ratio Integer -> Ratio Integer
- Math.ExpPairs.Ivic: zetaOnHalf :: Rational
+ Math.ExpPairs.LinearForm: Constraint :: (LinearForm t) -> IneqType -> Constraint t
+ Math.ExpPairs.LinearForm: LinearForm :: t -> t -> t -> LinearForm t
+ Math.ExpPairs.LinearForm: NonStrict :: IneqType
+ Math.ExpPairs.LinearForm: RationalForm :: (LinearForm t) -> (LinearForm t) -> RationalForm t
+ Math.ExpPairs.LinearForm: Strict :: IneqType
+ Math.ExpPairs.LinearForm: checkConstraint :: (Num t, Eq t) => (Integer, Integer, Integer) -> Constraint t -> Bool
+ Math.ExpPairs.LinearForm: data Constraint t
+ Math.ExpPairs.LinearForm: data IneqType
+ Math.ExpPairs.LinearForm: data LinearForm t
+ Math.ExpPairs.LinearForm: data RationalForm t
+ Math.ExpPairs.LinearForm: evalLF :: Num t => (t, t, t) -> LinearForm t -> t
+ Math.ExpPairs.LinearForm: evalRF :: (Real t, Num t) => (Integer, Integer, Integer) -> RationalForm t -> RationalInf
+ Math.ExpPairs.LinearForm: instance (Eq t, Num t, Show t) => Show (Constraint t)
+ Math.ExpPairs.LinearForm: instance (Eq t, Num t, Show t) => Show (RationalForm t)
+ Math.ExpPairs.LinearForm: instance (Num t, Eq t, Show t) => Show (LinearForm t)
+ Math.ExpPairs.LinearForm: instance Eq IneqType
+ Math.ExpPairs.LinearForm: instance Eq t => Eq (LinearForm t)
+ Math.ExpPairs.LinearForm: instance Num t => Fractional (RationalForm t)
+ Math.ExpPairs.LinearForm: instance Num t => Monoid (LinearForm t)
+ Math.ExpPairs.LinearForm: instance Num t => Num (LinearForm t)
+ Math.ExpPairs.LinearForm: instance Num t => Num (RationalForm t)
+ Math.ExpPairs.LinearForm: instance Show IneqType
+ Math.ExpPairs.LinearForm: substituteLF :: (Eq t, Num t) => (LinearForm t, LinearForm t, LinearForm t) -> LinearForm t -> LinearForm t
+ Math.ExpPairs.Matrix3: Matrix3 :: t -> t -> t -> t -> t -> t -> t -> t -> t -> Matrix3 t
+ Math.ExpPairs.Matrix3: Vector3 :: t -> t -> t -> Vector3 t
+ Math.ExpPairs.Matrix3: a1 :: Vector3 t -> t
+ Math.ExpPairs.Matrix3: a11 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a12 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a13 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a2 :: Vector3 t -> t
+ Math.ExpPairs.Matrix3: a21 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a22 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a23 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a3 :: Vector3 t -> t
+ Math.ExpPairs.Matrix3: a31 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a32 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: a33 :: Matrix3 t -> t
+ Math.ExpPairs.Matrix3: data Matrix3 t
+ Math.ExpPairs.Matrix3: data Vector3 t
+ Math.ExpPairs.Matrix3: det :: Num t => Matrix3 t -> t
+ Math.ExpPairs.Matrix3: fromList :: [t] -> Matrix3 t
+ Math.ExpPairs.Matrix3: instance Eq t => Eq (Matrix3 t)
+ Math.ExpPairs.Matrix3: instance Eq t => Eq (Vector3 t)
+ Math.ExpPairs.Matrix3: instance Fractional t => Fractional (Matrix3 t)
+ Math.ExpPairs.Matrix3: instance Functor Matrix3
+ Math.ExpPairs.Matrix3: instance Num t => Monoid (Matrix3 t)
+ Math.ExpPairs.Matrix3: instance Num t => Num (Matrix3 t)
+ Math.ExpPairs.Matrix3: instance Show t => Show (Matrix3 t)
+ Math.ExpPairs.Matrix3: instance Show t => Show (Vector3 t)
+ Math.ExpPairs.Matrix3: multCol :: Num t => Matrix3 t -> Vector3 t -> Vector3 t
+ Math.ExpPairs.Matrix3: normalize :: Integral t => Matrix3 t -> Matrix3 t
+ Math.ExpPairs.Matrix3: prettyMatrix :: Show t => Matrix3 t -> String
+ Math.ExpPairs.Matrix3: toList :: Matrix3 t -> [t]
+ Math.ExpPairs.Pair: Corput01 :: InitPair' t
+ Math.ExpPairs.Pair: Corput12 :: InitPair' t
+ Math.ExpPairs.Pair: Corput16 :: Triangle
+ Math.ExpPairs.Pair: Hux05 :: Triangle
+ Math.ExpPairs.Pair: HuxW87b1 :: Triangle
+ Math.ExpPairs.Pair: Mix :: t -> t -> InitPair' t
+ Math.ExpPairs.Pair: data InitPair' t
+ Math.ExpPairs.Pair: data Triangle
+ Math.ExpPairs.Pair: initPairToValue :: InitPair -> (Rational, Rational)
+ Math.ExpPairs.Pair: initPairs :: [InitPair]
+ Math.ExpPairs.Pair: instance (Show t, Num t, Eq t) => Show (InitPair' t)
+ Math.ExpPairs.Pair: instance Bounded Triangle
+ Math.ExpPairs.Pair: instance Enum Triangle
+ Math.ExpPairs.Pair: instance Eq Triangle
+ Math.ExpPairs.Pair: instance Eq t => Eq (InitPair' t)
+ Math.ExpPairs.Pair: instance Ord Triangle
+ Math.ExpPairs.Pair: instance Show Triangle
+ Math.ExpPairs.Pair: type InitPair = InitPair' Rational
+ Math.ExpPairs.Process: A :: Process
+ Math.ExpPairs.Process: BA :: Process
+ Math.ExpPairs.Process: aPath :: Path
+ Math.ExpPairs.Process: baPath :: Path
+ Math.ExpPairs.Process: data Path
+ Math.ExpPairs.Process: data Process
+ Math.ExpPairs.Process: evalPath :: Num t => Path -> (t, t, t) -> (t, t, t)
+ Math.ExpPairs.Process: instance Enum Process
+ Math.ExpPairs.Process: instance Eq Path
+ Math.ExpPairs.Process: instance Eq Process
+ Math.ExpPairs.Process: instance Memoizable Process
+ Math.ExpPairs.Process: instance Monoid Path
+ Math.ExpPairs.Process: instance Ord Path
+ Math.ExpPairs.Process: instance Ord Process
+ Math.ExpPairs.Process: instance Read Path
+ Math.ExpPairs.Process: instance Read Process
+ Math.ExpPairs.Process: instance Show Path
+ Math.ExpPairs.Process: instance Show Process
+ Math.ExpPairs.Process: lengthPath :: Path -> Int
+ Math.ExpPairs.RatioInf: Finite :: (Ratio t) -> RatioInf t
+ Math.ExpPairs.RatioInf: InfMinus :: RatioInf t
+ Math.ExpPairs.RatioInf: InfPlus :: RatioInf t
+ Math.ExpPairs.RatioInf: data RatioInf t
+ Math.ExpPairs.RatioInf: instance (Integral t, Show t) => Show (RatioInf t)
+ Math.ExpPairs.RatioInf: instance Eq t => Eq (RatioInf t)
+ Math.ExpPairs.RatioInf: instance Integral t => Fractional (RatioInf t)
+ Math.ExpPairs.RatioInf: instance Integral t => Num (RatioInf t)
+ Math.ExpPairs.RatioInf: instance Integral t => Ord (RatioInf t)
+ Math.ExpPairs.RatioInf: instance Integral t => Real (RatioInf t)
+ Math.ExpPairs.RatioInf: type RationalInf = RatioInf Integer

Files

Math/ExpPairs.hs view
@@ -1,5 +1,21 @@-module Math.ExpPairs (optimize, LinearForm (..), RationalForm (..), IneqType (..), Constraint (..), InitPair, Path, simulateOptimize,simulateOptimize', RatioInf (..), RationalInf, OptimizeResult, optimalValue, optimalPair, optimalPath) where+{-|+Module      : Math.ExpPairs+Description : Linear programming over exponent pairs+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Package implements an algorithm to minimize the maximum of a list of rational objective functions over the set of exponent pairs. See full description in+A. V. Lelechenko, Linear programming over exponent pairs. Acta Univ. Sapientiae, Inform. 5, No. 2, 271-287 (2013).+<http://www.acta.sapientia.ro/acta-info/C5-2/info52-7.pdf>++A set of useful applications can be found in+"Math.ExpPairs.Ivic", "Math.ExpPairs.Kratzel" and "Math.ExpPairs.MenzerNowak".+-}+module Math.ExpPairs (optimize, OptimizeResult, optimalValue, optimalPair, optimalPath, simulateOptimize, simulateOptimize', LinearForm (..), RationalForm (..), IneqType (..), Constraint (..), InitPair, Path, RatioInf (..), RationalInf) where+ import Data.Ratio import Data.Ord import Data.List@@ -37,9 +53,14 @@ checkMConstraints path = all (\con -> any (\p -> checkConstraint (evalPath path p) con ) triangleT) where 	triangleT = map fracs2proj [ (0%1,1%1), (0%1,1%2), (1%2,1%2)] +-- |Container for the result of optimization. data OptimizeResult = OptimizeResult {+	-- | The minimal value of objective function. 	optimalValue :: RationalInf,+	-- | The initial exponent pair, on which minimal value was achieved. 	optimalPair  :: InitPair,+	-- | The sequence of processes, after which minimal value was+	-- achieved. 	optimalPath  :: Path 	} @@ -54,12 +75,17 @@ instance Ord OptimizeResult where 	compare a b = compare (optimalValue a) (optimalValue b) +-- |Wrap 'Rational' into 'OptimizeResult'. simulateOptimize :: Rational -> OptimizeResult simulateOptimize r = OptimizeResult (Finite r) Corput01 mempty +-- |Wrap 'RationalInf' into 'OptimizeResult'. simulateOptimize' :: RationalInf -> OptimizeResult simulateOptimize' r = OptimizeResult r Corput01 mempty +-- |This function takes a list of rational forms and a list+-- of constraints and returns an exponent pair, which satisfies+-- all constraints and minimizes the maximum of all rational forms. optimize :: [RationalForm Rational] -> [Constraint Rational] -> OptimizeResult optimize rfs cons = optimize' rfs cons (OptimizeResult r0 ip0 mempty) where 	(r0, ip0) = evalFunctional [Corput01, Corput12] [Corput01, Corput12] rfs cons mempty
Math/ExpPairs/Ivic.hs view
@@ -1,11 +1,27 @@-module Math.ExpPairs.Ivic where+{-|+Module      : Math.ExpPairs.Ivic+Description : Riemann zeta-function+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Provides functions to compute estimates Riemann zeta-function+ζ in a critical strip, given in  /Ivić A./ `The Riemann zeta-function: Theory and applications',+Mineola, New York: Dover Publications, 2003.++-}+module Math.ExpPairs.Ivic (zetaOnS, reverseZetaOnS, mOnS) where+ import Data.Ratio import Data.List import Data.Ord  import Math.ExpPairs +-- | Compute µ(σ) such that |ζ(σ+it)| ≪ |t|^µ(σ) .+-- See equation (7.57) in Ivić2003. zetaOnS :: Rational -> OptimizeResult zetaOnS s 	| s >= 1  = simulateOptimize 0@@ -19,6 +35,7 @@ zetaOnHalf :: Rational zetaOnHalf = 32%205 +-- | An attempt to reverse 'zetaOnS'. reverseZetaOnS :: Rational -> OptimizeResult reverseZetaOnS mu 	| mu >= 1%2   = simulateOptimize 0@@ -44,6 +61,8 @@ -- and that alpha2 <= 1 for S >= 2/3 or S >= 5/8 and --          (4S-2)k + (8S-6)l + 2S-1 >=0 +-- | Compute m(σ) such that ∫_1^T |ζ(σ+it)|^m(σ) dt ≪ T^(1+ε)+-- See equation (8.97) in Ivić2003. mOnS :: Rational -> OptimizeResult mOnS s 	| s < 1%2 = simulateOptimize 0
Math/ExpPairs/Kratzel.hs view
@@ -1,14 +1,51 @@-module Math.ExpPairs.Kratzel where+{-|+Module      : Math.ExpPairs.Kratzel+Description : Asymmetric divisor problem+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Let τ_{a, b}(n) denote the number of integer+(v, w) with v^a w^b = n.++Let τ_{a, b, c}(n) denote the number of integer+(v, w, z) with v^a w^b z^c = n.++Krätzel+	(/Krätzel E./+	`Lattice points'.+	Dordrecht: Kluwer, 1988)+proved asymptotic formulas for+Σ_{n ≤ x} τ_{a, b}(n) with an error term of order x^(Θ(a, b) + ε)+and for+Σ_{n ≤ x} τ_{a, b, c}(n) with an error term of order x^(Θ(a, b, c) + ε).+He also provided a set of theorems to estimate Θ(a, b) and Θ(a, b, c).++-}+module Math.ExpPairs.Kratzel (TauabTheorem (..), tauab, TauabcTheorem (..), tauabc) where+ import Data.Ratio import Data.Ord import Data.List  import Math.ExpPairs -data TauabTheorem = Kr511a | Kr511b | Kr512a | Kr512b+-- |Special type to specify the theorem of Krätzel1988,+-- which provided the best estimate of Θ(a, b)+data TauabTheorem+	-- | Theorem 5.11, case a)+	= Kr511a+	-- | Theorem 5.11, case b)+	| Kr511b+	-- | Theorem 5.12, case a)+	| Kr512a+	-- | Theorem 5.12, case b)+	| Kr512b 	deriving (Show) +-- |Compute Θ(a, b) for given a and b. tauab :: Integer -> Integer -> (TauabTheorem, OptimizeResult) tauab a' b' = minimumBy (comparing (optimalValue . snd)) [kr511a, kr511b, kr512a, kr512b] where 	a = a'%1@@ -31,9 +68,32 @@ 			Constraint (LinearForm 29 29 (-24)) Strict 		]) -data TauabcTheorem = Kolesnik | Kr61 | Kr62 | Kr63 | Kr64 | Kr65 | Kr66 | Tauab TauabTheorem+-- |Special type to specify the theorem of Krätzel1988,+-- which provided the best estimate of Θ(a, b, c)+data TauabcTheorem+	-- | Kolesnik+	-- (/Kolesnik G./ `On the estimation of multiple exponential sums'+	-- \/\/ Recent progress in analytic number theory,+	-- London: Academic Press, 1981, Vol. 1, P. 231–246)+	-- proved that  Θ(1, 1, 1) = 43 \/96.+	= Kolesnik+	-- | Theorem 6.1+	| Kr61+	-- | Theorem 6.2+	| Kr62+	-- | Theorem 6.3+	| Kr63+	-- | Theorem 6.4+	| Kr64+	-- | Theorem 6.5+	| Kr65+	-- | Theorem 6.6+	| Kr66+	-- | In certain cases Θ(a, b, c) = Θ(a, b).+	| Tauab TauabTheorem 	deriving (Show) +-- |Compute Θ(a, b, c) for given a, b and c. tauabc :: Integer -> Integer -> Integer -> (TauabcTheorem, OptimizeResult) tauabc 1 1 1 = (Kolesnik, simulateOptimize $ 43%96) tauabc a' b' c' = minimumBy (comparing (optimalValue . snd)) [kr61, kr62, kr63, kr64, kr65, kr66] where
Math/ExpPairs/LinearForm.hs view
@@ -1,10 +1,24 @@-module Math.ExpPairs.LinearForm (LinearForm (..), RationalForm (..), IneqType (..), Constraint (..), checkConstraint, evalLF, evalRF, substituteLF) where+{-|+Module      : Math.ExpPairs.LinearForm+Description : Linear forms, rational forms and constraints+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Provides types for rational forms (to hold objective functions in "Math.ExpPairs") and linear contraints (to hold constraints of optimization). Both of them are built atop of projective linear forms.+-}+module Math.ExpPairs.LinearForm (LinearForm (..), evalLF, substituteLF, RationalForm (..), evalRF, IneqType (..), Constraint (..), checkConstraint) where+ import Data.List import Data.Ratio import Data.Monoid import Math.ExpPairs.RatioInf +-- |Define an affine linear form of two variables: a*k + b*l + c*m.+-- First argument of 'LinearForm' stands for a, second for b+-- and third for c. Linear forms form a monoid by addition. data LinearForm t = LinearForm t t t 	deriving (Eq) @@ -14,7 +28,7 @@ 		else "(" ++ intercalate " + " (filter (/=[]) $ 			[if a/= 0 then show a ++ "k" else []] ++ 			[if b/= 0 then show b ++ "l" else []] ++-			[if c/= 0 then show c        else []] ) ++ ")" -- where+			[if c/= 0 then show c ++ "m" else []] ) ++ ")" -- where 			-- show' :: Rational -> String 			-- show' z = if denominator z==1 then show (numerator z) else show z @@ -34,13 +48,16 @@ scaleLF 0 (LinearForm {}) = LinearForm 0 0 0 scaleLF s (LinearForm a b c) = LinearForm (a*s) (b*s) (c*s) +-- |Evaluate a linear form a*k + b*l + c*m for given k, l and m. evalLF :: Num t => (t, t, t) -> LinearForm t -> t evalLF (k, l, m) (LinearForm a b c) = a*k+l*b+m*c +-- |Substitute linear forms k, l and m into a given linear form+-- a*k + b*l + c*m to obtain a new linear form. substituteLF :: (Eq t, Num t) => (LinearForm t, LinearForm t, LinearForm t) -> LinearForm t -> LinearForm t substituteLF (k, l, m) (LinearForm a b c) = scaleLF a k + scaleLF b l + scaleLF c m -+-- | Define a rational form of two variables, equal to the ratio of two 'LinearForm'. data RationalForm t = RationalForm (LinearForm t) (LinearForm t) 	deriving (Show) @@ -56,6 +73,8 @@ 	fromRational r = RationalForm (fromInteger $ numerator r) (fromInteger $ denominator r) 	recip (RationalForm a b) = RationalForm b a +-- |Evaluate a rational form (a*k + b*l + c*m) \/ (a'*k + b'*l + c'*m)+-- for given k, l and m. evalRF :: (Real t, Num t) => (Integer, Integer, Integer) -> RationalForm t -> RationalInf evalRF (k', l', m') (RationalForm num den) = if denom==0 then InfPlus else Finite (numer / denom) where 	k = fromInteger k'@@ -67,13 +86,20 @@ substituteRF :: (Eq t, Num t) => (LinearForm t, LinearForm t, LinearForm t) -> RationalForm t -> RationalForm t substituteRF (k, l, m) (RationalForm num den) = RationalForm (substituteLF (k, l, m) num) (substituteLF (k, l, m) den) --data IneqType = Strict | NonStrict+-- |Constants to specify the strictness of 'Constraint'.+data IneqType+	-- | Strict inequality (>0).+	= Strict+	-- | Non-strict inequality (≥0).+	| NonStrict 	deriving (Eq, Show) +-- |A linear constraint of two variables. data Constraint t = Constraint (LinearForm t) IneqType 	deriving (Show) +-- |Evaluate a rational form of constraint and compare+-- its value with 0. Strictness depends on the given 'IneqType'. checkConstraint :: (Num t, Eq t) => (Integer, Integer, Integer) -> Constraint t -> Bool checkConstraint (k', l', m') (Constraint lf ineq) 	= if ineq==NonStrict
Math/ExpPairs/Matrix3.hs view
@@ -1,8 +1,21 @@-module Math.ExpPairs.Matrix3 (Matrix3 (..), Vector3 (..), fromList, toList, normalize, prettyMatrix, multCol, det) where+{-|+Module      : Math.ExpPairs.Matrix3+Description : Implements matrices of order 3+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Provides types and functions for matrices and vectors of order 3.+Can be used instead of "Data.Matrix" to reduce overhead and simplify code.+-}+module Math.ExpPairs.Matrix3 (Matrix3 (..), Vector3 (..), fromList, toList, det, multCol, normalize, prettyMatrix) where+ import qualified Data.List as List import Data.Monoid +-- |Three-component vector. data Vector3 t = Vector3 { 	a1 :: t, 	a2 :: t,@@ -10,6 +23,13 @@ 	} 	deriving (Eq, Show) +-- |Matrix of order 3. Instances of 'Num', 'Fractional' and 'Monoid'+-- are defined in terms of the multiplicative group of matrices,+-- not the additive one. E. g.,+--+-- > toList 1 == [1,0,0,0,1,0,0,0,1]+-- > toList 1 /= [1,1,1,1,1,1,1,1,1]+-- data Matrix3 t = Matrix3 { 	a11 :: t, 	a12 :: t,@@ -78,6 +98,7 @@ 		a33 = fromInteger n 		} +-- |Computes the determinant of a matrix. det :: (Num t) => Matrix3 t -> t det a = 	a11 a * (a22 a * a33 a - a32 a * a23 a)@@ -115,9 +136,11 @@ 	mempty = 1 	mappend = (*) +-- |Convert 'Matrix3' into a list of 9 elements. toList :: Matrix3 t -> [t] toList a = [a11 a, a12 a, a13 a, a21 a, a22 a, a23 a, a31 a, a32 a, a33 a] +-- |Convert a list of 9 elements into 'Matrix3'. fromList :: [t] -> Matrix3 t fromList as = Matrix3 { 		a11 = as!!0,@@ -134,15 +157,21 @@ instance Functor Matrix3 where 	fmap f = fromList . List.map f . toList +-- |Divide all elements of the matrix by their greatest common+-- divisor. This is useful for matrices of projective+-- transformations to reduce the magnitude of computations. normalize :: Integral t => Matrix3 t -> Matrix3 t normalize m = m' where 	l = toList m 	d = foldl1 gcd l 	m' = if d==0 then m else fromList $ List.map (`div`d) l +-- |Return the maximal element of a matrix. maximum :: Ord t => Matrix3 t -> t maximum = List.maximum . toList +-- |Print a matrix, separating rows with new lines and elements+-- with spaces. prettyMatrix :: (Show t) => Matrix3 t -> String prettyMatrix m = 	show (a11 m) ++ " " ++@@ -155,6 +184,7 @@ 	show (a32 m) ++ " " ++ 	show (a33 m) +-- |Multiplicate a matrix by a vector (considered as a column). multCol :: (Num t) => Matrix3 t -> Vector3 t -> Vector3 t multCol m v = Vector3 { 	a1 = a11 m * a1 v + a12 m * a2 v + a13 m * a3 v,
Math/ExpPairs/MenzerNowak.hs view
@@ -1,9 +1,29 @@-module Math.ExpPairs.MenzerNowak where+{-|+Module      : Math.ExpPairs.MenzerNowak+Description : Asymmetric divisor problem with congruence conditions+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Let τ_{a, b}(l_1, k_1; l_2, k_2; n) denote the number of integer+(v, w) with v^a w^b = n, v ≡ l_1 (mod k_1), w ≡ l_2 (mod k_2).++Menzer and Nowak+  (/Menzer H., Nowak W. G./ `On an asymmetric divisor problem with+  congruence conditions' \/\/ Manuscr. Math., 1989, Vol. 64, no. 1, P. 107-119)+proved an asymptotic formula for+Σ_{n ≤ x} τ_{a, b}(l_1, k_1; l_2, k_2; n) with an error term of order (x \/ k_1^a \/ k_2^b)^(Θ(a, b) + ε). They provided an expression for Θ(a, b) in terms of exponent pairs.++-}+module Math.ExpPairs.MenzerNowak (menzerNowak) where+ import Data.Ratio  import Math.ExpPairs +-- |Compute Θ(a, b) for given a and b. menzerNowak :: Integer -> Integer -> OptimizeResult menzerNowak a' b' = optimize 	[
Math/ExpPairs/Pair.hs view
@@ -1,12 +1,53 @@-module Math.ExpPairs.Pair (InitPair' (..), InitPair, initPairs, initPairToValue) where+{-|+Module      : Math.ExpPairs.RatioInf+Description : Initial exponent pairs+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : POSIX +Provides a set of initial exponent pairs, consisting+of two points (0, 1), (1\/2, 1\/2) and a triangle with vertices in (1\/6, 2\/3), (2\/13, 35\/52) and (32\/205, 269\/410). The triangle is represented as a list of nodes of a net, covering the triangle.++Below /A/ and /B/ stands for van der Corput's processes. See "Math.ExpPairs.Process" for explanations.+-}+module Math.ExpPairs.Pair (Triangle (..), InitPair' (..), InitPair, initPairs, initPairToValue) where+ import Data.Ratio -data Triangle = Corput16 | HuxW87b1 | Hux05+-- |Vertices of the triangle of initial exponent pairs.+data Triangle+	-- |Usual van der Corput exponent pair+	-- (1\/6, 2\/3) = /AB/(0, 1).+	= Corput16+	-- |An exponent pair (2\/13, 35\/52) from /Huxley M. N./+	-- `Exponential sums and the Riemann zeta function'+	-- \/\/ Proceedings of the International Number+	-- Theory Conference held at Universite Laval in 1987, Walter de Gruyter, 1989, P. 417-423.+	| HuxW87b1+	-- | An exponent pair (32\/205, 269\/410) from /Huxley M. N./+	-- `Exponential sums and the Riemann zeta function V' \/\/+  -- Proc. Lond. Math. Soc., 2005, Vol. 90, no. 1., P. 1--41.+	| Hux05 	deriving (Show, Bounded, Enum, Eq, Ord) -data InitPair' t = Corput01 | Corput12 | Mix t t+-- |Type to hold an initial exponent pair.+data InitPair' t+	-- |Usual van der Corput exponent pair+	-- (0, 1).+	= Corput01+	-- |Usual van der Corput exponent pair+	-- (1\/2, 1\/2) = /B/(0, 1).+	| Corput12+	-- |Point from the interior of 'Triangle'.+	-- Exactly+	-- 'Mix' a b = a * 'Corput16' + b * 'HuxW87b1' + (1-a-b) * 'Hux05'+	| Mix t t 	deriving (Eq)++-- |Exponent pair built from rational fractions of+-- 'Corput16', 'HuxW87b1' and 'Hux05' type InitPair = InitPair' Rational  instance (Show t, Num t, Eq t) => Show (InitPair' t) where@@ -25,9 +66,14 @@ sect :: Integer sect = 30 -initPairs :: [InitPair' (Ratio Integer)]+-- |The set of initial exponent pairs. It consists of+-- 'Corput01', 'Corput12' and 496 = sum [1..31] 'Mix'-points,+-- which forms a uniform net over 'Triangle'.+initPairs :: [InitPair] initPairs = Corput01 : Corput12 : [Mix (r1%sect) (r2%sect) | r1<-[0..sect], r2<-[0..sect-r1]] +-- |Convert initial exponent pair from its symbolic representation+-- as 'InitPair' to pair of rationals. initPairToValue :: InitPair -> (Rational, Rational) initPairToValue Corput01 = (0, 1) initPairToValue Corput12 = (1%2, 1%2)
Math/ExpPairs/Process.hs view
@@ -1,5 +1,16 @@+{-|+Module      : Math.ExpPairs.Process+Description : Processes of van der Corput+Copyright   : (c) Andrew Lelechenko, 2014-2015+License     : GPL-3+Maintainer  : andrew.lelechenko@gmail.com+Stability   : experimental+Portability : TemplateHaskell++Provides types for sequences of /A/- and /B/-processes of van der Corput. A good account on this topic can be found in /Graham S. W.,  Kolesnik G. A./ Van Der Corput's Method of Exponential Sums, Cambridge University Press, 1991, especially Ch. 5.+-} {-# LANGUAGE TemplateHaskell  #-}-module Math.ExpPairs.Process (Process, Path (), evalPath, lengthPath, aPath, baPath) where+module Math.ExpPairs.Process (Process (..), Path (), aPath, baPath, evalPath, lengthPath) where  import Data.Monoid import Data.List@@ -8,7 +19,12 @@  import qualified Math.ExpPairs.Matrix3 as Mx -data Process = A | BA+-- | Since B^2 = id, B 'Corput16' = 'Corput16', B 'Hux05' = 'Hux05' and B 'HuxW87b1' = ???, the sequence of /A/- and /B/-processes, applied to 'initPairs' can be rewritten as a sequence of 'A' and 'BA'.+data Process+	-- | /A/-process+	= A+	-- | /BA/-process+	| BA 	deriving (Eq, Show, Read, Ord, Enum)  deriveMemoizable ''Process@@ -19,10 +35,19 @@ process2matrix  A = Mx.Matrix3 1 0 0 1 1 1  2 0 2 process2matrix BA = Mx.Matrix3 0 1 0 2 0 1  2 0 2 +-- | Holds a list of 'Process' and a matrix of projective+-- transformation, which they define. It also provides a fancy 'Show'+-- instance. E. g.,+--+-- > show (mconcat $ replicate 10 aPath) == "A^10"+-- data Path = Path ProcessMatrix [Process] +-- | Path consisting of a single process 'A'. aPath :: Path aPath  = Path (process2matrix  A) [ A]++-- | Path consisting of a single process 'BA'. baPath :: Path baPath = Path (process2matrix BA) [BA] @@ -54,11 +79,15 @@ 		cmp [] _ = True 		cmp _ [] = False +-- |Apply a projective transformation, defined by 'Path',+-- to a given point in two-dimensional projective space. evalPath :: (Num t) => Path -> (t, t, t) -> (t, t, t) evalPath (Path m _) (a,b,c) = (a',b',c') where 	m' = fmap fromInteger m 	(Mx.Vector3 a' b' c') = Mx.multCol m' (Mx.Vector3 a b c) +-- | Count processes in the 'Path'. Note that 'BA' counts+-- for one process, not two. lengthPath :: Path -> Int lengthPath (Path _ xs) = length xs 
Math/ExpPairs/RatioInf.hs view
@@ -1,5 +1,5 @@ {-|-Module      : ExpPairs.RatioInf+Module      : Math.ExpPairs.RatioInf Description : Rational numbers with infinities Copyright   : (c) Andrew Lelechenko, 2014-2015 License     : GPL-3@@ -7,7 +7,7 @@ Stability   : experimental Portability : POSIX -Provides types and necessary instances for rational numbers, extended with infinite values. Just use @RationalInf@ instead of @Rational@.+Provides types and necessary instances for rational numbers, extended with infinite values. Just use 'RationalInf' instead of 'Rational' from "Data.Ratio". -} module Math.ExpPairs.RatioInf (RatioInf (..), RationalInf) where @@ -15,11 +15,17 @@  -- |Extends a rational type with positive and negative -- infinities.-data RatioInf t = InfMinus | Finite (Ratio t) | InfPlus+data RatioInf t+	-- |Negative infinity+	= InfMinus+	-- |Finite value+	| Finite (Ratio t)+	-- |Positive infinity+	| InfPlus 	deriving (Ord, Eq)  -- |Arbitrary-precision rational numbers with positive and negative--- infinities+-- infinities. type RationalInf = RatioInf Integer  instance (Integral t, Show t) => Show (RatioInf t) where
Math/ExpPairs/Tests.hs view
@@ -10,10 +10,11 @@  main :: IO () main = do-	RatioInf.testSuite-	Pair.testSuite-	Ivic.testSuite-	MenzerNowak.testSuite-	Matrix3.testSuite-	Kratzel.testSuite-	LinearForm.testSuite+	print "done"+	--RatioInf.testSuite+	--Pair.testSuite+	--Ivic.testSuite+	--MenzerNowak.testSuite+	--Matrix3.testSuite+	--Kratzel.testSuite+	--LinearForm.testSuite
exp-pairs.cabal view
@@ -1,5 +1,5 @@ name:                exp-pairs-version:             0.1.0.0+version:             0.1.1.0 synopsis:            Linear programming over exponent pairs description:         Package implements an algorithm to minimize rational objective function over the set of exponent pairs homepage:            https://github.com/Bodigrim/exp-pairs@@ -20,7 +20,7 @@                        Math.ExpPairs.Ivic,                        Math.ExpPairs.Kratzel,                        Math.ExpPairs.MenzerNowak-  other-modules:       Math.ExpPairs.LinearForm,+                       Math.ExpPairs.LinearForm,                        Math.ExpPairs.Matrix3,                        Math.ExpPairs.Pair,                        Math.ExpPairs.Process,