M
Michael Aramini
I need to represent 1D and 2D arrays of numeric or bool types in a C++
program. The sizes of the arrays in my intended application are
dynamic in the sense that they are not known at compile time, so I'd
like to use an STL container class template such as valarray or vector
to represent 1D arrays, and valarrays or vectors of valarrays or
vectors to represent 2D arrays.
As I said the sizes of the arrays in my intended application are
dynamic in that they are determined at run time, but on the other hand
I don't anticipate the need to continually resize a given array during
a given call to the routine in which it is declared. The thing that's
more important to my application is speed. Is there a significant
different between the element access speeds of valarrays vs. vectors?
For 1D arrays, the choices are:
valarray<type> vs. vector<type>
For 2D arrays, the choices are:
valarray< valarray<type> > vs. valarray< vector<type> > vs.
vector< valarray<type> > vs. vector < vector<type> >
In my application, type is will be a scalar type such as bool, double,
int, or size_t.
The code is initially being targeted for Linux, but it may also be
ported to another UNIX such as IRIX, or perhaps even Windows, so I'd
like to keep things portable by using an STL container rather than one
from some operating system specific template library.
-Michael
program. The sizes of the arrays in my intended application are
dynamic in the sense that they are not known at compile time, so I'd
like to use an STL container class template such as valarray or vector
to represent 1D arrays, and valarrays or vectors of valarrays or
vectors to represent 2D arrays.
As I said the sizes of the arrays in my intended application are
dynamic in that they are determined at run time, but on the other hand
I don't anticipate the need to continually resize a given array during
a given call to the routine in which it is declared. The thing that's
more important to my application is speed. Is there a significant
different between the element access speeds of valarrays vs. vectors?
For 1D arrays, the choices are:
valarray<type> vs. vector<type>
For 2D arrays, the choices are:
valarray< valarray<type> > vs. valarray< vector<type> > vs.
vector< valarray<type> > vs. vector < vector<type> >
In my application, type is will be a scalar type such as bool, double,
int, or size_t.
The code is initially being targeted for Linux, but it may also be
ported to another UNIX such as IRIX, or perhaps even Windows, so I'd
like to keep things portable by using an STL container rather than one
from some operating system specific template library.
-Michael