D
dakupoto
Could some C++ guru please provide some hints to this
odd C++ STL vector issue ?
I have in a class:
private:
std::vector<double> invect;
std::vector<double> invect_copy;
std::vector<double> filtvect;
'invect' gets filled correctly with 64 distinct double
values, as checked with a simple print statement.
Then I have:
invect_copy = invect;
invect.clear();
/*for(i = 0; i < MAXELEM; i++) std::cout<<invect_copy<<std::endl; */
Here again, the print statement correctly shows the elements added
to 'invect_copy'
Now I wish to read out chunks of data from 'invect_copy' as:
if(invect_copy.size() > 0)
{
while(clim + MAXFILTELEM < MAXELEM)
{
for(j = 0; j < MAXFILTELEM; j++)
{
cind = j + clim;
tmp = invect_copy.at(cind);
std::cout<<name()<<" "<<j<<" "<<cind<<" "<<clim<<" "<<tmp<<std::endl;
filtvect.push_back(tmp);
}
This time however, I get the same value being for all values
of the index 'cind' as:
mavg 0 0 0 1.80429e+09
mavg 1 1 0 1.80429e+09
mavg 2 2 0 1.80429e+09
mavg 3 3 0 1.80429e+09
mavg 4 4 0 1.80429e+09
mavg 5 5 0 1.80429e+09
mavg 6 6 0 1.80429e+09
mavg 7 7 0 1.80429e+09
mavg 8 8 0 1.80429e+09
mavg 9 9 0 1.80429e+09
mavg 0 1 1 1.80429e+09
mavg 1 2 1 1.80429e+09
mavg 2 3 1 1.80429e+09
mavg 3 4 1 1.80429e+09
mavg 4 5 1 1.80429e+09
mavg 5 6 1 1.80429e+09
mavg 6 7 1 1.80429e+09
mavg 7 8 1 1.80429e+09
mavg 8 9 1 1.80429e+09
mavg 9 10 1 1.80429e+09
mavg 0 2 2 1.80429e+09
mavg 1 3 2 1.80429e+09
and so on ...
Could someone please point out what I might be doing
wrong ? Any hints, suggestions would be gratefully
accepted.
odd C++ STL vector issue ?
I have in a class:
private:
std::vector<double> invect;
std::vector<double> invect_copy;
std::vector<double> filtvect;
'invect' gets filled correctly with 64 distinct double
values, as checked with a simple print statement.
Then I have:
invect_copy = invect;
invect.clear();
/*for(i = 0; i < MAXELEM; i++) std::cout<<invect_copy<<std::endl; */
Here again, the print statement correctly shows the elements added
to 'invect_copy'
Now I wish to read out chunks of data from 'invect_copy' as:
if(invect_copy.size() > 0)
{
while(clim + MAXFILTELEM < MAXELEM)
{
for(j = 0; j < MAXFILTELEM; j++)
{
cind = j + clim;
tmp = invect_copy.at(cind);
std::cout<<name()<<" "<<j<<" "<<cind<<" "<<clim<<" "<<tmp<<std::endl;
filtvect.push_back(tmp);
}
This time however, I get the same value being for all values
of the index 'cind' as:
mavg 0 0 0 1.80429e+09
mavg 1 1 0 1.80429e+09
mavg 2 2 0 1.80429e+09
mavg 3 3 0 1.80429e+09
mavg 4 4 0 1.80429e+09
mavg 5 5 0 1.80429e+09
mavg 6 6 0 1.80429e+09
mavg 7 7 0 1.80429e+09
mavg 8 8 0 1.80429e+09
mavg 9 9 0 1.80429e+09
mavg 0 1 1 1.80429e+09
mavg 1 2 1 1.80429e+09
mavg 2 3 1 1.80429e+09
mavg 3 4 1 1.80429e+09
mavg 4 5 1 1.80429e+09
mavg 5 6 1 1.80429e+09
mavg 6 7 1 1.80429e+09
mavg 7 8 1 1.80429e+09
mavg 8 9 1 1.80429e+09
mavg 9 10 1 1.80429e+09
mavg 0 2 2 1.80429e+09
mavg 1 3 2 1.80429e+09
and so on ...
Could someone please point out what I might be doing
wrong ? Any hints, suggestions would be gratefully
accepted.