Data Storage Schemes
The existence of the subscripting operators generally makes the storage scheme used by the vector, matrix, and array classes completely transparent to the user. In fact, one of the great benefits of object-oriented programming is that such an implementation detail can be completely hidden without any loss of performance or functionality. There area a few cases, however, where knowing how the data is organized in the data block is useful:
*You may want to initialize a matrix or array using a vector or a C-style array.
*You might want to pass a pointer to the array's data to a Fortran subprogram, or to a C or C++ subroutine that doesn't use the Essential Math Module classes.
*Knowing how the data are stored might help you design faster algorithms. By structuring your algorithms in such a way that memory is accessed contiguously, you can minimize page faults and use your memory cache most effectively.
There are two conventional methods of organizing multidimensional arrays in memory: row major order, as used by C and C++ array types; and column major order, which is used by Fortran. Rather than decide between these two alternatives, we chose a storage scheme flexible enough to accommodate both. The appropriate matrix and array constructors and member functions have an optional final argument of type RWDataView::Storage. This type is an enum with two possible values: ROW_MAJOR and COLUMN_MAJOR. By setting this variable, you can control how the matrix or array is stored. The default setting is always COLUMN_MAJOR. Here's an example of how you can use this feature to construct an RWGenMat<double> from a regular C++ array of doubles:
 
static Adat[3][3] = {3,2,1, 4,1,8, 7,8,0};
RWGenMat<double> A(Adat,3,3,RWDataView::ROW_MAJOR);
The ROW_MAJOR parameter in the constructor specifies that the new matrix be stored in row major order, and that the data be interpreted as row major data.
Here's an example of passing a matrix to a C function:
 
RWGenMat<double> A(3,3,RWDataView::ROW_MAJOR);
.
.
.
Cfunc(A.data(),A.rows(),A.cols());