summaryrefslogtreecommitdiff
path: root/lib/Numeric/Container.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2014-04-24 13:17:55 +0200
committerAlberto Ruiz <aruiz@um.es>2014-04-24 13:17:55 +0200
commitde0219353ca9631135a3f750cef05b9636bef232 (patch)
tree2943867ceca43bcf5037f60077a6269f589deff8 /lib/Numeric/Container.hs
parent3c1bbdd450304945c035a1e49cdb67871ea50451 (diff)
konst with bidirectional type inference
Diffstat (limited to 'lib/Numeric/Container.hs')
-rw-r--r--lib/Numeric/Container.hs18
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 @@
28module Numeric.Container ( 28module 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
66import Data.Packed 65import Data.Packed
@@ -174,3 +173,18 @@ instance Container Matrix t => Contraction t (Matrix t) (Matrix t) where
174instance Container Matrix t => Contraction (Matrix t) t (Matrix t) where 173instance Container Matrix t => Contraction (Matrix t) t (Matrix t) where
175 (×) = flip scale 174 (×) = flip scale
176 175
176--------------------------------------------------------------------------------
177
178-- bidirectional type inference
179class Konst e d c | d -> c, c -> d
180 where
181 konst :: e -> d -> c e
182
183instance Container Vector e => Konst e Int Vector
184 where
185 konst = konst'
186
187instance Container Vector e => Konst e (Int,Int) Matrix
188 where
189 konst = konst'
190