BIGMATRIX - Functions to manipulate 2-dimensional matrices that are too big
to fit in real memory, but that are small enough to fit in
virtual memory:
bmalloc allocate a big matrix
bmfree free a big matrix
bmread read a vector from a big matrix
bmwrite write a vector to a big matrix
Function Prototypes:
void *bmalloc (int nbpe, int n1, int n2);
void bmfree (void *bm);
void bmread (void *bm, int dir, int k1, int k2, int n, void *v);
void bmwrite (void *bm, int dir, int k1, int k2, int n, void *v);
bmalloc:
Input:
nbpe number of bytes per matrix element
n1 number of elements in 1st (fastest) dimension
n2 number of elements in 2nd (slowest) dimension
Returned:
bm pointer to big matrix
bmfree:
Input:
bm pointer to big matrix state (returned by bmalloc)
bmread:
Input:
bm pointer to big matrix state (returned by bmalloc)
d = 1 or 2: direction in which to read matrix elements
k1 1st dimension index of first matrix element to read
k2 2nd dimension index of first matrix element to read
n number of elements to read
Output:
v array[n] to contain matrix elements read
bmwrite:
Input:
bm pointer to big matrix state (returned by bmalloc)
d = 1 or 2: direction in which to write matrix elements
k1 1st dimension index of first matrix element to write
k2 2nd dimension index of first matrix element to write
n number of elements to write
v array[n] containing matrix elements to write
Notes:
The bm functions provide access to a big 2-dimensional matrix along
either the 1st or 2nd dimensions. Although, the matrix must be small
enough to fit in virtual memory, it may be too large to fit in real memory.
These functions provide equally efficient (or equally inefficient) access
to vectors in a big matrix along either the 1st or 2nd dimensions.
For example, the following algorithm will efficiently transpose an
n1 by n2 array of (n1*n2) floats stored in a file:
void *bm;
float *v;
bm = bmalloc(sizeof(float),n1,n2);
for (i2=0; i2