packages feed

simple-affine-space 0.1.1 → 0.2

raw patch · 3 files changed

+23/−3 lines, 3 files

Files

CHANGELOG view
@@ -1,3 +1,8 @@+2022-10-12 Ivan Perez <ivan.perez@keera.co.uk>+        * Version bump (0.2) (#19).+        * Move type constraints to default methods (#17).+        * Enable compilation with GHC 8.6-9.0 (#18).+ 2020-04-28 Ivan Perez <ivan.perez@keera.co.uk>         * Document combination with other vector libraries (#13), by @walseb.         * Remove unnecessary GHC extension (#10), by @turion.
simple-affine-space.cabal view
@@ -1,6 +1,6 @@ name: simple-affine-space-version: 0.1.1-cabal-version: >= 1.8+version: 0.2+cabal-version: >= 1.10 license: BSD3 license-file: LICENSE author: Henrik Nilsson, Antony Courtney@@ -45,10 +45,17 @@     Data.Vector3     Data.VectorSpace +  default-language:+    Haskell2010+ test-suite hlint   type: exitcode-stdio-1.0   main-is: hlint.hs   hs-source-dirs: tests++  default-language:+    Haskell2010+   if !flag(test-hlint)     buildable: False   else@@ -62,6 +69,9 @@   main-is: HaddockCoverage.hs   ghc-options: -Wall   hs-source-dirs: tests++  default-language:+    Haskell2010    if !flag(test-doc-coverage)     buildable: False
src/Data/VectorSpace.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE FunctionalDependencies, FlexibleInstances #-}+{-# LANGUAGE DefaultSignatures #-} ----------------------------------------------------------------------------------------- -- | -- Module      :  Data.VectorSpace@@ -56,7 +57,7 @@ --   The encoding uses a type class |VectorSpace| @v a@, where @v@ represents --   the type of the vectors and @a@ represents the types of the scalars. -class (Eq a, Floating a) => VectorSpace v a | v -> a where+class VectorSpace v a | v -> a where     -- | Vector with no magnitude (unit for addition).     zeroVector :: v @@ -65,6 +66,7 @@      -- | Division by a scalar.     (^/) :: v -> a -> v+    default (^/) :: Fractional a => v -> a -> v     v ^/ a = (1/a) *^ v      -- | Vector addition@@ -77,6 +79,7 @@     -- | Vector negation. Addition with a negated vector should be     --   same as subtraction.     negateVector :: v -> v+    default negateVector :: Num a => v -> v     negateVector v = (-1) *^ v      -- | Dot product (also known as scalar or inner product).@@ -95,11 +98,13 @@     -- For a vector represented mathematically as @a = a1,a2,...,an@, the norm     -- is the square root of @a1^2 + a2^2 + ... + an^2@.     norm :: v -> a+    default norm :: Floating a => v -> a     norm v = sqrt (v `dot` v)      -- | Return a vector with the same origin and orientation (angle), but such     -- that the norm is one (the unit for multiplication by a scalar).     normalize    :: v -> v+    default normalize :: (Eq a, Floating a) => v -> v     normalize v = if nv /= 0 then v ^/ nv else error "normalize: zero vector"         where nv = norm v