[email protected]
[Top] [All Lists]

[Haskell-cafe] Re: parallel matrix multiply (dph, par/pseq)

Subject: [Haskell-cafe] Re: parallel matrix multiply dph, par/pseq
From: Johannes Waldmann
Date: Tue, 19 Jan 2010 11:08:27 +0000 UTC
> ... use Array (Int,Int) Double, as it accesses its elements in O(1). 

thanks for the comments.

I don't need O(dim^0) element access - 
I need O(dim^reasonable) addition and multiplication.

Modelling a matrix as [[Element]] should be nearly fine 
(for sequential execution), I think these are quadratic/cubic:

a * b = zipWith (zipWith (+)) a b  
a * b = for a $ \ row -> 
        for ( transpose b ) $ \ col -> 
            sum $ zipWith (*) row col

The only problem with this code is that 'transpose b'
(assuming the compiler lifts it to outer scope)
allocates memory that later becomes garbage,
but not immediately, since it is needed several times.

( in the above, for = flip map  , 
which is missing from the standard libs?
by analogy to  forM = flip mapM )

Best regards, J.W.

_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

<Prev in Thread] Current Thread [Next in Thread>