[Haskell-beginners] Error in converting List of Lists into PArray ( Parray a )

mukesh tiwari mukeshtiwari.iiitm at gmail.com
Wed Jan 18 20:56:30 CET 2012


Hello all
I am trying to convert List of Lists ( [[(Int , Double )]] ) into PArray (
PArray ( Int , Double )) but getting run time error. This code works fine
and print list of PArray ( Int , Double ) but when i put print $ P.fromList
( map P.fromList c ) then i am getting runtime error. It says "Main:
Data/Array/Parallel/PArray/PDataInstances.hs:337:10-30: No instance nor
default method for class operation
Data.Array.Parallel.PArray.PData.fromListPR". Could some one please tell me
how to resolve this issue.
Thank you


--import ParallelMat
import Data.List
import System.Environment
import Data.Array.Parallel
import qualified Data.Array.Parallel.PArray as P


processMatrix :: [ [ Double ] ] -> [ [ Double ] ] -> [ ( [ ( Int , Double )
] , [ ( Int , Double ) ]) ]
processMatrix [] [] = []
processMatrix ( x : xs ) ( y : ys )
  | ( all ( == 0 ) x )  Prelude.|| (  all ( == 0 ) y ) = processMatrix xs ys
  | otherwise = ( filter ( \( x , y ) -> y /= 0 ) . zip [ 1..]  $ x ,filter
(  \( x , y ) -> y /= 0 ) . zip [1..] $ y  ) : processMatrix xs ys

main = do
    [ first , second ] <- getArgs
    a <- readFile first
    b <- readFile second
    let a' = transpose . tail . map ( map ( read :: String -> Double ) .
words ) . lines $ a
        b' = tail . map ( map ( read :: String -> Double ) . words ) .
lines $ b
        ( c , d )   = unzip $ processMatrix a' b'
    print $   (  map P.fromList c )
   --print d

Macintosh-0026bb610428:Haskell mukesh$ ghc --make  -Odph -fdph-par  Main.hs
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking Main ...
Macintosh-0026bb610428:Haskell mukesh$ ./Main  A.in A.in
[fromList<PArray> [(1,1.0),(6,1.0)],fromList<PArray>
[(4,11.0),(9,11.0)],fromList<PArray> [(1,4.0),(4,2.0),(6,4.0),(9,2.0)]]

Putting print $ P.fromList ( map P.fromList c )

Macintosh-0026bb610428:Haskell mukesh$ ghc --make  -Odph -fdph-par  Main.hs
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking Main ...
Macintosh-0026bb610428:Haskell mukesh$ ./Main  A.in A.in
Main: Data/Array/Parallel/PArray/PDataInstances.hs:337:10-30: No instance
nor default method for class operation
Data.Array.Parallel.PArray.PData.fromListPR

Input file A.in
10 10
1 2 3 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 2 11 2
0 1 2 0 0 0 0 0 0 0
1 2 3 0 0 0 0 0 0 4
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 2 11 2
0 1 2 0 0 0 0 0 0 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120119/f5ac0182/attachment.htm>


More information about the Beginners mailing list