multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices question (Homework)

hi i was trying to solve it but All i got is type Matrix=[[Double]] multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices multMM m t = [[sum (zipWith (*) (head m)(a)) ] ]where a = [head a | a<- t] Main> multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]] [[14.0]] from this i could get only the first multiplication 14 that is by 2*1 + 1*0 + -6*-2 = 14 how can i make this go throw all rows and colums to get multiple of matrixs? Thank you~

On 3 Feb 2010, at 07:38, 조광래 wrote:
hi i was trying to solve it but
All i got is type Matrix=[[Double]]
multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices multMM m t = [[sum (zipWith (*) (head m)(a)) ] ]where a = [head a | a<- t]
Main> multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]] [[14.0]]
from this i could get only the first multiplication 14 that is by 2*1 + 1*0 + -6*-2 = 14
how can i make this go throw all rows and colums to get multiple of matrixs?
Perhaps you might try the beginners mailing list: http://haskell.org/haskellwiki/Mailing_lists http://haskell.org/mailman/listinfo/beginners because here, people will just assume one wants effective solutions. :-) Anyway, the page I mentioned before has a matrix multiplication: http://haskell.org/haskellwiki/Prelude_extensions It uses the function transpose(), which is in the module Data.List. I find looking into the modules of Hugs useful, on my computer they are in /usr/local/lib/hugs/packages but those for GHC are also available online: http://www.haskell.org/ghc/docs/latest/html/libraries/ Hans

I did a blog post on basic matrix ops which may be useful to you
http://blog.keithsheppard.name/2009/06/bird-tracks-through-math-land-basic.h...
It uses a 2D list representation for matrices which you would not do
for any performance critical work.
best
keith
On Wed, Feb 3, 2010 at 1:38 AM, 조광래
hi i was trying to solve it but
All i got is type Matrix=[[Double]]
multMM :: Matrix -> Matrix -> Matrix --multiplies two matrices multMM m t = [[sum (zipWith (*) (head m)(a)) ] ]where a = [head a | a<- t]
Main> multMM [[2,1,-6],[1,-3,2]] [[1,0,-3],[0,4,20],[-2,1,1]] [[14.0]]
from this i could get only the first multiplication 14 that is by 2*1 + 1*0 + -6*-2 = 14
how can i make this go throw all rows and colums to get multiple of matrixs?
Thank you~
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- keithsheppard.name
participants (3)
-
Hans Aberg
-
Keith Sheppard
-
조광래