📄 bigmatrix.cwp.lib
字号:
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 matrixbmfree free a big matrix bmread read a vector from a big matrixbmwrite write a vector to a big matrixFunction 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 elementn1 number of elements in 1st (fastest) dimensionn2 number of elements in 2nd (slowest) dimensionReturned:bm pointer to big matrixbmfree: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 elementsk1 1st dimension index of first matrix element to readk2 2nd dimension index of first matrix element to readn number of elements to readOutput:v array[n] to contain matrix elements readbmwrite:Input:bm pointer to big matrix state (returned by bmalloc)d = 1 or 2: direction in which to write matrix elementsk1 1st dimension index of first matrix element to writek2 2nd dimension index of first matrix element to writen number of elements to writev array[n] containing matrix elements to writeNotes:The bm functions provide access to a big 2-dimensional matrix alongeither the 1st or 2nd dimensions. Although, the matrix must be smallenough 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 ann1 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<n2; i2++) { (read n1 floats from input file into array v); bmwrite(bm,1,0,i2,n1,(char*)v); } for (i1=0; i1<n1; i1++) { bmread(bm,2,i1,0,n2,(char*)v); (write n2 floats in array v to output file); } bmfree(bm);Author: Dave Hale, Colorado School of Mines, 05/17/89
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -