I'm trying to implement an Euclidean vector for my programming assignment. I need to overload operator* to provide dot product calculation for two vectors with arbitrary same dimension. As 3D vector for example:
Vector<3> v1, v2; //two 3D vectors.
double dotProduct = v1 * v2;
The value of dotProduct should be v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2]
So, my problem is how to get this value without using any explicit loop and std::accumulate() operation in numeric.h header file? Because those are forbidden in this assignment.
P.S. I may use functor(self defined) together with STL algorithm.
Vector?dotProduct = v1[0]*v2[0]+v1[1]*v2[1]+v1[2]*v2[2], it appears to me that you have an idea of how to approach this. What have you tried and where exactly are you stuck?<numeric.h>, only<numeric>. Your answer is on this page. (Hint: the dot product is a type of what?)