cayley-dickson 0.1.3.0 → 0.1.4.0
raw patch · 3 files changed
+17/−8 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- cayley-dickson.cabal +2/−2
- src/Math/CayleyDickson.hs +12/−5
- test/test.hs +3/−1
cayley-dickson.cabal view
@@ -1,5 +1,5 @@ name: cayley-dickson-version: 0.1.3.0+version: 0.1.4.0 synopsis: Complex numbers, quaternions, octonions, sedenions, etc. description: Cayley-Dickson constructions (complex numbers, quaternions, octonions, sedenions, etc.) over general scalars without@@ -9,7 +9,7 @@ author: James M. Lawrence maintainer: James M. Lawrence <llmjjmll@gmail.com> copyright: Copyright (c) James M. Lawrence-category: Algebra, Data, Data Structures, Math+category: Algebra, Math build-type: Simple extra-source-files: README.md cabal-version: >=1.10
src/Math/CayleyDickson.hs view
@@ -260,11 +260,13 @@ polar :: (Tag n, Conjugable a, RealFloat a) => Nion n a -> (a, a, Nion n a) polar = polar' Proxy -applyUsing :: (Conjugable a, RealFloat a) =>- Nion n a -> (a -> a) -> (C.Complex a -> C.Complex a) ->- Nion n a -> Nion n a-applyUsing _ f _ (Scalar s) = Scalar $ f s-applyUsing sqrtMinus1 _ f z = x .+ u *. y+applyUsing' :: (Tag n, Conjugable a, RealFloat a) =>+ Proxy n ->+ Nion n a -> (a -> a) -> (C.Complex a -> C.Complex a) ->+ Nion n a -> Nion n a+applyUsing' n sqrtMinus1 fr f z+ | tagVal n == 0 = Scalar $ fr $ scalarPart z+ | otherwise = x .+ u *. y where (s, t, u) = polarUsing sqrtMinus1 z -- handle special cases for a little more accuracy x C.:+ y | t == 0 = f s'@@ -273,6 +275,11 @@ where s' = s C.:+ 0 t' = t C.:+ 0 u' = 0 C.:+ 1++applyUsing :: (Tag n, Conjugable a, RealFloat a) =>+ Nion n a -> (a -> a) -> (C.Complex a -> C.Complex a) ->+ Nion n a -> Nion n a+applyUsing = applyUsing' Proxy ---------------------------------------------------------- -- constants
test/test.hs view
@@ -244,9 +244,11 @@ nion [1 % 2, 1, 3 % 2, 2] forM_ [-2, -1, -0.5, 0, 0.5, 1, 2] $ \r -> do- let (s, t, u) = polar $ (fromScalar r :: Quaternion Double)+ let y = fromScalar r :: Quaternion Double+ (s, t, u) = polar y assert $ s >= 0 assertClose (fromScalar r) $ s .* exp (t .* u)+ assertClose (sqrt y) $ (sqrt s) .* exp ((t .* u) /. 2) checkInverses :: IO () checkInverses = do