summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrevorMcDonell <>2017-09-29 06:27:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2017-09-29 06:27:00 (GMT)
commit579cbc7286bece4774d1b4236c3533babe803cb5 (patch)
tree7978b40bb8020d9fd868f5e9a111a4596e2909c8
parent80dc8d343bab32ad8a0fe82613e6c6b0724b9aa8 (diff)
version 0.5.0.1HEAD0.5.0.1master
-rw-r--r--.travis.yml4
-rw-r--r--CHANGELOG.markdown7
-rw-r--r--linear-accelerate.cabal4
-rw-r--r--src/Data/Array/Accelerate/Linear/Matrix.hs48
-rw-r--r--src/Data/Array/Accelerate/Linear/V1.hs13
-rw-r--r--src/Data/Array/Accelerate/Linear/V2.hs21
-rw-r--r--src/Data/Array/Accelerate/Linear/V3.hs12
-rw-r--r--src/Data/Array/Accelerate/Linear/V4.hs12
-rw-r--r--src/Data/Array/Accelerate/Linear/Vector.hs51
9 files changed, 112 insertions, 60 deletions
diff --git a/.travis.yml b/.travis.yml
index 2d13c13..97be622 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,10 @@ cache:
- $HOME/.stack
- .stack-work/install
+before_cache:
+ - rm -rf $(stack path --local-install-root)/bin
+ - rm -rf $(stack path --local-install-root)/doc
+
addons:
apt:
sources: &apt_sources
diff --git a/CHANGELOG.markdown b/CHANGELOG.markdown
index f22569a..9b9859e 100644
--- a/CHANGELOG.markdown
+++ b/CHANGELOG.markdown
@@ -7,6 +7,10 @@ project adheres to the [Haskell Package Versioning Policy
(PVP)](https://pvp.haskell.org)
+## [0.5.0.1]
+
+* Fix [#10]: doctest failure with accelerate-1.1.1.0
+
## [0.5]
* Fix [#25][acc-llvm#25]: "impossible evaluation" error with accelerate-llvm-native
@@ -34,6 +38,8 @@ project adheres to the [Haskell Package Versioning Policy
* Repository initialized
+
+[0.5.0.1]: https://github.com/ekmett/linear-accelerate/compare/v0.5...v0.5.0.1
[0.5]: https://github.com/ekmett/linear-accelerate/compare/v0.4.1...v0.5
[0.4.1]: https://github.com/ekmett/linear-accelerate/compare/v0.4...v0.4.1
[0.4]: https://github.com/ekmett/linear-accelerate/compare/v0.3...v0.4
@@ -42,5 +48,6 @@ project adheres to the [Haskell Package Versioning Policy
[0.1]: https://github.com/ekmett/linear-accelerate/compare/3db20f05af0a1488fcbc3ea28f8561ce73289b73...v0.1
[#1]: https://github.com/ekmett/linear-accelerate/issues/1
+[#10]: https://github.com/ekmett/linear-accelerate/issues/10
[acc-llvm#25]: https://github.com/AccelerateHS/accelerate-llvm/issues/25
diff --git a/linear-accelerate.cabal b/linear-accelerate.cabal
index 4274e2f..103e983 100644
--- a/linear-accelerate.cabal
+++ b/linear-accelerate.cabal
@@ -1,6 +1,6 @@
name: linear-accelerate
category: Math, Algebra, Compilers/Interpreters, Concurrency, Data, Parallelism
-version: 0.5
+version: 0.5.0.1
license: BSD3
cabal-version: >= 1.10
license-file: LICENSE
@@ -26,7 +26,7 @@ source-repository head
source-repository this
type: git
- tag: v0.5
+ tag: v0.5.0.1
location: git://github.com/ekmett/linear-accelerate.git
custom-setup
diff --git a/src/Data/Array/Accelerate/Linear/Matrix.hs b/src/Data/Array/Accelerate/Linear/Matrix.hs
index 09b6e74..fde785a 100644
--- a/src/Data/Array/Accelerate/Linear/Matrix.hs
+++ b/src/Data/Array/Accelerate/Linear/Matrix.hs
@@ -49,13 +49,19 @@ import Data.Traversable
import Control.Applicative
import Prelude as P
+-- $setup
+-- >>> import Data.Array.Accelerate.Interpreter
+-- >>> :{
+-- let test :: Elt e => Exp e -> e
+-- test e = indexArray (run (unit e)) Z
+-- :}
infixl 7 !*!
-- | Matrix product. This can compute any combination of sparse and dense multiplication.
--
--- >>> lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !*! lift (V3 (V2 1 2) (V2 3 4) (V2 4 5) :: M32 Int)
--- ((19,25),(43,58))
+-- >>> test $ lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !*! lift (V3 (V2 1 2) (V2 3 4) (V2 4 5) :: M32 Int)
+-- V2 (V2 19 25) (V2 43 58)
--
(!*!) :: (Functor m, Foldable t, Additive t, Additive n, A.Num a, Box2 m t a, Box2 t n a, Box2 m n a)
=> Exp (m (t a))
@@ -67,8 +73,8 @@ f !*! g = lift (unlift' f L.!*! unlift' g)
infixl 6 !+!
-- | Entry-wise matrix addition.
--
--- >>> lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !+! lift (V2 (V3 7 8 9) (V3 1 2 3) :: M23 Int)
--- ((8,10,12),(5,7,9))
+-- >>> test $ lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !+! lift (V2 (V3 7 8 9) (V3 1 2 3) :: M23 Int)
+-- V2 (V3 8 10 12) (V3 5 7 9)
--
(!+!) :: (Additive m, Additive n, A.Num a, Box2 m n a)
=> Exp (m (n a))
@@ -80,8 +86,8 @@ f !+! g = lift (unlift' f L.!+! unlift' g)
infixl 6 !-!
-- | Entry-wise matrix subtraction.
--
--- >>> lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !-! lift (V2 (V3 7 8 9) (V3 1 2 3) :: M23 Int)
--- ((-6,-6,-6),(3,3,3))
+-- >>> test $ lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !-! lift (V2 (V3 7 8 9) (V3 1 2 3) :: M23 Int)
+-- V2 (V3 (-6) (-6) (-6)) (V3 3 3 3)
--
(!-!) :: (Additive m, Additive n, A.Num a, Box2 m n a)
=> Exp (m (n a))
@@ -93,8 +99,8 @@ f !-! g = lift (unlift' f L.!-! unlift' g)
infixl 7 !*
-- | Matrix * column vector
--
--- >>> lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !* lift (V3 7 8 9 :: V3 Int)
--- (50,122)
+-- >>> test $ lift (V2 (V3 1 2 3) (V3 4 5 6) :: M23 Int) !* lift (V3 7 8 9 :: V3 Int)
+-- V2 50 122
--
(!*) :: (Functor m, Foldable r, Additive r, A.Num a, Box2 m r a, Box m a)
=> Exp (m (r a))
@@ -106,8 +112,8 @@ m !* v = lift (unlift' m L.!* unlift v)
infixl 7 *!
-- | Row vector * matrix
--
--- >>> lift (V2 1 2 :: V2 Int) *! lift (V2 (V3 3 4 5) (V3 6 7 8) :: M23 Int)
--- (15,18,21)
+-- >>> test $ lift (V2 1 2 :: V2 Int) *! lift (V2 (V3 3 4 5) (V3 6 7 8) :: M23 Int)
+-- V3 15 18 21
-- (*!) :: (Metric r, Additive n, Num a) => r a -> r (n a) -> n a
-- f *! g = dot f <$> distribute g
@@ -122,8 +128,8 @@ f *! g = lift (unlift f L.*! unlift' g)
infixl 7 *!!
-- | Scalar-matrix product
--
--- >>> 5 *!! lift (V2 (V2 1 2) (V2 3 4) :: M22 Int)
--- ((5,10),(15,20))
+-- >>> test $ 5 *!! lift (V2 (V2 1 2) (V2 3 4) :: M22 Int)
+-- V2 (V2 5 10) (V2 15 20)
--
(*!!) :: (Functor m, Functor r, A.Num a, Box2 m r a)
=> Exp a
@@ -135,8 +141,8 @@ s *!! m = lift (unlift s L.*!! unlift' m)
infixl 7 !!*
-- | Matrix-scalar product
--
--- >>> lift (V2 (V2 1 2) (V2 3 4) :: M22 Int) !!* 5
--- ((5,10),(15,20))
+-- >>> test $ lift (V2 (V2 1 2) (V2 3 4) :: M22 Int) !!* 5
+-- V2 (V2 5 10) (V2 15 20)
--
(!!*) :: (Functor m, Functor r, A.Num a, Box2 m r a)
=> Exp (m (r a))
@@ -157,15 +163,11 @@ m !!/ s = lift (unlift' m L.!!/ unlift s)
-- |The identity matrix for any dimension vector.
--
--- >>> identity :: Exp (M44 Int)
--- let x0 = 1 in
--- let x1 = 0
--- in ((x0,x1,x1,x1),(x1,x0,x1,x1),(x1,x1,x0,x1),(x1,x1,x1,x0))
+-- >>> test $ (identity :: Exp (M44 Int))
+-- V4 (V4 1 0 0 0) (V4 0 1 0 0) (V4 0 0 1 0) (V4 0 0 0 1)
--
--- >>> identity :: Exp (V3 (V3 Int))
--- let x0 = 1 in
--- let x1 = 0
--- in ((x0,x1,x1),(x1,x0,x1),(x1,x1,x0))
+-- >>> test $ (identity :: Exp (V3 (V3 Int)))
+-- V3 (V3 1 0 0) (V3 0 1 0) (V3 0 0 1)
--
identity :: forall t a. (Traversable t, Applicative t, A.Num a, Box2 t t a) => Exp (t (t a))
identity = lift (L.identity :: t (t (Exp a)))
@@ -173,7 +175,7 @@ identity = lift (L.identity :: t (t (Exp a)))
-- | 'transpose' is just an alias for 'distribute'
--
--- > transpose (V3 (V2 1 2) (V2 3 4) (V2 5 6))
+-- >>> test $ transpose $ lift (V3 (V2 1 2) (V2 3 4) (V2 5 6) :: M32 Int)
-- V2 (V3 1 3 5) (V3 2 4 6)
--
transpose
diff --git a/src/Data/Array/Accelerate/Linear/V1.hs b/src/Data/Array/Accelerate/Linear/V1.hs
index 3be8762..c1ed71f 100644
--- a/src/Data/Array/Accelerate/Linear/V1.hs
+++ b/src/Data/Array/Accelerate/Linear/V1.hs
@@ -44,16 +44,23 @@ import Linear.V1 ( V1(..) )
import qualified Linear.V1 as L
import Prelude as P
+-- $setup
+-- >>> import Data.Array.Accelerate.Interpreter
+-- >>> :{
+-- let test :: Elt e => Exp e -> e
+-- test e = indexArray (run (unit e)) Z
+-- :}
+
-- | A space that has at least 1 basis vector '_x'.
--
class L.R1 t => R1 t where
-- |
- -- >>> lift (V1 2 :: V1 Int) ^._x
+ -- >>> test $ lift (V1 2 :: V1 Int) ^._x
-- 2
--
- -- >>> lift (V1 2 :: V1 Int) & _x .~ 3
- -- (3)
+ -- >>> test $ lift (V1 2 :: V1 Int) & _x .~ 3
+ -- V1 3
--
_x :: (Elt a, Box t a) => Lens' (Exp (t a)) (Exp a)
_x = liftLens (L._x :: Lens' (t (Exp a)) (Exp a))
diff --git a/src/Data/Array/Accelerate/Linear/V2.hs b/src/Data/Array/Accelerate/Linear/V2.hs
index 0041e32..e474898 100644
--- a/src/Data/Array/Accelerate/Linear/V2.hs
+++ b/src/Data/Array/Accelerate/Linear/V2.hs
@@ -47,11 +47,18 @@ import Linear.V2 ( V2(..) )
import qualified Linear.V2 as L
import Prelude as P
+-- $setup
+-- >>> import Data.Array.Accelerate.Interpreter
+-- >>> :{
+-- let test :: Elt e => Exp e -> e
+-- test e = indexArray (run (unit e)) Z
+-- :}
+
-- | the counter-clockwise perpendicular vector
--
--- >>> perp $ lift (V2 10 20 :: V2 Int)
--- (-20,10)
+-- >>> test $ perp $ lift (V2 10 20 :: V2 Int)
+-- V2 (-20) 10
--
perp :: forall a. A.Num a => Exp (V2 a) -> Exp (V2 a)
perp = lift1 (L.perp :: V2 (Exp a) -> V2 (Exp a))
@@ -68,11 +75,11 @@ angle = lift . L.angle
--
class (L.R2 t, R1 t) => R2 t where
-- |
- -- >>> lift (V2 1 2 :: V2 Int) ^._y
+ -- >>> test $ lift (V2 1 2 :: V2 Int) ^._y
-- 2
--
- -- >>> lift (V2 1 2 :: V2 Int) & _y .~ 3
- -- (1,3)
+ -- >>> test $ lift (V2 1 2 :: V2 Int) & _y .~ 3
+ -- V2 1 3
--
_y :: (Elt a, Box t a) => Lens' (Exp (t a)) (Exp a)
_y = liftLens (L._y :: Lens' (t (Exp a)) (Exp a))
@@ -82,8 +89,8 @@ class (L.R2 t, R1 t) => R2 t where
-- |
--- >>> lift (V2 1 2 :: V2 Int) ^. _yx
--- (2,1)
+-- >>> test $ lift (V2 1 2 :: V2 Int) ^. _yx
+-- V2 2 1
--
_yx :: forall t a. (R2 t, Elt a, Box t a) => Lens' (Exp (t a)) (Exp (V2 a))
_yx = liftLens (L._yx :: Lens' (t (Exp a)) (V2 (Exp a)))
diff --git a/src/Data/Array/Accelerate/Linear/V3.hs b/src/Data/Array/Accelerate/Linear/V3.hs
index 1839c0b..b9557cd 100644
--- a/src/Data/Array/Accelerate/Linear/V3.hs
+++ b/src/Data/Array/Accelerate/Linear/V3.hs
@@ -52,6 +52,13 @@ import Linear.V3 ( V3(..) )
import qualified Linear.V3 as L
import Prelude as P
+-- $setup
+-- >>> import Data.Array.Accelerate.Interpreter
+-- >>> :{
+-- let test :: Elt e => Exp e -> e
+-- test e = indexArray (run (unit e)) Z
+-- :}
+
-- | cross product
--
@@ -69,9 +76,12 @@ triple = lift3 (L.triple :: V3 (Exp a) -> V3 (Exp a) -> V3 (Exp a) -> Exp a)
--
class (L.R3 t, R2 t) => R3 t where
-- |
- -- >>> lift (V3 1 2 3 :: V3 Int) ^. _z
+ -- >>> test $ lift (V3 1 2 3 :: V3 Int) ^. _z
-- 3
--
+ -- >>> test $ lift (V3 1 2 3 :: V3 Int) & _z .~ 42
+ -- V3 1 2 42
+ --
_z :: forall a. (Elt a, Box t a) => Lens' (Exp (t a)) (Exp a)
_z = liftLens (L._z :: Lens' (t (Exp a)) (Exp a))
diff --git a/src/Data/Array/Accelerate/Linear/V4.hs b/src/Data/Array/Accelerate/Linear/V4.hs
index 0fcbcd0..95c785c 100644
--- a/src/Data/Array/Accelerate/Linear/V4.hs
+++ b/src/Data/Array/Accelerate/Linear/V4.hs
@@ -60,6 +60,13 @@ import Linear.V4 ( V4(..) )
import qualified Linear.V4 as L
import Prelude as P
+-- $setup
+-- >>> import Data.Array.Accelerate.Interpreter
+-- >>> :{
+-- let test :: Elt e => Exp e -> e
+-- test e = indexArray (run (unit e)) Z
+-- :}
+
-- | Convert a 3-dimensional affine vector into a 4-dimensional homogeneous
-- vector.
@@ -86,9 +93,12 @@ normalizePoint = lift1 (L.normalizePoint :: V4 (Exp a) -> V3 (Exp a))
--
class (L.R4 t, R3 t) => R4 t where
-- |
- -- >>> lift (V4 1 2 3 4 :: V4 Int) ^._w
+ -- >>> test $ lift (V4 1 2 3 4 :: V4 Int) ^._w
-- 4
--
+ -- >>> test $ lift (V4 1 2 3 4 :: V4 Int) & _w .~ 42
+ -- V4 1 2 3 42
+ --
_w :: forall a. (Elt a, Box t a) => Lens' (Exp (t a)) (Exp a)
_w = liftLens (L._w :: Lens' (t (Exp a)) (Exp a))
diff --git a/src/Data/Array/Accelerate/Linear/Vector.hs b/src/Data/Array/Accelerate/Linear/Vector.hs
index a0f0843..69cde1c 100644
--- a/src/Data/Array/Accelerate/Linear/Vector.hs
+++ b/src/Data/Array/Accelerate/Linear/Vector.hs
@@ -32,8 +32,13 @@ infixl 6 ^+^, ^+, +^, ^-^, ^-, -^
infixl 7 ^*, *^, ^/, /^
-- $setup
--- >>> import Data.Array.Accelerate.Linear.V2 ()
-- >>> import Linear.V2
+-- >>> import Data.Array.Accelerate.Linear.V2 ()
+-- >>> import Data.Array.Accelerate.Interpreter
+-- >>> :{
+-- let test :: Elt e => Exp e -> e
+-- test e = indexArray (run (unit e)) Z
+-- :}
-- | A vector is an additive group with additional structure.
--
@@ -48,8 +53,8 @@ class L.Additive f => Additive f where
-- | Compute the sum of two vectors
--
- -- >>> lift (V2 1 2 :: V2 Int) ^+^ lift (V2 3 4 :: V2 Int)
- -- (4,6)
+ -- >>> test $ lift (V2 1 2 :: V2 Int) ^+^ lift (V2 3 4 :: V2 Int)
+ -- V2 4 6
--
(^+^) :: forall a. (A.Num a, Box f a)
=> Exp (f a)
@@ -59,8 +64,8 @@ class L.Additive f => Additive f where
-- | Compute the difference between two vectors
--
- -- >>> lift (V2 4 5 :: V2 Int) ^-^ lift (V2 3 1 :: V2 Int)
- -- (1,4)
+ -- >>> test $ lift (V2 4 5 :: V2 Int) ^-^ lift (V2 3 1 :: V2 Int)
+ -- V2 1 4
--
(^-^) :: forall a. (A.Num a, Box f a)
=> Exp (f a)
@@ -90,8 +95,8 @@ newtype E t = E {
-- | Compute the negation of a vector
--
--- >>> negated (lift (V2 2 4 :: V2 Int))
--- (-2,-4)
+-- >>> test $ negated (lift (V2 2 4 :: V2 Int))
+-- V2 (-2) (-4)
--
negated
:: forall f a. (Functor f, A.Num a, Box f a)
@@ -101,8 +106,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Compute the left scalar product
--
--- >>> 2 *^ lift (V2 3 4 :: V2 Int)
--- (6,8)
+-- >>> test $ 2 *^ lift (V2 3 4 :: V2 Int)
+-- V2 6 8
--
(*^) :: forall f a. (Functor f, A.Num a, Box f a)
=> Exp a
@@ -112,8 +117,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Compute the right scalar product
--
--- >>> lift (V2 3 4 :: V2 Int) ^* 2
--- (6,8)
+-- >>> test $ lift (V2 3 4 :: V2 Int) ^* 2
+-- V2 6 8
--
(^*) :: forall f a. (Functor f, A.Num a, Box f a)
=> Exp (f a)
@@ -123,8 +128,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Compute division by a scalar on the right
--
--- lift (V2 4 6 :: V2 Double) ^/ 2
--- V2 2 3
+-- >>> test $ lift (V2 4 6 :: V2 Double) ^/ 2
+-- V2 2.0 3.0
--
(^/) :: forall f a. (Functor f, A.Fractional a, Box f a)
=> Exp (f a)
@@ -134,8 +139,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Compute division of a scalar on the left
--
--- >>> 4 /^ lift (V2 2 4 :: V2 Double)
--- (2.0,1.0)
+-- >>> test $ 4 /^ lift (V2 2 4 :: V2 Double)
+-- V2 2.0 1.0
--
(/^) :: forall f a. (Functor f, A.Fractional a, Box f a)
=> Exp a
@@ -145,8 +150,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Addition with a scalar on the left
--
--- >>> 2 +^ lift (V2 3 4 :: V2 Int)
--- (5,6)
+-- >>> test $ 2 +^ lift (V2 3 4 :: V2 Int)
+-- V2 5 6
--
(+^) :: forall f a. (Functor f, A.Num a, Box f a)
=> Exp a
@@ -156,8 +161,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Addition with a scalar on the right
--
--- >>> lift (V2 1 2 :: V2 Int) ^+ 3
--- (4,5)
+-- >>> test $ lift (V2 1 2 :: V2 Int) ^+ 3
+-- V2 4 5
--
(^+) :: forall f a. (Functor f, A.Num a, Box f a)
=> Exp (f a)
@@ -167,8 +172,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Subtraction with a scalar on the left
--
--- >>> 2 -^ lift (V2 3 4 :: V2 Int)
--- (-1,-2)
+-- >>> test $ 2 -^ lift (V2 3 4 :: V2 Int)
+-- V2 (-1) (-2)
--
(-^) :: forall f a. (Functor f, A.Num a, Box f a)
=> Exp a
@@ -178,8 +183,8 @@ negated = lift1 (L.negated :: f (Exp a) -> f (Exp a))
-- | Subtraction with a scalar on the right
--
--- >>> lift (V2 1 2 :: V2 Int) ^- 3
--- (-2,-1)
+-- >>> test $ lift (V2 1 2 :: V2 Int) ^- 3
+-- V2 (-2) (-1)
--
(^-) :: forall f a. (Functor f, A.Num a, Box f a)
=> Exp (f a)