I am trying to do element-wise multiplication (.*) between two 2D vectors in C++11 using the code below but I am getting the errors as Error C2664 'int std::multiplies::operator ()(const _Ty &,const _Ty &) const' : cannot convert argument 1 from 'std::vector>' to 'const int &' I could not figure out what the actual problem is?
The code I used is as follows
// Example program
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iterator>
int main()
{
std::vector<std::vector<int32_t>> Route = { { 1,2 },{ 3,4 } };
std::vector<std::vector<int32_t>> Spectrum = { { 2,2 },{ 3,3 } };
std::vector<std::vector<int32_t>> score;
//and do element-wise multiplication of Spectrum and Route i.e. Spectrum .* Route
std::transform(Spectrum.begin() + 1, Spectrum.end(), Route.begin() + 1, std::back_inserter(score), std::multiplies<int32_t>());
std::vector< std::vector<int32_t> >::iterator row;
std::vector<int32_t>::iterator col;
for (row = score.begin(); row != score.end(); row++) {
for (col = row->begin() + 1; col != row->end(); col++) {
std::cout << *col << std::endl;
}
}
}
Aucun commentaire:
Enregistrer un commentaire