The virtual memory system allows the matrix elements to be stored outside of RAM. The external file may be stored on a hard drive, floppy drive, or in a RAM disk. The RAM disk provides the fastest access to the matrices, but may be of little value to machines without a large amount of extended memory. The matrix class stores at most 64 doubles in a buffer in RAM. If the requested element is not in the buffer, then the virtual system searches the file for the block containing the element. The virtual system then pages the requested block into the matrix buffer.
The algorithm for allocating memory is found in Kernighan and Ritchie[#!kr:cprg!#]. Holub[#!Ho:pr!#] adapted the algorithm for managing the data in virtual memory file (instead of data on the heap). Holub's program was modified to compile in Turbo C++, and some bugs were corrected. Holub then constructed a class for integer vectors stored in virtual memory. This class was adapted to doubles, and the matrix class was constructed by dereferencing matrix elements stored in the virtual vector in row major order. The matrix class, VMatrix, will be described later.
This chapter will give a loose explanation of the virtual
memory system. It will concentrate on the public functions
in Holub's work. The reader who is interested in using
these functions should obtain a copy of the article, and
work through the program . There are some sparks in it.
However, these functions are fragile, so it is not recommended that they be used directly in any program for the virtual matrix applications. The virtual memory functions should be considered encapsulated in the matrix algorithms. The matrix class frees the user of the overhead of directly manipulating the virtual memory.
If you are using the in-ram version, you can skip this chapter since matrices are allocated from the heap using calloc().