I'm very new to prolog, specifically, SWI-PL. I've seen several related questions about computing matrix-vector products. It seems that they're all unnecessarily complicated or use libraries. This question contains a nice first principles implementation of the dot product as:
dot([], [], 0).
dot([H1|T1], [H2|T2], Result) :-
Prod is H1 * H2,
dot(T1, T2, Remaining),
Result is Prod + Remaining.
It seems like we could get a nice definition of a matrix vector product (MVP) by applying dot
to every element of the matrix and every element of the list. Something like:
maplist(dot, M, V, R).
or
maplist(maplist(dot), M, V, R).
where M is a matrix (list of lists), v is a vector, and R is the result. however, these consistently give false
, for values such as:
[[2,3],[4,5]],[1,0]
what am I missing?