summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhololeap <hololeap@protonmail.com>2023-10-02 23:08:37 -0600
committerSam James <sam@gentoo.org>2023-10-23 04:09:51 +0100
commitfed642c298aa3c8417255ff303935ae9e57949cc (patch)
treee1c32158b93f0c4f6f274ebc0eaab0aeb9a436d3 /dev-haskell/math-functions
parentdev-haskell/lukko: Hackage revision bump (diff)
downloadgentoo-fed642c298aa3c8417255ff303935ae9e57949cc.tar.gz
gentoo-fed642c298aa3c8417255ff303935ae9e57949cc.tar.bz2
gentoo-fed642c298aa3c8417255ff303935ae9e57949cc.zip
dev-haskell/math-functions: add 0.3.4.2
Signed-off-by: hololeap <hololeap@protonmail.com> Signed-off-by: Sam James <sam@gentoo.org>
Diffstat (limited to 'dev-haskell/math-functions')
-rw-r--r--dev-haskell/math-functions/Manifest1
-rw-r--r--dev-haskell/math-functions/files/math-functions-0.3.4.2-fix-test-suite.patch118
-rw-r--r--dev-haskell/math-functions/math-functions-0.3.4.2.ebuild43
-rw-r--r--dev-haskell/math-functions/metadata.xml8
4 files changed, 164 insertions, 6 deletions
diff --git a/dev-haskell/math-functions/Manifest b/dev-haskell/math-functions/Manifest
index e9316477817f..17ed2533d34e 100644
--- a/dev-haskell/math-functions/Manifest
+++ b/dev-haskell/math-functions/Manifest
@@ -1 +1,2 @@
DIST math-functions-0.3.3.0.tar.gz 424169 BLAKE2B 8b53c657fb5eba8d3ab54d5ba29f7d316e8c2f4803d0587a1071fd9b6c0cf0d8a17c4dadc903280faf028622207ab84db5fb628c8826af0e615524ef45b625c5 SHA512 f6ac6f9fb604207c11d7888fa375a52b544732dd8e811c3b9bf74237bbc0dc83839eb83c11c5ef0dd88666cff4919d4e06236e14d84da7065b4dc75717ceafad
+DIST math-functions-0.3.4.2.tar.gz 429223 BLAKE2B 63d305c524c6ab40c415828375a8c2491911693fdf7a1462b9e4d9055a26e1570fb4e80eee8dd617852c96dfc802b6e6a8e2d7bc822d9bf62c00241e5cf43dd7 SHA512 cb29901294463edbba37e97445bb9ed039bdc43815c9bbd9b9bb92b87393e6e891f5840d337c6c06c7e30d26107d32a59c39ac51436be43dba00d0e2411a9053
diff --git a/dev-haskell/math-functions/files/math-functions-0.3.4.2-fix-test-suite.patch b/dev-haskell/math-functions/files/math-functions-0.3.4.2-fix-test-suite.patch
new file mode 100644
index 000000000000..5dd2d9c622f7
--- /dev/null
+++ b/dev-haskell/math-functions/files/math-functions-0.3.4.2-fix-test-suite.patch
@@ -0,0 +1,118 @@
+From 7e5deed1cb3fafdd6eb035b3713ae2f46b67014a Mon Sep 17 00:00:00 2001
+From: Alexey Khudyakov <alexey.skladnoy@gmail.com>
+Date: Thu, 8 Jun 2023 13:26:11 +0300
+Bug: https://github.com/haskell/math-functions/pull/75
+Signed-off-by: hololeap <hololeap@protonmail.com>
+Subject: [PATCH] Fix test suite
+
+QC as of 2.14.3. became much better at generating test cases and started
+reliably failing Kahan summation
+
+This was fixed by tweaking badvec to be just very bad. Not outrageously
+bad.
+---
+ tests/Tests/Sum.hs | 72 +++++++++++++++++++++++++++-------------------
+ 1 file changed, 43 insertions(+), 29 deletions(-)
+
+diff --git a/tests/Tests/Sum.hs b/tests/Tests/Sum.hs
+index 08eaf1e..1fcb2e9 100644
+--- a/tests/Tests/Sum.hs
++++ b/tests/Tests/Sum.hs
+@@ -4,54 +4,68 @@ module Tests.Sum (tests) where
+
+ import Control.Applicative ((<$>))
+ import Numeric.Sum as Sum
++import Numeric.MathFunctions.Comparison
+ import Prelude hiding (sum)
+ import Test.Tasty (TestTree, testGroup)
+-import Test.Tasty.QuickCheck (testProperty)
++import Test.Tasty.QuickCheck
+ import Test.QuickCheck (Arbitrary(..))
+ import qualified Prelude
+
+-t_sum :: ([Double] -> Double) -> [Double] -> Bool
+-t_sum f xs = f xs == trueSum xs
+-
+-t_sum_error :: ([Double] -> Double) -> [Double] -> Bool
+-t_sum_error f xs = abs (ts - f xs) <= abs (ts - Prelude.sum xs)
+- where ts = trueSum xs
+-
+-t_sum_shifted :: ([Double] -> Double) -> [Double] -> Bool
++-- Test that summation result is same as exact sum. That should pass
++-- if we're effectively working with quad precision
++t_sum :: ([Double] -> Double) -> [Double] -> Property
++t_sum f xs
++ = counterexample ("APPROX = " ++ show approx)
++ $ counterexample ("EXACT = " ++ show exact)
++ $ counterexample ("DELTA = " ++ show (approx - exact))
++ $ counterexample ("ULPS = " ++ show (ulpDistance approx exact))
++ $ approx == exact
++ where
++ approx = f xs
++ exact = trueSum xs
++
++-- Test that summation has smaller error than naive summation or no
++-- worse than given number of ulps. If we're close enough to exact
++-- answer naive may get ahead
++t_sum_error :: ([Double] -> Double) -> [Double] -> Property
++t_sum_error f xs
++ = counterexample ("APPROX = " ++ show approx)
++ $ counterexample ("NAIVE = " ++ show naive)
++ $ counterexample ("EXACT = " ++ show exact)
++ $ counterexample ("A-EXACT = " ++ show (approx - exact))
++ $ counterexample ("N-EXACT = " ++ show (naive - exact))
++ $ counterexample ("ULPS[A] = " ++ show (ulpDistance approx exact))
++ $ counterexample ("ULPS[N] = " ++ show (ulpDistance naive exact))
++ $ abs (exact - approx) <= abs (exact - naive)
++ where
++ naive = Prelude.sum xs
++ approx = f xs
++ exact = trueSum xs
++
++t_sum_shifted :: ([Double] -> Double) -> [Double] -> Property
+ t_sum_shifted f = t_sum_error f . zipWith (+) badvec
+
+ trueSum :: (Fractional b, Real a) => [a] -> b
+ trueSum xs = fromRational . Prelude.sum . map toRational $ xs
+
+ badvec :: [Double]
+-badvec = cycle [1,1e16,-1e16]
++badvec = cycle [1, 1e14, -1e14]
+
+ tests :: TestTree
+-tests = testGroup "Summation" [
+- testGroup "ID" [
+- -- plain summation loses precision quickly
+- -- testProperty "t_sum" $ t_sum (sum id)
+-
+- -- tautological tests:
+- -- testProperty "t_sum_error" $ t_sum_error (sum id)
+- -- testProperty "t_sum_shifted" $ t_sum_shifted (sum id)
+- ]
+- , testGroup "Kahan" [
+- -- tests that cannot pass:
+- -- testProprty "t_sum" $ t_sum (sum kahan)
+- -- testProperty "t_sum_error" $ t_sum_error (sum kahan)
+-
+- -- kahan summation only beats normal summation with large values
++tests = testGroup "Summation"
++ [ testGroup "Kahan" [
++ -- Kahan summation only beats naive summation when truly
++ -- catastrophic cancellation occurs
+ testProperty "t_sum_shifted" $ t_sum_shifted (sum kahan)
+ ]
+ , testGroup "KBN" [
+- testProperty "t_sum" $ t_sum (sum kbn)
+- , testProperty "t_sum_error" $ t_sum_error (sum kbn)
++ testProperty "t_sum" $ t_sum (sum kbn)
++ , testProperty "t_sum_error" $ t_sum_error (sum kbn)
+ , testProperty "t_sum_shifted" $ t_sum_shifted (sum kbn)
+ ]
+ , testGroup "KB2" [
+- testProperty "t_sum" $ t_sum (sum kb2)
+- , testProperty "t_sum_error" $ t_sum_error (sum kb2)
++ testProperty "t_sum" $ t_sum (sum kb2)
++ , testProperty "t_sum_error" $ t_sum_error (sum kb2)
+ , testProperty "t_sum_shifted" $ t_sum_shifted (sum kb2)
+ ]
+ ]
diff --git a/dev-haskell/math-functions/math-functions-0.3.4.2.ebuild b/dev-haskell/math-functions/math-functions-0.3.4.2.ebuild
new file mode 100644
index 000000000000..fc819016d1da
--- /dev/null
+++ b/dev-haskell/math-functions/math-functions-0.3.4.2.ebuild
@@ -0,0 +1,43 @@
+# Copyright 1999-2023 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# ebuild generated by hackport 0.6.7.9999
+#hackport: flags: +system-erf,+system-expm1
+
+CABAL_FEATURES="lib profile haddock hoogle hscolour test-suite"
+inherit haskell-cabal
+
+DESCRIPTION="Collection of tools for numeric computations"
+HOMEPAGE="https://github.com/bos/math-functions"
+SRC_URI="https://hackage.haskell.org/package/${P}/${P}.tar.gz"
+
+LICENSE="BSD-2"
+SLOT="0/${PV}"
+KEYWORDS="~amd64 ~arm64 ~ppc64 ~riscv ~x86"
+
+PATCHES=(
+ "${FILESDIR}/${PN}-0.3.4.2-fix-test-suite.patch"
+)
+
+RDEPEND=">=dev-haskell/data-default-class-0.1.2.0:=[profile?]
+ dev-haskell/primitive:=[profile?]
+ >=dev-haskell/vector-0.11:=[profile?]
+ >=dev-lang/ghc-8.4.3:=
+"
+DEPEND="${RDEPEND}
+ >=dev-haskell/cabal-2.2.0.1
+ test? ( dev-haskell/erf
+ >=dev-haskell/quickcheck-2.7
+ >=dev-haskell/tasty-1.2
+ >=dev-haskell/tasty-hunit-0.10
+ >=dev-haskell/tasty-quickcheck-0.10
+ dev-haskell/vector-th-unbox )
+"
+
+src_configure() {
+ haskell-cabal_src_configure \
+ --flag=system-erf \
+ --flag=system-expm1
+}
diff --git a/dev-haskell/math-functions/metadata.xml b/dev-haskell/math-functions/metadata.xml
index 34d3ae1258d4..6e48d98c7be5 100644
--- a/dev-haskell/math-functions/metadata.xml
+++ b/dev-haskell/math-functions/metadata.xml
@@ -5,12 +5,8 @@
<email>haskell@gentoo.org</email>
<name>Gentoo Haskell</name>
</maintainer>
- <longdescription>
- This library provides implementations of special mathematical
- functions and Chebyshev polynomials. These functions are often
- useful in statistical and numerical computing.
- </longdescription>
<upstream>
- <remote-id type="github">haskell/math-functions</remote-id>
+ <remote-id type="hackage">math-functions</remote-id>
+ <remote-id type="github">bos/math-functions</remote-id>
</upstream>
</pkgmetadata>