ocramz / sparse-linear-algebra

Numerical computation in native Haskell
GNU General Public License v3.0
88 stars 10 forks source link

Decouple algorithms from implementation #11

Closed ocramz closed 8 years ago

ocramz commented 8 years ago

Currently, Data.Sparse.Common is the interface to sparse datastructures. It gathers SpMatrix, SpVector and IntMap2 functionality, and re-exports all of it. If we comment out as X in the line import Data.Sparse.IntMap2.IntMap2 as X , thus omitting its re-export, a number of algorithms can't find the implementation:

src/Numeric/LinearAlgebra/Sparse.hs:410:13: error: …
    • Variable not in scope:
        lookupIM2 :: IxRow -> IxCol -> IM.IntMap (IM.IntMap a) -> Maybe a1
    • Perhaps you meant ‘lookupSM’ (imported from Data.Sparse.Common)
src/Numeric/LinearAlgebra/Sparse.hs:412:20: error: …
    • Variable not in scope:
        ifilterIM2
          :: (IxRow -> IxCol -> t0 -> Bool)
             -> IM.IntMap (IM.IntMap a) -> IM.IntMap a0
    • Perhaps you meant one of these:
        ‘ifilterSM’ (imported from Data.Sparse.Common),
        ‘ifilterSV’ (imported from Data.Sparse.Common),
        ‘filterSM’ (imported from Data.Sparse.Common)
src/Numeric/LinearAlgebra/Sparse.hs:436:25: error: …
    • Couldn't match expected type ‘(Rows, Cols)’
                  with actual type ‘FDSize f’
    • In the first argument of ‘SM’, namely ‘(dim m)’
      In the expression: SM (dim m)
      In the expression: SM (dim m) $ ifilterIM2 f (dat m)
    • Relevant bindings include
        m :: f a4
          (bound at /Users/ocramz/Dropbox/RESEARCH/Haskell/sparse-linear-algebra/src/Numeric/LinearAlgebra/Sparse.hs:436:14)
        sparsifyLU :: f a4 -> SpMatrix a2 -> SpMatrix a3
          (bound at /Users/ocramz/Dropbox/RESEARCH/Haskell/sparse-linear-algebra/src/Numeric/LinearAlgebra/Sparse.hs:436:3)
src/Numeric/LinearAlgebra/Sparse.hs:436:34: error: …
    • Variable not in scope:
        ifilterIM2
          :: (IxRow -> IxCol -> t1 -> Bool)
             -> HDData f a4 -> IM.IntMap (IM.IntMap a3)
    • Perhaps you meant one of these:
        ‘ifilterSM’ (imported from Data.Sparse.Common),
        ‘ifilterSV’ (imported from Data.Sparse.Common),
        ‘filterSM’ (imported from Data.Sparse.Common)
Compilation failed.

This is wrong, because it pins the algorithm implementation to the datastructure used. We need a typeclass interface

ocramz commented 8 years ago

Fixed for now. However some algorithms such as permutAA (now commented out since not needed) require access to IntMap keys