I'm trying to write a function which performs calculations with a vector containing data from a CSV file. The result is to be stored in another vector.

If a vector element obtained from the CSV file is negative, the corresponding element in the new vector should equal to zero. If the element from the original vector is within a certain range, it should perform the calculation as normal and finally, if it's above a certain number it should again be set to zero.

I have written some code which performs the calculation when the element is in range:

The vector 'Data' contains the orginal data from the CSV. This piece of code cubes the elements and multiplies them by another product.Code:void TurPw(vector<double> &Data){ double Pproduct = 0.5*RotorArea*AirDensity; vector<double> vec2; for( vector<double>::const_iterator i=Data.begin(); i!=Data.end(); ++i){ vec2.push_back( pow(*i, 3) ); } for( vector<double>::iterator iter = vec2.begin(); iter!=vec2.end(); ++iter){ *iter *= Pproduct; } }

How could I implement the other conditions?

Any help appreicated,

Thanks!