cyclotomic 0.4.4 → 0.4.4.1
raw patch · 3 files changed
+10/−195 lines, 3 filesdep ~arithmoidep ~basedep ~containersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: arithmoi, base, containers
API changes (from Hackage documentation)
Files
- LICENSE +3/−3
- cyclotomic.cabal +7/−4
- src/Tests.hs +0/−188
LICENSE view
@@ -631,8 +631,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - <one line to give the program's name and a brief idea of what it does.>- Copyright (C) <year> <name of author>+ Copyright (C) 2015 Scott N. Walck This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by@@ -652,7 +651,8 @@ If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - <program> Copyright (C) <year> <name of author>+ cyclotomic Copyright (C) 2015 Scott N. Walck+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
cyclotomic.cabal view
@@ -1,5 +1,5 @@ Name: cyclotomic-Version: 0.4.4+Version: 0.4.4.1 Synopsis: A subfield of the complex numbers for exact calculation. Description: The cyclotomic numbers are a subset of the complex numbers that are represented exactly, enabling exact@@ -22,7 +22,10 @@ Tested-with: GHC == 7.8.4, GHC == 7.10.2 Library Exposed-modules: Data.Complex.Cyclotomic- Build-depends: base >= 4.2 && < 4.9,- containers >= 0.3 && < 0.6,- arithmoi >= 0.4 && < 0.5+ Build-depends: base >= 4.2 && < 5,+ containers >= 0.3,+ arithmoi >= 0.4 Hs-source-dirs: src+Source-repository head+ type: git+ location: https://github.com/walck/cyclotomic
− src/Tests.hs
@@ -1,188 +0,0 @@-{-# OPTIONS_GHC -Wall #-}--module Main where--import Data.Complex.Cyclotomic-import Test.Framework- ( defaultMain- , testGroup- )-import Test.Framework.Providers.HUnit- ( testCase- )-import Test.Framework.Providers.QuickCheck2- ( testProperty- )-import qualified Test.Framework.Providers.SmallCheck as S-import qualified Test.Framework.Providers.API as T-import Test.QuickCheck- ( Gen- , elements- , Arbitrary(..)- , shrinkRealFrac- )-import Test.HUnit- ( (@?=)- , Assertion- )-import Data.List- ( nub- )-import Data.Ratio- ( (%)- )--main :: IO ()-main = defaultMain tests--tests :: [T.Test]-tests = [test1a- ,test2b- ,test3b- ,test4b- ,S.withDepth 10 (S.testProperty "SmallCheck prop_square_sqrtRat" prop_square_sqrtRat)- ,qc_square_sqrtRat- ,qc_Gauss- ,qc_dftInv_dft- ,qc_dft_dftInv- ,qc_sum_quadratic_roots- ]--rationals :: [Rational]-rationals = 0 % 1 : [sign * k % j | n <- [0..], m <- [0..n-1], sign <- [1,-1]- , let k = m + 1, let j = n - m, gcd k j == 1]--rationalList :: Integer -> [Rational]-rationalList m = nub [n % d | n <- [-m..m], d <- [1..m]]--test1a :: T.Test-test1a = testGroup "polarRat" [polarRatTest p q | p <- [0..10], q <- [1..10]]--polarRatAssertion :: Integer -> Integer -> Assertion-polarRatAssertion p q = polarRat 1 (p % q) @?= e q^p--polarRatTest :: Integer -> Integer -> T.Test-polarRatTest p q = testCase ("polarRat 1 (" ++ show p ++ " % " ++ show q ++ ")") (polarRatAssertion p q)--test2b :: T.Test-test2b = testGroup "sqrtRat r ^ 2 == r for the following values of r"- [testCase (show r) (sqrtRat r ^ (2::Int) @?= fromRational r)- | r <- take 100 rationals]--test3b :: T.Test-test3b = testGroup "sqrtRat (r*r) == abs r for the following values of r"- [testCase (show r) (sqrtRat (r*r) @?= fromRational (abs r))- | r <- take 100 rationals]--test4b :: T.Test-test4b = testGroup "z * (1 / z) == 1 for the following values of z"- [testCase (show z) (z * (1 / z) @?= 1)- | n <- [1..10], m <- [1..10], let z = e n + e m, z /= 0]--------------------- Properties ---------------------prop_square_sqrtRat :: Int -> Bool-prop_square_sqrtRat n = sqrtRat (fromIntegral n) ^ (2::Int) == fromIntegral n--prop_Gauss :: Integer -> Bool-prop_Gauss n = let nn = 2 * abs n + 1- in sum [e nn^(j*j `mod` nn) | j <- [1..(nn - 1) `div` 2]]- == if nn `mod` 4 == 1- then (-1 + sqrtInteger nn) / 2- else (-1 + i*sqrtInteger nn) / 2--prop_dftInv_dft :: [Rational] -> Bool-prop_dftInv_dft rs = dftInv (dft cs) == cs- where cs = map fromRational rs--prop_dft_dftInv :: [Rational] -> Bool-prop_dft_dftInv rs = dft (dftInv cs) == cs- where cs = map fromRational rs--prop_sum_quadratic_roots :: (Rational, Rational, Rational) -> Bool-prop_sum_quadratic_roots (a, b, c)- = case rootsQuadEq a b c of- Nothing -> a == 0- Just (r1,r2) -> r1 + r2 == fromRational (-b / a)--prop_sum_quadratic_roots_small :: (SmallRational, SmallRational, SmallRational) -> Bool-prop_sum_quadratic_roots_small (SmallRational a, SmallRational b, SmallRational c)- = case rootsQuadEq a b c of- Nothing -> a == 0- Just (r1,r2) -> r1 + r2 == fromRational (-b / a)--------------------------- QuickCheck Tests ---------------------------qc_square_sqrtRat :: T.Test-qc_square_sqrtRat- = T.plusTestOptions (T.TestOptions- {T.topt_seed = Nothing- ,T.topt_maximum_generated_tests = Just 15- ,T.topt_maximum_unsuitable_generated_tests = Nothing- ,T.topt_maximum_test_size = Just 15- ,T.topt_maximum_test_depth = Nothing- ,T.topt_timeout = Nothing- })- $ testProperty "QuickCheck prop_square_sqrtRat" prop_square_sqrtRat--qc_Gauss :: T.Test-qc_Gauss- = T.plusTestOptions (T.TestOptions- {T.topt_seed = Nothing- ,T.topt_maximum_generated_tests = Nothing- ,T.topt_maximum_unsuitable_generated_tests = Nothing- ,T.topt_maximum_test_size = Nothing- ,T.topt_maximum_test_depth = Nothing- ,T.topt_timeout = Nothing- })- $ testProperty "QuickCheck prop_Gauss" prop_Gauss--qc_dftInv_dft :: T.Test-qc_dftInv_dft- = T.plusTestOptions (T.TestOptions- {T.topt_seed = Nothing- ,T.topt_maximum_generated_tests = Just 15- ,T.topt_maximum_unsuitable_generated_tests = Nothing- ,T.topt_maximum_test_size = Just 30- ,T.topt_maximum_test_depth = Nothing- ,T.topt_timeout = Nothing- })- $ testProperty "QuickCheck prop_dftInv_dft" prop_dftInv_dft--qc_dft_dftInv :: T.Test-qc_dft_dftInv- = T.plusTestOptions (T.TestOptions- {T.topt_seed = Nothing- ,T.topt_maximum_generated_tests = Just 15- ,T.topt_maximum_unsuitable_generated_tests = Nothing- ,T.topt_maximum_test_size = Just 30- ,T.topt_maximum_test_depth = Nothing- ,T.topt_timeout = Nothing- })- $ testProperty "QuickCheck prop_dft_dftInv" prop_dft_dftInv--qc_sum_quadratic_roots :: T.Test-qc_sum_quadratic_roots- = testProperty "QuickCheck prop_sum_quadratic_roots" prop_sum_quadratic_roots_small--------------------------- QuickCheck Stuff ---------------------------data SmallRational = SmallRational Rational- deriving (Show,Ord,Eq)--smallRationalList :: [SmallRational]-smallRationalList = map SmallRational (rationalList 3)--smallRationalGen :: Gen SmallRational-smallRationalGen = elements smallRationalList--instance Arbitrary SmallRational where- arbitrary = smallRationalGen- shrink (SmallRational r) = map SmallRational (shrinkRealFrac r)-