Aelve Codesearch

grep over package repositories
Please provide a string to search for.
3+ characters are required.
Index updated about a month ago

total matches: more than 1000

ADPfusion-0.5.2.2
10 matches
ADP/Fusion/SynVar/Fill.hs
    VU.forM_ tbos $ \bo ->
      case (VU.length tlos) of
        1 -> let lo = VU.head tlos
             in  flip SM.mapM_ (streamUp from to) $ \k ->
                  mutateCell h bo lo (inline mrph) tt to k
        -- TODO each big-order group should be allowed to have its own sets
        -- of bounds. within a group, it doesn't make a lot of sense to
        -- have different bounds? Is there a use case for that even?
        _ -> flip SM.mapM_ (streamUp from to) $ \k ->

            
ADP/Fusion/SynVar/Fill.hs
        -- TODO each big-order group should be allowed to have its own sets
        -- of bounds. within a group, it doesn't make a lot of sense to
        -- have different bounds? Is there a use case for that even?
        _ -> flip SM.mapM_ (streamUp from to) $ \k ->
              VU.forM_ tlos $ \lo ->
                mutateCell h bo lo (inline mrph) tt to k
    return tt
  {-# INLINE mutateTables #-}


            
ADP/Fusion/SynVar/Fill.hs
    if null hs
      then fillWithDyn qs ts
      else do
        let ms = Prelude.map concrete hs
            concrete  = (maybe (error "fromDynamic should not fail!")
                         (\x -> x `asTypeOf` t)
                        . fromDynamic . qObject)
        -- We have a single table and should short-circuit here
        --

            
ADP/Fusion/SynVar/Fill.hs
        -- seconds down to @1.25@ seconds. :-)
        case (length ms) of
          1 -> do marr <- unsafeThaw arr
                  flip SM.mapM_ (streamUp from to) $ \k -> do
                    -- TODO @inline mrph@ ...
                    z <- (return . unId) $ f to k
                    writeM marr k z
        -- We have more than one table in will work over the list of tables
          _ -> do marrfs <- Prelude.mapM (\(TW (ITbl _ _ _ arr) f) -> unsafeThaw arr >>= \marr -> return (marr,f)) ms

            
ADP/Fusion/SynVar/Fill.hs
                    z <- (return . unId) $ f to k
                    writeM marr k z
        -- We have more than one table in will work over the list of tables
          _ -> do marrfs <- Prelude.mapM (\(TW (ITbl _ _ _ arr) f) -> unsafeThaw arr >>= \marr -> return (marr,f)) ms
                  flip SM.mapM_ (streamUp from to) $ \k ->
                    forM_ marrfs $ \(marr,f) -> do
                      z <- (return . unId) $ f to k
                      writeM marr k z
        -- traceShow (hs,length ms) $
        return ns

            
ADP/Fusion/Tutorial/NeedlemanWunsch.hs
with Boxed and Unboxed tables. In addition, linear, context-free, and set
data structures are made available.

> import           Data.PrimitiveArray as PA hiding (map)

@ADP.Fusion.Point@ exposes everything necessary for higher-level DP
algorithms. Depending on the type of DP algorithm, different top-level
modules can be imported. @.Point@ for linear grammars, and @.Core@ are
provided in this package. @.Core@ exports only the core modules required to

            
src/NeedlemanWunsch.hs
-- with Boxed and Unboxed tables. In addition, linear, context-free, and
-- set data structures are made available.

import           Data.PrimitiveArray as PA hiding (map)

-- @ADP.Fusion.Point@ exposes everything necessary for higher-level DP
-- algorithms. Depending on the type of DP algorithm, different top-level
-- modules can be imported. @.Point@ for linear grammars, and @.Core@ are
-- provided in this package. @.Core@ exports only the core modules required

            
src/SpecTest.hs
import           System.IO.Unsafe (unsafePerformIO)
import           Text.Printf

import           Data.PrimitiveArray as PA hiding (map)

import           ADP.Fusion.Point




            
tests/BacktrackingStructures.hs
module Main where

