Skip to content

vector dot - inconsistent results #88958

Closed Answered by tannergooding
ernest-morariu asked this question in General
Discussion options

You must be logged in to vote

-- Noting that I may have made a mistake in the pairwise algorithm. It's early and I didn't think too deeply 😅

The general intent is that you add neighbors to eachother recursively. So (a[0] + a[1]) and (a[2] + a[3]) and so on. This halves the length. You then do it again on those intermediates until you only have 1 result left.

So for 4 elements:

var tmp1 = (a[0] + a[1]);
var tmp2 = (a[2] + a[3]);
return tmp1 + tmp2;

Or for 8 elements:

var tmp1 = (a[0] + a[1]);
var tmp2 = (a[2] + a[3]);
var tmp3 = tmp1 + tmp2;

var tmp4 = (a[4] + a[5]);
var tmp5 = (a[6] + a[7]);
var tmp6 = tmp4 + tmp5;

return tmp3 + tmp6;

etc

Replies: 4 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@ernest-morariu
Comment options

Comment options

You must be logged in to vote
1 reply
@tannergooding
Comment options

Answer selected by ernest-morariu
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants