packages feed

hVOIDP 1.0 → 1.0.1

raw patch · 3 files changed

+93/−1 lines, 3 files

Files

+ Dynamic.hs view
@@ -0,0 +1,11 @@+module Dynamic(module Table,dynamic) where+-- to get access to the imported modules in Hugs do+-- :set -P../Chapter5:{Hugs}/lib:{Hugs}/lib/hugs:{Hugs}/lib/exts+import Table+import Data.Ix++dynamic :: Ix coord => (Table entry coord -> coord -> entry)+                        -> (coord,coord) -> (Table entry coord)+dynamic compute bnds = t+    where t = newTable (map (\coord ->(coord,compute t coord)) +                            (range bnds))
+ Table.hs view
@@ -0,0 +1,74 @@+module Table(Table,newTable,findTable,updTable) where++{--- general index ---+newTable    :: (Eq b) => [(b,a)] -> Table a b+findTable   :: (Eq b) => Table a b -> b -> a+updTable    :: (Eq b) => (b,a) -> Table a b -> Table a b++--}++{-- Function implementation --++newtype Table a b   = Tbl (b -> a)++instance Show (Table a b) where+    showsPrec _ _ str = showString "<<A Table>>" str++newTable assocs = foldr updTable +                        (Tbl (\_ -> error "item not found in table"))+                        assocs++findTable (Tbl f) i   = f i++updTable (i,x) (Tbl f) = Tbl g+    where g j | j==i      = x+              | otherwise = f j+-- end of Function implementation --}++{-- List implementation --}+{--+newtype Table a b        = Tbl [(b,a)]+    deriving Show++newTable   t          = Tbl t++findTable (Tbl []) i = error "item not found in table"+findTable (Tbl ((j,v):r)) i+     | (i==j)        = v+     | otherwise     = findTable (Tbl r) i ++updTable e (Tbl [])         = (Tbl [e])+updTable e'@(i,_) (Tbl (e@(j,_):r))+     | (i==j)         = Tbl (e':r)+     | otherwise      = Tbl (e:r')+     where Tbl r' = updTable e' (Tbl r)+--}++{-- end of List implementation --}++{--- end of general index ---}++--- Array implementation ---++import Data.Array++newTable    :: (Ix b) => [(b,a)] -> Table a b+findTable   :: (Ix b) => Table a b -> b -> a+updTable    :: (Ix b) => (b,a) -> Table a b -> Table a b++newtype Table a b     = Tbl (Array b a)+    deriving Show++newTable l = Tbl (array (lo,hi) l)+    where+           indices = map fst l+           lo      = minimum indices+           hi      = maximum indices++findTable (Tbl a) i      = a ! i++updTable p@(i,x) (Tbl a) = Tbl (a // [p])++--- end of Array implementation ---++
hVOIDP.cabal view
@@ -1,5 +1,5 @@ Name:	hVOIDP-Version: 1.0+Version: 1.0.1 Synopsis: Optimal variable selection in chain graphical model. Description:     An implementation of the VOIDP algorithm that selects the optimal observations in chain graphical models.@@ -33,3 +33,10 @@   Build-Depends:   array,hmatrix,base >=3 && <5   extra-libraries: lapack blas   extra-lib-dirs:  /usr/lib +++Library  +  Hs-source-dirs:  .+  Exposed-Modules:+    Dynamic+    Table