Since C++ doesn't provide multidimensional arrays in its standard library technical applications typically use one of the more well-known array libraries such as Eigen, Armadillo, uBLAS, or Boost.MultiArray. These each have somewhat different goals, capabilities, and performance. At Objexx we have a focus on array performance and we do a lot of conversions from Fortran to C++. You can criticize Fortran for its many limitations but its arrays have capabilities that are very nice for scientific and engineering applications.
From this perspective we have certain features that we would like to see these major array libraries adopt:
-
Flexible index ranges (like Fortran). Sometimes natural indexing for an algorithm doesn't start at zero. C++ provides a nice syntax for this, which we use in the ObjexxFCL arrays:
Array2D_int A( {-n,n}, 3 );
This is supported with no lookup performance penalty. -
Live slice (section) proxies.
These can exploit the same C++ syntax shown above for index ranges for elegant usage:
A( {-i,i,2}, 2 )
Slices can be non-contiguous, so their use must be balanced against performance considerations but a proper "Fortranic" implementation can eliminate other kinds of overhead. - Linear indexing to eliminate the index offset overhead in lookups for 2+D arrays in loops. See Array Lookups for more on linear indexing.
- Row and column major array layout support. Row major is more natural in the C/C++ world but column major is more familiar for projects migrating from Fortran. We provide both variants in the ObjexxFCL and we built a nifty Clang-based tool for converting a C++ code base between them.