Accumulating Vectors

I have two vectors
1
2
vector<double> Weights;
vector<double> Inputs;

I have been looking for about half an hour, looking over examples and the STL documentation about the function accumulate. I was wondering if it is possible to return a vector of the two vectors multiplied by each other (they are both the same size, eg.
1
2
3
newVector[0] = Weights[0]*Inputs[0];
newVector[1] = Weights[1]*Inputs[1];
...

I kow i could do this in a for loop, but using the accumulate function seems like it would be better, if not equivalent, so is it possible?
1
2
3
4
5
6
std::vector<double> a = { 1, 2, 3, 4, 5 } ;
std::vector<double> b = { 6, 7, 8, 9, 10 } ;
std::vector<double> result ;

std::transform( a.begin(), a.end(), b.begin(), std::back_inserter(result),
                std::multiplies<double>() ) ;

Topic archived. No new replies allowed.