Hi all,

I have a simple mathematical series that I need to expand fully and I am not sure what the most efficient way is of achieving this. I know I can write a for-loop quite simply to do this but I don't know if a solution already exists in e.g., STL.

I discovered that I can sum elements of a vector using accumulate(); and thought that maybe somehow I can prepare the elements of the vector before they are subjected to the function. Basically, my series is quite simple, I have a constant exponent value and I have to raise the value of each of the vector elements by this exponent, and then sum all the elements of the array.

The big issue I'm having right now though is that the vector I am using is a vector of object pointers, and the values to be summed in the series belong to a member variable of those objects.

I want to code this series expansion into one of my class functions (another class from the class that produces the objects I'm using).

I've tried to do the following, but it doesn't seem to be working:

```
void FooClass::expandSeries()
{
sum = accumulate(pointerVector->value.begin(),pointerVector->value.end(),0);
}
```

The error is get is:

simulation.cpp:30: error: base operand of '->' has non-pointer type 'std::vector<ObjectName*, std::allocator<ObjectName*> >'

I don't understand this as the vector is clearing a vector of pointers and it works like that when I'm using it in other parts of the code.

I would appreciate if someone could help me sort out how to do this with accumulate (and also then how best to raise all of the vector elements to the exponent value before submitting them to the function). If not with accumulate, I'd appreciate any advice on how to do this efficiently.

I think it can be done with Boost but if there's some way of avoiding that, I'd like to hear so. Otherwise I might just revert to a simple for-loop and deference each object.

Thanks a lot,

Kartik