#include #include #include using namespace std; ////////////////////////////////////////////////////// //Prototypes for readDoubles and dotProduct goes here. ////////////////////////////////////////////////////// double* readDoubles (string, int&); double dotProduct(double*, double*, int); int main() { int size1, size2; //read in the two vectors double* v1 = readDoubles("hw25_vector1.txt", size1); cout << "Read vector 1. Size is: " << size1 << endl; double* v2 = readDoubles("hw25_vector2.txt", size2); cout << "Read vector 2. Size is: " << size1 << endl; //calculate dot product double dp = dotProduct(v1, v2, size1); //Output the result cout << "The dot product of Vector1 and Vector2 is: " << dp << endl; return 0; } ////////////////////////////////////////////////////// //Definitons for readDoubles and dotProduct goes here. ////////////////////////////////////////////////////// double* readDoubles (string filename, int& size) { // open file ifstream fin(filename.c_str()); // get size from the file fin >> size; // make the array double *vec; vec = new double[size]; // fill in array from the file for (int i=0; i> vec[i]; } return vec; } // Compute dotproduct of vec1 and vec2, each of size 'size' double dotProduct (double *vec1, double *vec2, int size) { double result = 0; for (int i=0; i