diff options
author | Alberto Ruiz <aruiz@um.es> | 2007-06-13 16:35:02 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2007-06-13 16:35:02 +0000 |
commit | 713d4056abb2e786b4084e7e220d359b06dcaf1f (patch) | |
tree | 4535b87da8756ca89f07e46181891df2b90406dc /lib/Data/Packed/Internal/Tensor.hs | |
parent | 8c5be977858723aac8b8f47f57ce98d82fe249b4 (diff) |
refactoring
Diffstat (limited to 'lib/Data/Packed/Internal/Tensor.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Tensor.hs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Data/Packed/Internal/Tensor.hs b/lib/Data/Packed/Internal/Tensor.hs index 67dcb09..123270d 100644 --- a/lib/Data/Packed/Internal/Tensor.hs +++ b/lib/Data/Packed/Internal/Tensor.hs | |||
@@ -1,4 +1,3 @@ | |||
1 | --{-# OPTIONS_GHC -fglasgow-exts -fallow-undecidable-instances #-} | ||
2 | ----------------------------------------------------------------------------- | 1 | ----------------------------------------------------------------------------- |
3 | -- | | 2 | -- | |
4 | -- Module : Data.Packed.Internal.Tensor | 3 | -- Module : Data.Packed.Internal.Tensor |
@@ -9,15 +8,17 @@ | |||
9 | -- Stability : provisional | 8 | -- Stability : provisional |
10 | -- Portability : portable (uses FFI) | 9 | -- Portability : portable (uses FFI) |
11 | -- | 10 | -- |
12 | -- Fundamental types | 11 | -- basic tensor operations |
13 | -- | 12 | -- |
14 | ----------------------------------------------------------------------------- | 13 | ----------------------------------------------------------------------------- |
15 | 14 | ||
16 | module Data.Packed.Internal.Tensor where | 15 | module Data.Packed.Internal.Tensor where |
17 | 16 | ||
17 | import Data.Packed.Internal | ||
18 | import Data.Packed.Internal.Vector | 18 | import Data.Packed.Internal.Vector |
19 | import Data.Packed.Internal.Matrix | 19 | import Data.Packed.Internal.Matrix |
20 | import Foreign.Storable | 20 | import Foreign.Storable |
21 | import Data.List(sort) | ||
21 | 22 | ||
22 | data IdxTp = Covariant | Contravariant deriving (Show,Eq) | 23 | data IdxTp = Covariant | Contravariant deriving (Show,Eq) |
23 | 24 | ||
@@ -99,3 +100,10 @@ compatIdxAux (n1,(t1,_)) (n2, (t2,_)) = t1 /= t2 && n1 == n2 | |||
99 | compatIdx t1 n1 t2 n2 = compatIdxAux d1 d2 where | 100 | compatIdx t1 n1 t2 n2 = compatIdxAux d1 d2 where |
100 | d1 = head $ snd $ fst $ findIdx n1 t1 | 101 | d1 = head $ snd $ fst $ findIdx n1 t1 |
101 | d2 = head $ snd $ fst $ findIdx n2 t2 | 102 | d2 = head $ snd $ fst $ findIdx n2 t2 |
103 | |||
104 | names t = sort $ map (snd.snd) (dims t) | ||
105 | |||
106 | normal t = tridx (names t) t | ||
107 | |||
108 | contractions t1 t2 = [ contraction t1 n1 t2 n2 | n1 <- names t1, n2 <- names t2, compatIdx t1 n1 t2 n2 ] | ||
109 | |||