Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

3.3 Data and Views

The vector, matrix, and array classes are built on a powerful and simple architecture which we call the data-view model. Understanding this architecture will help you use Math.h++ to write efficient, simple code that is easy to maintain. Here is the key point:


NOTE: Vectors, matrices, and arrays provide views into blocks of data. While more than one object can view the same block of data, they need not share the same view of it. Associated with each vector, matrix, and array is information describing which data in the block is being viewed, and how to interpret the data.

As an example of the data-view model, consider the following figure:

Figure 1 -- Different views into a single data block

Figure 1 illustrates a 3 x 3 matrix A, a 2 x 2 matrix Atl, which is a view of the top left corner of A, and a vector v, which is a view of A's middle row. All three of these objects are different views into a single data block. Since the views share the same data, changing the middle element 5 in the vector v, for example, also changes the corresponding element in A and Atl. Assigning different names to views of the same data is sometimes called aliasing. In later sections, we will show how to use the data-view concept effectively, why it leads to efficient code, and how to avoid aliasing when necessary.


Previous fileTop of DocumentContentsIndexNext file

©Copyright 1999, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.