jacobi-elliptic 0.1.0.0 → 0.1.1.0
raw patch · 5 files changed
+86/−63 lines, 5 filesdep ~elliptic-integralsdep ~jacobi-thetaPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: elliptic-integrals, jacobi-theta
API changes (from Hackage documentation)
+ Math.JacobiElliptic: am :: Complex Double -> Complex Double -> Complex Double
- Math.JacobiElliptic: jellip :: Char -> Char -> Cplx -> Cplx -> Cplx
+ Math.JacobiElliptic: jellip :: Char -> Char -> Complex Double -> Complex Double -> Complex Double
- Math.JacobiElliptic: jellip' :: Char -> Char -> Cplx -> Cplx -> Cplx
+ Math.JacobiElliptic: jellip' :: Char -> Char -> Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_c :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_c :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_c' :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_c' :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_d :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_d :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_d' :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_d' :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_n :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_n :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_n' :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_n' :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_s :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_s :: Complex Double -> Complex Double -> Complex Double
- Math.NevilleTheta: theta_s' :: Cplx -> Cplx -> Cplx
+ Math.NevilleTheta: theta_s' :: Complex Double -> Complex Double -> Complex Double
Files
- CHANGELOG.md +6/−0
- jacobi-elliptic.cabal +3/−2
- src/Math/JacobiElliptic.hs +28/−17
- src/Math/NevilleTheta.hs +27/−28
- tests/Main.hs +22/−16
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog for `jacobi-elliptic` ++## 0.1.1.0 - 2023-02-27++Added the amplitude function.++ ## 0.1.0.0 - 2023-02-20 First release.
jacobi-elliptic.cabal view
@@ -1,5 +1,5 @@ name: jacobi-elliptic-version: 0.1.0.0+version: 0.1.1.0 synopsis: Neville Theta Functions and Jacobi Elliptic Functions description: Evaluation of the Neville theta functions and the Jacobi elliptic functions. homepage: https://github.com/stla/jacobi-elliptic#readme@@ -19,7 +19,7 @@ exposed-modules: Math.NevilleTheta , Math.JacobiElliptic build-depends: base >= 4.7 && < 5- , jacobi-theta >= 0.1.0.0+ , jacobi-theta >= 0.1.1.0 , elliptic-integrals >= 0.1.0.0 default-language: Haskell2010 ghc-options: -Wall@@ -41,6 +41,7 @@ , tasty , tasty-hunit , jacobi-elliptic+ , elliptic-integrals Default-Language: Haskell2010 source-repository head
src/Math/JacobiElliptic.hs view
@@ -1,27 +1,27 @@ module Math.JacobiElliptic ( jellip,- jellip'+ jellip',+ am ) where-import Data.Complex ( Complex )+import Data.Complex ( Complex, realPart, imagPart ) import Math.NevilleTheta- ( theta_c,- theta_d,- theta_n,- theta_s,- theta_c',- theta_d',- theta_n',- theta_s' )+ ( theta_c,+ theta_d,+ theta_n,+ theta_s,+ theta_c',+ theta_d',+ theta_n',+ theta_s' ) -type Cplx = Complex Double -- | Jacobi elliptic function in terms of the nome. jellip :: Char -- ^ a letter among 'c', 'd', 'n', 's' identifying the Neville function at the numerator -> Char -- ^ a letter among 'c', 'd', 'n', 's' identifying the Neville function at the denominator- -> Cplx -- ^ z, the variable- -> Cplx -- ^ q, the nome- -> Cplx+ -> Complex Double -- ^ z, the variable+ -> Complex Double -- ^ q, the nome+ -> Complex Double jellip p q z nome = theta_num z nome / theta_den z nome where@@ -42,9 +42,9 @@ jellip' :: Char -- ^ a letter among 'c', 'd', 'n', 's' identifying the Neville function at the numerator -> Char -- ^ a letter among 'c', 'd', 'n', 's' identifying the Neville function at the denominator- -> Cplx -- ^ z, the variable- -> Cplx -- ^ m, the squared modulus- -> Cplx+ -> Complex Double -- ^ z, the variable+ -> Complex Double -- ^ m, the squared modulus+ -> Complex Double jellip' p q z m = theta_num z m / theta_den z m where@@ -60,3 +60,14 @@ 'n' -> theta_n' 's' -> theta_s' _ -> error "Invalid denominator identifier."++-- | The amplitude function.+am ::+ Complex Double -- ^ u, a complex number + -> Complex Double -- ^ m, the squared elliptic modulus+ -> Complex Double+am u m = fromInteger ((-1)^k) * w + k' * pi+ where+ k = round (realPart u / pi) + round (imagPart u / pi)+ k' = fromInteger k+ w = asin (jellip' 's' 'n' u m)
src/Math/NevilleTheta.hs view
@@ -13,22 +13,21 @@ import Math.JacobiTheta ( jtheta1, jtheta1Dash, jtheta2, jtheta3, jtheta4 ) -type Cplx = Complex Double -i_ :: Cplx+i_ :: Complex Double i_ = 0.0 :+ 1.0 -tauFromM :: Cplx -> Cplx+tauFromM :: Complex Double -> Complex Double tauFromM m = i_ * ellipticF (pi/2) (1 - m) / ellipticF (pi/2) m -nomeFromM :: Cplx -> Cplx+nomeFromM :: Complex Double -> Complex Double nomeFromM m = exp (i_ * pi * tauFromM m) -- | Neville theta-c function in terms of the nome. theta_c :: - Cplx -- ^ z- -> Cplx -- ^ q, the nome- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ q, the nome+ -> Complex Double theta_c z q = jtheta2 z' q / jtheta2 0 q where@@ -37,9 +36,9 @@ -- | Neville theta-d function in terms of the nome. theta_d :: - Cplx -- ^ z- -> Cplx -- ^ q, the nome- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ q, the nome+ -> Complex Double theta_d z q = jtheta3 z' q / jtheta3 0 q where@@ -48,9 +47,9 @@ -- | Neville theta-n function in terms of the nome. theta_n :: - Cplx -- ^ z- -> Cplx -- ^ q, the nome- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ q, the nome+ -> Complex Double theta_n z q = jtheta4 z' q / jtheta4 0 q where@@ -59,9 +58,9 @@ -- | Neville theta-d function in terms of the nome. theta_s :: - Cplx -- ^ z- -> Cplx -- ^ q, the nome- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ q, the nome+ -> Complex Double theta_s z q = j3sq * jtheta1 z' q / jtheta1Dash 0 q where@@ -71,28 +70,28 @@ -- | Neville theta-c function in terms of the squared modulus. theta_c' :: - Cplx -- ^ z- -> Cplx -- ^ m, the squared modulus- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ m, the squared modulus+ -> Complex Double theta_c' z m = theta_c z (nomeFromM m) -- | Neville theta-d function in terms of the squared modulus. theta_d' :: - Cplx -- ^ z- -> Cplx -- ^ m, the squared modulus- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ m, the squared modulus+ -> Complex Double theta_d' z m = theta_d z (nomeFromM m) -- | Neville theta-n function in terms of the squared modulus. theta_n' :: - Cplx -- ^ z- -> Cplx -- ^ m, the squared modulus- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ m, the squared modulus+ -> Complex Double theta_n' z m = theta_n z (nomeFromM m) -- | Neville theta-s function in terms of the squared modulus. theta_s' :: - Cplx -- ^ z- -> Cplx -- ^ m, the squared modulus- -> Cplx+ Complex Double -- ^ z+ -> Complex Double -- ^ m, the squared modulus+ -> Complex Double theta_s' z m = theta_s z (nomeFromM m)
tests/Main.hs view
@@ -1,18 +1,18 @@ module Main where-import Approx ( assertApproxEqual )-import Data.Complex ( Complex(..) )-import Math.NevilleTheta- ( theta_c,- theta_d,- theta_n,- theta_s,- theta_c',- theta_d',- theta_n',- theta_s' )-import Math.JacobiElliptic ( jellip' )-import Test.Tasty ( defaultMain, testGroup )-import Test.Tasty.HUnit ( testCase )+import Approx ( assertApproxEqual )+import Data.Complex ( Complex(..) )+import Math.NevilleTheta ( theta_c,+ theta_d,+ theta_n,+ theta_s,+ theta_c',+ theta_d',+ theta_n',+ theta_s' )+import Math.EllipticIntegrals ( ellipticF )+import Math.JacobiElliptic ( jellip', am )+import Test.Tasty ( defaultMain, testGroup )+import Test.Tasty.HUnit ( testCase ) i_ :: Complex Double i_ = 0.0 :+ 1.0@@ -125,7 +125,7 @@ testCase "jellip relation 1" $ do let z1 = jellip' 'c' 'n' u m z2 = jellip' 'n' 'c' (i_ * u) (1 - m) - assertApproxEqual "" 14 z1 z2, + assertApproxEqual "" 13 z1 z2, testCase "jellip relation 2" $ do let z1 = jellip' 's' 'n' u m @@ -135,6 +135,12 @@ testCase "jellip relation 3" $ do let z1 = jellip' 'd' 'n' u m z2 = jellip' 'd' 'c' (i_ * u) (1 - m) - assertApproxEqual "" 14 z1 z2+ assertApproxEqual "" 13 z1 z2,++ testCase "amplitude function" $ do+ let phi = 1 :+ 1+ ell = ellipticF phi 2+ obtained = am ell 2+ assertApproxEqual "" 14 obtained phi ]