#include
#include
using namespace std;
//A version of the dot product function using vector class
double dot(vector x, vector y)
{
//Initialise the answer
double answer = 0.0;
//If the vectors are not of the same size, die
if(x.size() != y.size())
{
cout << "Vector argments to dot(x,y) are not the same size" << endl;
exit(1);
}
//Otherwise
else
{
//Loop over each entry of the vector and add the product to the result
for(unsigned int i=0;i x(3), y(3);
x[0] = 1.0; x[1] = 2.0; x[2] = 3.0;
y[0] = 5.0; y[1] = -1.0; y[2] = 10.0;
//Print out the dot product, the answer should be 5 - 2 + 30 = 33
cout << dot(x,y) << endl;
}