Thanks for the input guys.
The >> problem was a dumb thing on my part - fixed easily.
For the 'late construction' part I experimented with the smart pointer/new
approach as some suggested, but ended up initialising the:
std::vector< std::valarray< float > > foo;
...as a placeholder and then using the built in .resize() abilities of both
vector and valarray appropriately. This turns out to be fast and means I
don't have to mess about with memory allocation/deallocation myself. I have
a preference for avoiding pointers and using the STL as much as possible to
let other people deal with the headaches!
Someone asked about the ( i, j ) access - I do this on all my linear
algebra/maths code to mimic Fortran syntax from 1 to n, just as I did before
with C (but with different syntax in that case). One way is to use:
valarray<T> v( rows * cols );
...for storage and set up another valarray of pointers (uo_row_ptr) to the
start of each 'row' in the matrix and then:
T & operator ()( const iter r, const iter c )
{
return *(uo_row_ptr( r )+c);
};
There are many options but this one works well, usually just as fast as or
sometimes even faster than raw array access with a good compliler and
optimisation in fact (especially when you use valarray).
It allows me to easily escape the dreaded and almost universal requirement
amongst the C++ community to do access/loops from 0 to n-1 which is so
unnatural for mathematical work. This is one of the main reasons why I
don't use some of the powerful libraries like uBlas, MTL and Blitz.
M
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
_/ _/ _/_/_/ Hopkins Research Ltd
_/ _/ _/ _/
_/_/_/_/ _/_/_/
http://www.hopkins-research.com/
_/ _/ _/ _/
_/ _/ _/ _/ 'touch the future'
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[ See
http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]