import           Criterion.Main
import           Data.Vector.Fusion.Stream.Monadic (Stream,foldl',mapM_)
import           Data.Vector.Fusion.Util
import           Data.Vector.Unboxed (Vector, fromList)
import           GHC.Exts (inline, Int(..), (<=#) )
import           Prelude hiding (mapM_)
import           System.IO.Unsafe
import qualified Data.FMList as F




            
tests/QuickCheck/Point.hs
stoList = unId . SM.toList

infixl 8 >>>
(>>>) f xs = \lu ij -> SM.map f . mkStream (build xs) (initialContext ij) lu $ ij

xsP :: Unboxed (PointL I) Int
xsP = fromList (PointL 0) maxPLi [0 ..]

xsZP :: Unboxed (Z:.PointL I) Int

            
ADPfusionForest-0.0.0.1
20 matches
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
import           Data.Either (either)
import           Data.Graph.Inductive.Basic
import           Data.Strict.Tuple hiding (fst, snd)
import           Data.Traversable (mapAccumL)
import           Data.Vector.Fusion.Stream.Monadic hiding (flatten)
import           Debug.Trace
import           Prelude hiding (map)
import qualified Data.Forest.Static as F
import qualified Data.Tree as T
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Fusion.Stream.Monadic as SM

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs

import           ADP.Fusion.Core
import           Data.Forest.Static
import           Data.PrimitiveArray hiding (map)

import           ADP.Fusion.Term.Node.Type

-- HETEROGEN


            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
{-
mkLookUp f = HM.fromList . flip P.zip [0..] . go $ roots f : (VG.toList $ children f)
  where go :: [VU.Vector Int] -> [VU.Vector Int]
        go = P.map VG.fromList
           . S.toList . S.fromList
           . P.concatMap (P.tail . subsequences)
           . P.concatMap permutations
           . P.map VG.toList
        -- @go@ generates all permutations (i.e. all orders of children),
        -- then for each such order provides all possible subsequences.
        -- This yields all ordered subsets. These are then made unique and
        -- associated in the main body with linearized indices.
-}

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  ( TmkCtx1 m ls Epsilon (TreeIxR p v a t)
  ) => MkStream m (ls :!: Epsilon) (TreeIxR p v a t) where
  mkStream (ls :!: Epsilon) sv us is
    = map (\(ss,ee,ii) -> ElmEpsilon ii ss)
    . addTermStream1 Epsilon sv us is
    $ mkStream ls (termStaticVar Epsilon sv is) us (termStreamIndex Epsilon sv is)
  {-# Inline mkStream #-}



            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  ( TstCtx m ts s x0 i0 is (TreeIxR p v a I)
  ) => TermStream m (TermSymbol ts Epsilon) s (is:.TreeIxR p v a I) where
  termStream (ts:|Epsilon) (cs:.IStatic ()) (us:.TreeIxR _ ul utfe) (is:.TreeIxR frst il itfe)
    = map (\(TState s ii ee) ->
              let RiTirI ef = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a I))
                  l         = case ef of {E l -> l ; F _ -> 0}
              in  TState s (ii:.:RiTirI ef) (ee:.()) )
    . termStream ts cs us is
    . staticCheck ( (isEmpty itfe) || getTFEIx utfe == 0) --TODO: 2nd condition takes care of empty inputs

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  ( TmkCtx1 m ls Deletion (TreeIxR p v a t)
  ) => MkStream m (ls :!: Deletion) (TreeIxR p v a t) where
  mkStream (ls :!: Deletion) sv us is
    = map (\(ss,ee,ii) -> ElmDeletion ii ss)
    . addTermStream1 Deletion sv us is
    $ mkStream ls (termStaticVar Deletion sv is) us (termStreamIndex Deletion sv is)
  {-# Inline mkStream #-}



            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  ( TstCtx m ts s x0 i0 is (TreeIxR p v a I)
  ) => TermStream m (TermSymbol ts Deletion) s (is:.TreeIxR p v a I) where
  termStream (ts:|Deletion) (cs:.IVariable ()) (us:.u) (is:.TreeIxR frst i ii)
    = map (\(TState s ii ee) ->
              let RiTirI tfe = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a I))
              in  {- traceShow ("-"::String,l,tf) $ -} TState s (ii:.:RiTirI tfe) (ee:.()) )
    . termStream ts cs us is
--    . staticCheck (ii == T)
  {-# Inline termStream #-}

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , MkStream m S is
  ) => MkStream m S (is:.TreeIxR p v a I) where
  mkStream S (vs:._) (lus:.TreeIxR frst ul utfe) (is:.TreeIxR _ kl ktfe)
    = map (\(ElmS zi) -> ElmS $ zi :.: RiTirI ktfe)
    . staticCheck ((getTFEIx ktfe) >=0 && (getTFEIx ktfe) <= (getTFEIx utfe))
    $ mkStream S vs lus is
  {-# INLINE mkStream #-}

-- | When choosing tree and forest sizes, 

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
--  , a ~ Info
  ) => AddIndexDense s (us:.TreeIxR p v a I) (cs:.c) (is:.TreeIxR p v a I) where
  addIndexDenseGo (cs:._) (vs:.IStatic ()) (lbs:._) (ubs:._) (us:.TreeIxR frst ul utfe) (is:.TreeIxR _ jl jtfe)
    = map go . addIndexDenseGo cs vs lbs ubs us is
    where
      go (SvS s tt ii) =
        let RiTirI tfe = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a I))
            -- TODO this will probably barf, because we need the index
            -- "after the empty forest", which we can't get anymore.

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , Show r
  ) => TermStream m (TermSymbol ts (Node r x)) s (is:.TreeIxR p v a O) where
  termStream (ts:|Node f nty xs) (cs:.OFirstLeft ()) (us:.TreeIxR _ ul utfe) (is:.TreeIxR frst il itfe)
    = map (\(TState s ii ee) ->
              let RiTirO l = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a O))
                  p = case l of 
                        E i  -> i 
                        F cs -> parent frst VG.! VG.head cs
              in  TState s (ii:.:RiTirO (T p)) (ee:.f xs p) )

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , Show r
  ) => TermStream m (TermSymbol ts (PermNode r x)) s (is:.TreeIxR p v a O) where
  termStream (ts:|PermNode f xs) (cs:.OFirstLeft ()) (us:.TreeIxR _ ul utfe) (is:.TreeIxR frst il itfe)
    = map (\(TState s ii ee) ->
              let RiTirO l = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a O))
                  p = case l of 
                        E i  -> i 
                        F cs -> parent frst VG.! VG.head cs
              in  TState s (ii:.:RiTirO (T p)) (ee:.f xs p) )

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  ( TstCtx m ts s x0 i0 is (TreeIxR p v a O)
  ) => TermStream m (TermSymbol ts Epsilon) s (is:.TreeIxR p v a O) where
  termStream (ts:|Epsilon) (cs:.OStatic ()) (us:.TreeIxR _ ul utfe) (is:.TreeIxR frst il itfe)
    = map (\(TState s ii ee) ->
              let RiTirO ef = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a O))
              in  TState s (ii:.:RiTirO ef) (ee:.()) )
    . termStream ts cs us is
    . staticCheck (case itfe of {F cs -> cs == roots frst; _ -> False}) 
  {-# Inline termStream #-}

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  ( TstCtx m ts s x0 i0 is (TreeIxR p v a O)
  ) => TermStream m (TermSymbol ts Deletion) s (is:.TreeIxR p v a O) where
  termStream (ts:|Deletion) (cs:._) (us:.u) (is:.TreeIxR frst i ii)
    = map (\(TState s ii ee) ->
              let RiTirO tfe = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a O))
              in  {- traceShow ("-"::String,l,tf) $ -} TState s (ii:.:RiTirO tfe) (ee:.()) )
    . termStream ts cs us is
