summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkSafronov <>2012-01-22 08:04:51 (GMT)
committerhdiff <hdiff@luite.com>2012-01-22 08:04:51 (GMT)
commit850519ff429f22949702a58dfc96eb973a1a645a (patch)
treeb8691c34ccd4a31f970b5ac525f48736e9a11533
parent463ce8e06512065219ac67b188a254bf91ccc6da (diff)
version 1.0.01.0.0
-rw-r--r--Numeric/Functions/Theta.hs88
-rw-r--r--README.md28
-rw-r--r--theta-functions.cabal52
3 files changed, 85 insertions, 83 deletions
diff --git a/Numeric/Functions/Theta.hs b/Numeric/Functions/Theta.hs
index b07e25e..ea72b29 100644
--- a/Numeric/Functions/Theta.hs
+++ b/Numeric/Functions/Theta.hs
@@ -1,18 +1,24 @@
--- | Theta-functions implemented on top of trigonometric series.
+-- |
+-- Theta-functions implemented on top of trigonometric series.
+--
-- Theta-functions are special functions of several complex variables
-- Their importance is that we can construct an elliptic functions from
--- combination of theta-functions
--- http://en.wikipedia.org/wiki/Theta_function
--- Depend on parameter <tau>, which should be positive
--- Call every function as thetaN <n> (qpar <tau>) <u>
--- where <n> is a number of addends in series representing the function
--- <tau> is a tau parameter defining the theta-function
--- <u> is an argument, which is a complex number
+-- combination of theta-functions, see details at
+-- <http://en.wikipedia.org/wiki/Theta_function>.
+--
+-- Depend on parameter Tau, which should be positive.
+-- Call every function in the following form:
+--
+-- @theta1 N (qpar Tau) U@
+--
+-- where @N@ is a number of addends in series representing the function,
+-- @Tau@ is a tau parameter defining the theta-function and
+-- @U@ is an argument, which is a complex number.
--
-- WARNING: theta-functions are raising their values very quickly when arg is raising.
-- This depends on behaviour of cos and sin of complex functions,
-- which are very rapidly increasing their values.
--- Call theta-functions with n < 20, q < 1, |u| < pi
+-- Call theta-functions with n < 20, q < 1, |u| < pi.
module Numeric.Functions.Theta (
qpar,
@@ -22,45 +28,11 @@ module Numeric.Functions.Theta (
theta4
) where
--- We do not use parallelism yet
--- import Control.Parallel
--- import Control.Parallel.Strategies
-
-- We work with complex numbers only
import Data.Complex
-- And we have exceptional situations
import Control.Exception
--- | Theta-function depends on parameter q, which abs should be lower than 1
--- Parameter q, however, depends on the main parameter tau,
--- so we will make q dependent variable
-qpar :: RealFloat a => a -> Complex a
-qpar tau
- | tau > 0 = exp $ (pi :+ 0) * (0 :+ tau) * (0 :+ 1)
- | otherwise = throw $ ErrorCall "tau should be > 0 !"
-
--- | This is an analogue to $ (-1)^n $
-signfun :: (RealFloat a) => Integer -> Complex a
-signfun nn
- | odd nn = ((-1) :+ 0)
- | otherwise = (1 :+ 0)
-
--- | Function $ q^n^2 $
-qfun1 :: (RealFloat a) => Complex a -> Integer -> Complex a
-qfun1 q n = q ** (fromInteger n) ** 2
-
--- | Function $ q^{n + 1/2}^2 $
-qfun2 :: (RealFloat a) => Complex a -> Integer -> Complex a
-qfun2 q n = q ** (0.5 + fromInteger n) ** 2
-
--- | Cosine function tailored for our types
-cosfun :: (RealFloat a) => Complex a -> Integer -> Complex a
-cosfun u n = cos $ u * fromInteger n
-
--- | Sine function tailored for our types
-sinfun :: (RealFloat a) => Complex a -> Integer -> Complex a
-sinfun u n = sin $ u * fromInteger n
-
-- | \Theta_1
theta1 :: (RealFloat a) => Integer -> Complex a -> Complex a -> Complex a
theta1 n q u = (* 2) . sum $ map (theta1_arg q u) [0..n]
@@ -89,3 +61,33 @@ theta4 n q u = (+ 1) . (* 2) . sum $ map (theta4_arg q u) [1..n]
theta4_arg :: (RealFloat a) => Complex a -> Complex a -> Integer -> Complex a
theta4_arg q u nn = (signfun nn) * (qfun1 q nn) * (cosfun u (2 * nn))
+-- | Theta-function depends on parameter q, which abs should be lower than 1
+-- Parameter q, however, depends on the main parameter tau,
+-- so we will make q dependent variable
+qpar :: RealFloat a => a -> Complex a
+qpar tau
+ | tau > 0 = exp $ (pi :+ 0) * (0 :+ tau) * (0 :+ 1)
+ | otherwise = throw $ ErrorCall "tau should be > 0 !"
+
+-- | Complex signum function.
+-- Equivalent to raising (-1) to the power of n
+signfun :: (RealFloat a) => Integer -> Complex a
+signfun nn
+ | odd nn = ((-1) :+ 0)
+ | otherwise = (1 :+ 0)
+
+-- | Sine function tailored for our types
+sinfun :: (RealFloat a) => Complex a -> Integer -> Complex a
+sinfun u n = sin $ u * fromInteger n
+
+-- | Helper included in mathematical definition of 'theta1' and 'theta2'.
+qfun2 :: (RealFloat a) => Complex a -> Integer -> Complex a
+qfun2 q n = q ** (0.5 + fromInteger n) ** 2
+
+-- | Cosine function tailored for our types
+cosfun :: (RealFloat a) => Complex a -> Integer -> Complex a
+cosfun u n = cos $ u * fromInteger n
+
+-- | Helper included in mathematical definition of 'theta3' and 'theta4'.
+qfun1 :: (RealFloat a) => Complex a -> Integer -> Complex a
+qfun1 q n = q ** (fromInteger n) ** 2
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..2eb9ddf
--- /dev/null
+++ b/README.md
@@ -0,0 +1,28 @@
+theta-functions
+===============
+
+Implementation of theta-functions using trigonometric series.
+
+They're the special functions of two variables. Described very well at [Wikipedia article](http://en.wikipedia.org/wiki/Theta_function).
+
+Library exports four theta-functions and a small helper to calculate their second parameter.
+
+Theta functions are functions of Complex variables, FYI.
+
+Interface summary
+=================
+
+ thetaN n q u
+
+where N is a number from 1 to 4, `n` is a quantization factor, `q` is a theta-functions special parameter, and `u` is an actual argument of function.
+
+Parameter `q` should be calculated with the helper function `qpar`, which accepts real numbers as argument:
+
+ qpar tau
+
+qpar itself returns Complex value. This helper is used to draw the library closer to the definition of theta-functions provided in the books.
+
+Constraints
+===========
+
+Never call theta1..4 with `u` > pi. Theta-functions are raising very rapidly (maybe it's because of trigonometric series representing them), so with large values of argument they overflow badly and return incorrect results. \ No newline at end of file
diff --git a/theta-functions.cabal b/theta-functions.cabal
index d583835..fadcd4b 100644
--- a/theta-functions.cabal
+++ b/theta-functions.cabal
@@ -1,62 +1,34 @@
--- theta-functions.cabal auto-generated by cabal init. For additional
--- options, see
--- http://www.haskell.org/cabal/release/cabal-latest/doc/users-guide/authors.html#pkg-descr.
--- The name of the package.
Name: theta-functions
-
--- The package version. See the Haskell package versioning policy
--- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for
--- standards guiding when and how versions should be incremented.
-Version: 0.1
-
--- A short (one-line) description of the package.
+Version: 1.0.0
+Cabal-version: >= 1.6
Synopsis: Theta-functions implemented as trigonometric series
--- A longer description of the package.
Description:
Small and simple library for computing values of Theta functions.
- They're the special functions of two variables. Described very well at "http://en.wikipedia.org/wiki/Theta_function".
+ They're the special functions of two variables. Described very well at Wikipedia article with corresponding name.
Library exports four theta-functions and a small helper to calculate their second parameter.
Theta functions are functions of Complex variables, FYI.
--- The license under which the package is released.
License: PublicDomain
-
--- The file containing the license text.
License-file: LICENSE
--- The package author(s).
Author: Mark Safronov a.k.a. hijarian
-
--- An email address to which users can send suggestions, bug reports,
--- and patches.
Maintainer: hijarian@gmail.com
--- A copyright notice.
--- Copyright:
-
Category: Math
Build-type: Simple
--- Extra files to be distributed with the package, such as examples or
--- a README.
--- Extra-source-files:
-
--- Constraint on the version of Cabal needed to build this package.
-Cabal-version: >=1.2
+Homepage: https://github.com/hijarian/theta-functions
+Extra-source-files: README.md
Library
- -- Modules exported by the library.
Exposed-modules: Numeric.Functions.Theta
-
- -- Packages needed in order to build this package.
- Build-Depends: base >= 4.3 && < 5
-
- -- Modules not exported by this package.
- -- Other-modules:
-
- -- Extra tools (e.g. alex, hsc2hs, ...) needed to build the source.
- -- Build-tools:
-
+ Build-Depends: base >= 4.3.1.0 && < 5
+
+Source-repository head
+ type: git
+ location: git@github.com:hijarian/theta-functions.git
+
+