M
Michael Hopkins
Hi all
I have a class that contains as one of it's members a type that is
internally constructed like this:
std::vector< std::valarray< float > > foo
Think of it as a matrix. I cannot construct foo when the class itself is
constructed because I don't know how big it needs to be until I have loaded
that information from a file.
Within the member function that loads the file (including the information r
& c), this compiles OK:
std::vector< std::valarray< float > > temp( r, std::valarray<float>( c ));
foo = temp;
....but I'm sure there is a more elegant/efficient way to do this on foo
directly - any tips on this?
I have defined access to this type like a Fortran array i.e. foo( i, j )
either reads from or writes to the j'th valarray element of the i'th vector.
This works fine in general usage but, not when I am trying to load from the
input file in a loop:
std::ifstream infile( from_path );
// in i, j, loop
infile >> foo( i, j );
Again, any tips welcomed.
TIA
Michael
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ _/ _/_/_/ Hopkins Research Ltd
_/ _/ _/ _/
_/_/_/_/ _/_/_/ http://www.hopkins-research.com/
_/ _/ _/ _/
_/ _/ _/ _/ 'touch the future'
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
I have a class that contains as one of it's members a type that is
internally constructed like this:
std::vector< std::valarray< float > > foo
Think of it as a matrix. I cannot construct foo when the class itself is
constructed because I don't know how big it needs to be until I have loaded
that information from a file.
Within the member function that loads the file (including the information r
& c), this compiles OK:
std::vector< std::valarray< float > > temp( r, std::valarray<float>( c ));
foo = temp;
....but I'm sure there is a more elegant/efficient way to do this on foo
directly - any tips on this?
I have defined access to this type like a Fortran array i.e. foo( i, j )
either reads from or writes to the j'th valarray element of the i'th vector.
This works fine in general usage but, not when I am trying to load from the
input file in a loop:
std::ifstream infile( from_path );
// in i, j, loop
infile >> foo( i, j );
Again, any tips welcomed.
TIA
Michael
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ _/ _/_/_/ Hopkins Research Ltd
_/ _/ _/ _/
_/_/_/_/ _/_/_/ http://www.hopkins-research.com/
_/ _/ _/ _/
_/ _/ _/ _/ 'touch the future'
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/