--    . staticCheck (ii == T)
  {-# Inline termStream #-}

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , MkStream m S is
  ) => MkStream m S (is:.TreeIxR p v a O) where
  mkStream S (vs:._) (lus:.TreeIxR frst ul utfe) (is:.TreeIxR _ kl ktfe)
    = map (\(ElmS zi) -> ElmS $ zi :.: RiTirO ktfe)
    . staticCheck ((getTFEIx ktfe) >=0 && (getTFEIx ktfe) <= (getTFEIx utfe))
    $ mkStream S vs lus is
  {-# INLINE mkStream #-}



            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , MinSize c
  ) => AddIndexDense s (us:.TreeIxR p v a O) (cs:.c) (is:.TreeIxR p v a O) where
  addIndexDenseGo (cs:._) (vs:.OStatic ()) (lbs:._) (ubs:._) (us:.TreeIxR frst ul utfe) (is:.TreeIxR _ jl jtfe)
    = map go .addIndexDenseGo cs vs lbs ubs us is
    where go (SvS s tt ii) =
            let RiTirO ol = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a O))
            in  SvS s (tt:.TreeIxR frst ul ol) (ii:.:RiTirO ol) -- TODO should set right boundary
  addIndexDenseGo (cs:._) (vs:.ORightOf ()) (lbs:._) (ubs:._) (us:.TreeIxR frst ul utfe) (is:.TreeIxR _ jl jtfe)
    = flatten mk step . addIndexDenseGo cs vs lbs ubs us is

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  | let p = parent frst VG.! i
  , p >= 0
  , let cs = children frst VG.! p
  = L.map (F. VG.fromList) . L.map (i:) . L.concatMap permutations . subsequences . L.delete i $ VG.toList cs 
