cl3 1.0.0.2 → 1.0.0.3
raw patch · 5 files changed
+95/−61 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ChangeLog.md +5/−0
- benchmarks/NbodyGameCl3.hs +25/−0
- cl3.cabal +2/−2
- src/Algebra/Geometric/Cl3.hs +62/−58
- stack.yaml +1/−1
ChangeLog.md view
@@ -1,5 +1,10 @@ # Revision history for cl3 +## 1.0.0.3 -- 2018-08-16++* Factored out the view pattern (reduce -> cliffor) on several functions so it wasn't repeated in every pattern match+* Added -fno-worker-wrapper to work around the compile time and space issues in ghc > 8.0+ ## 1.0.0.2 -- 2018-06-19 * Tested with GHC 7.8.4 and 8.4.2
benchmarks/NbodyGameCl3.hs view
@@ -167,6 +167,31 @@ -- 1.000 R² (1.000 R² .. 1.000 R²) -- mean 155.1 s (154.8 s .. 155.7 s) -- std dev 560.8 ms (88.83 ms .. 714.2 ms)+-- variance introduced by outliers: 19% (moderately inflatemarking nbodyBaseline/50000000+-- +-- 20180816: cl3-1.0.0.3+-- +-- Modified code to use ghc-8.4.2, ghc greater than 8.0 require -fno-worker-wrapper +-- to compile within reasonable time and space constraints.+-- +-- time 9.271 s (9.231 s .. 9.344 s)+-- 1.000 R² (1.000 R² .. 1.000 R²)+-- mean 9.495 s (9.407 s .. 9.636 s)+-- std dev 133.9 ms (53.72 ms .. 174.3 ms)+-- variance introduced by outliers: 19% (moderately inflated)+-- +-- benchmarking nbodyCl3/50000000+-- time 10.10 s (9.797 s .. 10.30 s)+-- 1.000 R² (NaN R² .. 1.000 R²)+-- mean 10.10 s (10.05 s .. 10.16 s)+-- std dev 58.98 ms (28.18 ms .. 72.96 ms)+-- variance introduced by outliers: 19% (moderately inflated)+-- +-- benchmarking nbodyAPS/50000000+-- time 178.6 s (NaN s .. 181.1 s)+-- 1.000 R² (1.000 R² .. 1.000 R²)+-- mean 177.2 s (175.5 s .. 178.2 s)+-- std dev 1.670 s (618.8 ms .. 2.283 s) -- variance introduced by outliers: 19% (moderately inflated) -- -------------------------------------------------------------------
cl3.cabal view
@@ -10,7 +10,7 @@ -- PVP summary: +-+------- breaking API changes -- | | +----- non-breaking API additions -- | | | +--- code changes with no API change-version: 1.0.0.2+version: 1.0.0.3 -- A short (one-line) description of the package. synopsis: Clifford Algebra of three dimensional space.@@ -69,7 +69,7 @@ Algebra.Geometric.Cl3.JonesCalculus -- Compiler options- ghc-options: -Wall -O2+ ghc-options: -Wall -O2 -fno-worker-wrapper -- LANGUAGE extensions used by modules in this package. other-extensions:
src/Algebra/Geometric/Cl3.hs view
@@ -1172,28 +1172,29 @@ -- -- spectraldcmp :: (Cl3 -> Cl3) -> (Cl3 -> Cl3) -> Cl3 -> Cl3-spectraldcmp fun _ (reduce -> r@R{}) = fun r-spectraldcmp fun _ (reduce -> v@V3{}) = spectraldcmpSpecial toR fun v -- spectprojR fun v-spectraldcmp fun _ (reduce -> bv@BV{}) = spectraldcmpSpecial toI fun bv -- spectprojI fun bv-spectraldcmp fun _ (reduce -> i@I{}) = fun i-spectraldcmp fun _ (reduce -> pv@PV{}) = spectraldcmpSpecial toR fun pv -- spectprojR fun pv-spectraldcmp fun _ (reduce -> h@H{}) = spectraldcmpSpecial toC fun h -- spectprojC fun h-spectraldcmp fun _ (reduce -> c@C{}) = fun c-spectraldcmp fun fun' (reduce -> bpv@BPV{})- | hasNilpotent bpv = jordan fun fun' bpv -- jordan normal form Cl3 style- | isColinear bpv = spectraldcmpSpecial toC fun bpv -- spectprojC fun bpv- | otherwise = -- transform it so it will be colinear- let (v,d,v_bar) = boost2colinear bpv- in v * spectraldcmpSpecial toC fun d * v_bar -- v * spectprojC fun d * v_bar-spectraldcmp fun _ (reduce -> od@ODD{}) = spectraldcmpSpecial toC fun od -- spectprojC fun od-spectraldcmp fun _ (reduce -> tpv@TPV{}) = spectraldcmpSpecial toI fun tpv -- spectprojI fun tpv-spectraldcmp fun fun' (reduce -> aps@APS{})- | hasNilpotent aps = jordan fun fun' aps -- jordan normal form Cl3 style- | isColinear aps = spectraldcmpSpecial toC fun aps -- spectprojC fun aps- | otherwise = -- transform it so it will be colinear- let (v,d,v_bar) = boost2colinear aps- in v * spectraldcmpSpecial toC fun d * v_bar -- v * spectprojC fun d * v_bar-spectraldcmp _ _ _ = error "Major problems with 'spectraldcmp' or 'reduce'"+spectraldcmp fun fun' (reduce -> cliffor) = dcmp cliffor+ where+ dcmp (r@R{}) = fun r+ dcmp (v@V3{}) = spectraldcmpSpecial toR fun v -- spectprojR fun v+ dcmp (bv@BV{}) = spectraldcmpSpecial toI fun bv -- spectprojI fun bv+ dcmp (i@I{}) = fun i+ dcmp (pv@PV{}) = spectraldcmpSpecial toR fun pv -- spectprojR fun pv+ dcmp (h@H{}) = spectraldcmpSpecial toC fun h -- spectprojC fun h+ dcmp (c@C{}) = fun c+ dcmp (bpv@BPV{})+ | hasNilpotent bpv = jordan fun fun' bpv -- jordan normal form Cl3 style+ | isColinear bpv = spectraldcmpSpecial toC fun bpv -- spectprojC fun bpv+ | otherwise = -- transform it so it will be colinear+ let (v,d,v_bar) = boost2colinear bpv+ in v * spectraldcmpSpecial toC fun d * v_bar -- v * spectprojC fun d * v_bar+ dcmp (od@ODD{}) = spectraldcmpSpecial toC fun od -- spectprojC fun od+ dcmp (tpv@TPV{}) = spectraldcmpSpecial toI fun tpv -- spectprojI fun tpv+ dcmp (aps@APS{})+ | hasNilpotent aps = jordan fun fun' aps -- jordan normal form Cl3 style+ | isColinear aps = spectraldcmpSpecial toC fun aps -- spectprojC fun aps+ | otherwise = -- transform it so it will be colinear+ let (v,d,v_bar) = boost2colinear aps+ in v * spectraldcmpSpecial toC fun d * v_bar -- v * spectprojC fun d * v_bar -- -- | 'jordan' does a Cl(3,0) version of the decomposition into Jordan Normal Form and Matrix Function Calculation@@ -1218,28 +1219,29 @@ -- This is useful for determining if a cliffor is the pole -- of a function. eigvals :: Cl3 -> (Cl3,Cl3)-eigvals (reduce -> r@R{}) = (r,r)-eigvals (reduce -> v@V3{}) = eigvalsSpecial toR v -- eigvalsR v-eigvals (reduce -> bv@BV{}) = eigvalsSpecial toI bv -- eigvalsI bv-eigvals (reduce -> i@I{}) = (i,i)-eigvals (reduce -> pv@PV{}) = eigvalsSpecial toR pv -- eigvalsR pv-eigvals (reduce -> h@H{}) = eigvalsSpecial toC h -- eigvalsC h-eigvals (reduce -> c@C{}) = (c,c)-eigvals (reduce -> bpv@BPV{})- | hasNilpotent bpv = (0,0) -- this case is actually nilpotent- | isColinear bpv = eigvalsSpecial toC bpv -- eigvalsC bpv- | otherwise = -- transform it so it will be colinear- let (_,d,_) = boost2colinear bpv- in eigvalsSpecial toC d -- eigvalsC d-eigvals (reduce -> od@ODD{}) = eigvalsSpecial toC od -- eigvalsC od-eigvals (reduce -> tpv@TPV{}) = eigvalsSpecial toI tpv -- eigvalsI tpv-eigvals (reduce -> aps@APS{})- | hasNilpotent aps = (toC aps,toC aps) -- a scalar plus nilpotent- | isColinear aps = eigvalsSpecial toC aps -- eigvalsC aps- | otherwise = -- transform it so it will be colinear- let (_,d,_) = boost2colinear aps- in eigvalsSpecial toC d -- eigvalsC d-eigvals _ = error "Major issues with 'eigvals' or 'reduce'"+eigvals (reduce -> cliffor) = eigv cliffor+ where+ eigv (r@R{}) = (r,r)+ eigv (v@V3{}) = eigvalsSpecial toR v -- eigvalsR v+ eigv (bv@BV{}) = eigvalsSpecial toI bv -- eigvalsI bv+ eigv (i@I{}) = (i,i)+ eigv (pv@PV{}) = eigvalsSpecial toR pv -- eigvalsR pv+ eigv (h@H{}) = eigvalsSpecial toC h -- eigvalsC h+ eigv (c@C{}) = (c,c)+ eigv (bpv@BPV{})+ | hasNilpotent bpv = (0,0) -- this case is actually nilpotent+ | isColinear bpv = eigvalsSpecial toC bpv -- eigvalsC bpv+ | otherwise = -- transform it so it will be colinear+ let (_,d,_) = boost2colinear bpv+ in eigvalsSpecial toC d -- eigvalsC d+ eigv (od@ODD{}) = eigvalsSpecial toC od -- eigvalsC od+ eigv (tpv@TPV{}) = eigvalsSpecial toI tpv -- eigvalsI tpv+ eigv (aps@APS{})+ | hasNilpotent aps = (toC aps,toC aps) -- a scalar plus nilpotent+ | isColinear aps = eigvalsSpecial toC aps -- eigvalsC aps+ | otherwise = -- transform it so it will be colinear+ let (_,d,_) = boost2colinear aps+ in eigvalsSpecial toC d -- eigvalsC d -- -- | 'eigvalsSpecial' helper function to calculate Eigenvalues@@ -1252,20 +1254,22 @@ -- | 'project' makes a projector based off of the vector content of the Cliffor. -- We have safty problem with unreduced values, so it calls reduce first, as a view pattern. project :: Cl3 -> Cl3-project (reduce -> R{}) = PV 0.5 0 0 0.5 -- default to e3 direction-project (reduce -> v@V3{}) = 0.5 * (1 + signum v)-project (reduce -> bv@BV{}) = 0.5 * (1 + signum (toV3 $ mI * toBV bv))-project (reduce -> I{}) = PV 0.5 0 0 0.5 -- default to e3 direction-project (reduce -> pv@PV{}) = 0.5 * (1 + signum (toV3 pv))-project (reduce -> h@H{}) = 0.5 * (1 + signum (toV3 $ mI * toBV h))-project (reduce -> C{}) = PV 0.5 0 0 0.5 -- default to e3 direction-project (reduce -> bpv@BPV{})- | abs (toV3 bpv + toV3 (mI * toBV bpv)) <= tol = 0.5 * (1 + signum (toV3 bpv)) -- gaurd for equal and opposite- | otherwise = 0.5 * (1 + signum (toV3 bpv + toV3 (mI * toBV bpv)))-project (reduce -> od@ODD{}) = 0.5 * (1 + signum (toV3 od))-project (reduce -> tpv@TPV{}) = 0.5 * (1 + signum (toV3 $ mI * toBV tpv))-project (reduce -> aps@APS{}) = project.toBPV $ aps-project (reduce -> _) = error "Error: Got some serious issues with 'project' and/or 'reduce'. Please Fix."+project (reduce -> cliffor) = proj cliffor+ where+ proj (R{}) = PV 0.5 0 0 0.5 -- default to e3 direction+ proj (v@V3{}) = 0.5 * (1 + signum v)+ proj (bv@BV{}) = 0.5 * (1 + signum (toV3 $ mI * toBV bv))+ proj (I{}) = PV 0.5 0 0 0.5 -- default to e3 direction+ proj (pv@PV{}) = 0.5 * (1 + signum (toV3 pv))+ proj (h@H{}) = 0.5 * (1 + signum (toV3 $ mI * toBV h))+ proj (C{}) = PV 0.5 0 0 0.5 -- default to e3 direction+ proj (bpv@BPV{})+ | abs (toV3 bpv + toV3 (mI * toBV bpv)) <= tol = 0.5 * (1 + signum (toV3 bpv)) -- gaurd for equal and opposite+ | otherwise = 0.5 * (1 + signum (toV3 bpv + toV3 (mI * toBV bpv)))+ proj (od@ODD{}) = 0.5 * (1 + signum (toV3 od))+ proj (tpv@TPV{}) = 0.5 * (1 + signum (toV3 $ mI * toBV tpv))+ proj (aps@APS{}) = project.toBPV $ aps+ -- | 'boost2colinear' calculates a boost that is perpendicular to both the vector and bivector -- components, that will mix the vector and bivector parts such that the vector and bivector
stack.yaml view
@@ -1,3 +1,3 @@ packages: - .-resolver: lts-9.21+resolver: lts-12.6