% matrix , matrix multiplication mmultiply([],_,[]). mmultiply([V0|Rest], V1, [Result|Others]):- mmultiply(Rest, V1, Others), multiply(V1,V0,Result). % matrix , vector multiplication multiply([],_,[]). multiply([V0|Rest], V1, [Result|Others]):- multiply(Rest, V1, Others), vmul(V0,V1,Result). % vector , vector multiplication vmul([],[],0). vmul([H1|T1], [H2|T2], Result):- vmul(T1,T2, Newresult), Product is H1+H2, Result is Product+Newresult. -------------------------------------------------- vmul([],[],0). vmul([H1|T1], [H2|T2], Result):- vmul(T1,T2, Newresult), Product is H1*H2, Result is Product+Newresult.