# Applying dot product to list of vectors

Suppose I have: w = {1,0}. I want to apply the dot product of w to each element of the list of vectors x = {{1,2}, {3,4}, {4,5}} to get {1,3,4}. Simply doing w.x does not work. How do I do this?

• try x.w and it works May 13 '19 at 0:29

As J42161217 already wrote in a comment, you may use x.w in this case.

Should you ever have to compute the entrywise Dot-products of two lists of vectors x and y of same size, you may use the undocumented function NDSolveFEMMapThreadDot:

n = 1000000;
x = RandomReal[{-1, 1}, {n, 2}];
y = RandomReal[{-1, 1}, {n, 2}];

a = MapThread[Dot, {x, y}]; // AbsoluteTiming // First
b = NDSolveFEMMapThreadDot[x, y]; // AbsoluteTiming // First

Max[Abs[a - b]]


0.722634

0.01565

0.

Unfortunately, this works only for vectors of machine precision reals.