diff options
author | Alberto Ruiz <aruiz@um.es> | 2014-04-24 13:17:55 +0200 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2014-04-24 13:17:55 +0200 |
commit | de0219353ca9631135a3f750cef05b9636bef232 (patch) | |
tree | 2943867ceca43bcf5037f60077a6269f589deff8 /lib/Numeric/Container.hs | |
parent | 3c1bbdd450304945c035a1e49cdb67871ea50451 (diff) |
konst with bidirectional type inference
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r-- | lib/Numeric/Container.hs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index ed6714f..a31acfe 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs | |||
@@ -28,6 +28,7 @@ | |||
28 | module Numeric.Container ( | 28 | module Numeric.Container ( |
29 | -- * Basic functions | 29 | -- * Basic functions |
30 | module Data.Packed, | 30 | module Data.Packed, |
31 | konst, -- build, | ||
31 | constant, linspace, | 32 | constant, linspace, |
32 | diag, ident, | 33 | diag, ident, |
33 | ctrans, | 34 | ctrans, |
@@ -59,8 +60,6 @@ module Numeric.Container ( | |||
59 | loadMatrix, saveMatrix, fromFile, fileDimensions, | 60 | loadMatrix, saveMatrix, fromFile, fileDimensions, |
60 | readMatrix, | 61 | readMatrix, |
61 | fscanfVector, fprintfVector, freadVector, fwriteVector, | 62 | fscanfVector, fprintfVector, freadVector, fwriteVector, |
62 | -- * Experimental | ||
63 | build', konst' | ||
64 | ) where | 63 | ) where |
65 | 64 | ||
66 | import Data.Packed | 65 | import Data.Packed |
@@ -174,3 +173,18 @@ instance Container Matrix t => Contraction t (Matrix t) (Matrix t) where | |||
174 | instance Container Matrix t => Contraction (Matrix t) t (Matrix t) where | 173 | instance Container Matrix t => Contraction (Matrix t) t (Matrix t) where |
175 | (×) = flip scale | 174 | (×) = flip scale |
176 | 175 | ||
176 | -------------------------------------------------------------------------------- | ||
177 | |||
178 | -- bidirectional type inference | ||
179 | class Konst e d c | d -> c, c -> d | ||
180 | where | ||
181 | konst :: e -> d -> c e | ||
182 | |||
183 | instance Container Vector e => Konst e Int Vector | ||
184 | where | ||
185 | konst = konst' | ||
186 | |||
187 | instance Container Vector e => Konst e (Int,Int) Matrix | ||
188 | where | ||
189 | konst = konst' | ||
190 | |||