I would like to perform an operation with vectors, but I lost my way. Help would be appreciated.
The operation is, vv = v -(alpha +1)*i; where v and vv are vectors. I need to subtract (alpha +1 ) * i from each element of the vector v, and define those subtracted elements inside my vector vv.
int main ()
{
constint N = 16 * 2;
double eta = 0.25;
constdouble alpha = 1.2; //these are constants i use.
complex w(0.0, 1.0); //Defining a complex number here.
double z = w.im(); //using its imaginary part.
constdouble MAX_ELEMS = N * eta;
constdouble MAXIM_ELEMS = N;
vector<double> vv;
vector<double> v;
for (double i = 0; v.size() < MAX_ELEMS; i += eta)
{
v.push_back(i);
for (double j = v.at(1) - (alpha + 1)*z ; vv.size() < MAXIM_ELEMS; j = v.at(i++))
{
vv.push_back(j);
}
}
// Want to print my vv vector, at the end of this calculation.
cout << "my vv vector contains:";
for (unsigned i = 0; i < vv.size(); i++)
cout << ' ' << vv.at(i);
cout << '\n';
return 0;
}
vector<double> vv;
vv.reserve( N );
vector<double> v;
v.reserve( N );
for ( int i = 0; i < N; i++ )
{
v.push_back( i * eta );
vv.push_back( v.back() - ( alpha + 1 ) * i );
}