Hi everyone this is my first post, i've been browsing for awhile and finally decided to join. I'm having trouble with an assignment i have in class. I need to calculate the euclidean distance between two 2d vector. The function takes in two 2d vectors of integers. I'm also having trouble deciding what to use as a return when i calculate the distance between both 2d vectors either a vector<int> or a vector<vector<int> >??
vector <vector<double> > Location::CalculateEuclideanDistance (vector <vector<int> >trainingData, vector <vector<int> > testData)
{
count=trainingData.size();
/* using iterators
for ( ; rowIterator != rowEnd; ++rowIterator )
{
vector<int>::iterator columnIterator = rowIterator->begin();
vector<int>::iterator columnEnd = rowIterator->end();
for ( ; columnIterator != columnEnd; ++columnIterator )
*/
for(int i=0; i <count ;i++)
for(int j=0; j <count ; j++)
{
addedSum= addedSum+ pow( fabs(trainingData[i][j]-testData[i][j]),2);
distance=sqrt(addedSum);
cout << distance;
distanceVector[i][j]=distance;
cout <<" The Euclidean Distances at point " << distanceVector[i][j] << "is " << distance;
}
return distanceVector;
}