genPerm _ _ = []
{-# Inline genPerm #-}




            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , MinSize c
  ) => AddIndexDense s (us:.TreeIxR p v a I) (cs:.c) (is:.TreeIxR p v a O) where
  addIndexDenseGo (cs:._) (vs:.OStatic ()) (lbs:._) (ubs:._) (us:.TreeIxR frst ul utfe) (is:.TreeIxR _ jl jtfe)
    = map go .addIndexDenseGo cs vs lbs ubs us is
    where go (SvS s tt ii) =
            let RiTirO lo = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a O))
            in  SvS s (tt:.TreeIxR frst jl lo) (ii:.:RiTirO lo) -- TODO should set right boundary
  addIndexDenseGo (cs:._) (vs:.OFirstLeft ()) (lbs:._) (ubs:._) (us:.TreeIxR frst ul utfe) (is:.TreeIxR _ jl jtfe)
    = flatten mk step . addIndexDenseGo cs vs lbs ubs us is

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
          step (OIEE svS@(SvS s tt ii) (E i)) = return $ Skip (OIET svS (E i))
          step (OIET svS@(SvS s tt ii) (E i)) | Just l <- leftSibling (rightMostLeaf frst (getTFEIx utfe)) frst i =
            return $ Yield (SvS s (tt:.TreeIxR frst jl (T l)) (ii:.:RiTirO (T l))) 
                           (OIEF svS $ if i == (getTFEIx utfe) then (L.map F $ sortedSubForests frst) else [])
          step (OIET svS@(SvS s tt ii) (E i)) = return Done
          step (OIEF svS@(SvS s tt ii) []) = return Done
          step (OIEF svS@(SvS s tt ii) (x:xs)) =
            return $ Yield (SvS s (tt:.TreeIxR frst jl x) (ii:.:RiTirO x)) (OIEF svS xs) 
          step (OIT svS@(SvS s tt ii) (T i)) =

            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , MkStream m S is
  ) => MkStream m S (is:.TreeIxR p v a C) where
  mkStream S (vs:._) (lus:.TreeIxR frst lk uu) (is:.TreeIxR _ _ kt)
    = map (\(ElmS zi) -> ElmS $ zi :.: RiTirC kt)
    . staticCheck (let k = getTFEIx kt;u = getTFEIx uu in k >=0 && k<= u)
    $ mkStream S vs lus is
  {-# INLINE mkStream #-}



            
ADP/Fusion/Core/ForestAlign/PermuteRightLinear.hs
  , MinSize c
  ) => AddIndexDense s (us:.TreeIxR p v a I) (cs:.c) (is:.TreeIxR p v a C) where
  addIndexDenseGo (cs:._) (vs:.Complemented) (lbs:._) (ubs:._) (us:.TreeIxR frst lk v) (is:.TreeIxR _ _ j)
    = map go .addIndexDenseGo cs vs lbs ubs us is
    where go (SvS s tt ii) =
            let RiTirC tf = getIndex (getIdx s) (Proxy :: PRI is (TreeIxR p v a C))
            in  SvS s (tt:.TreeIxR frst lk tf) (ii:.:RiTirC tf)
  {-# Inline addIndexDenseGo #-}