On Mon, 17 Jan 2011 10:38:30 +0000 Blake Rain <blake.r...@gmail.com> wrote:
> So sorry, I meant: > > mult :: (Num a) => [[a]] -> [[a]] -> [a] > mult m1 m2 = [foldl (+) 0 $ zipWith (*) x y | x <- m1, y <- transpose > m2] > Shouldn't the result of multiplying an (n,k)-matrix by an (k,m)-matrix be an (n,m)-matrix? The way you've written it the result will be a list of length n*m. > > > > > Regarding performance: did you make sure you're forcing the > > evaluation of the result matrix? > > I thought I was. It's printing the results as expected. Could be I'm > just imagining I am and suffering a delusion or misunderstanding. > Another issue to look out for is let-floating: if you perform the same matrix multiplication repeatedly, the compiler might very well lift the matrix calculation outside the loop. Pedro _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe