Skip to content

Instantly share code, notes, and snippets.

@kitlabcode
Created May 27, 2015 10:03
Show Gist options
  • Select an option

  • Save kitlabcode/5c74334f200326ad72e0 to your computer and use it in GitHub Desktop.

Select an option

Save kitlabcode/5c74334f200326ad72e0 to your computer and use it in GitHub Desktop.
Finding a dot product
int[] v1 = {1,2,3};
int[] v2 = {3,2,1};
// dot product of vector
int[] dotProducts = v1.DotProduct(v2);
// output:
// 3
// 4
// 3
public static int[] DotProduct(this int[] vector1, int[] vector2)
{
return vector1.Zip(vector2, (x, y) => x*y).ToArray();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment