Created
May 27, 2015 10:03
-
-
Save kitlabcode/5c74334f200326ad72e0 to your computer and use it in GitHub Desktop.
Finding a dot product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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